Move savepoints functions into screen.c
This commit is contained in:
parent
46ec0d4e9c
commit
e3bbb7a3c9
3 changed files with 16 additions and 25 deletions
|
|
@ -221,6 +221,8 @@ typedef struct {
|
|||
} ScreenModes;
|
||||
PyTypeObject ScreenModes_Type;
|
||||
|
||||
#define SAVEPOINTS_SZ 256
|
||||
|
||||
typedef struct {
|
||||
unsigned int current_charset;
|
||||
uint16_t *g0_charset, *g1_charset;
|
||||
|
|
@ -231,13 +233,13 @@ typedef struct {
|
|||
|
||||
} Savepoint;
|
||||
|
||||
#define SAVEPOINTS_SZ 256
|
||||
|
||||
typedef struct {
|
||||
Savepoint buf[SAVEPOINTS_SZ];
|
||||
index_type start_of_data, count;
|
||||
} SavepointBuffer;
|
||||
|
||||
|
||||
#define PARSER_BUF_SZ 8192
|
||||
#define READ_BUF_SZ (1024*1024)
|
||||
|
||||
|
|
@ -277,7 +279,6 @@ Cursor* alloc_cursor();
|
|||
LineBuf* alloc_linebuf(unsigned int, unsigned int);
|
||||
HistoryBuf* alloc_historybuf(unsigned int, unsigned int);
|
||||
ChangeTracker* alloc_change_tracker(unsigned int, unsigned int);
|
||||
Savepoint* alloc_savepoint();
|
||||
int init_LineBuf(PyObject *);
|
||||
int init_HistoryBuf(PyObject *);
|
||||
int init_Cursor(PyObject *);
|
||||
|
|
@ -293,8 +294,6 @@ PyObject* parse_bytes_dump(PyObject UNUSED *, PyObject *);
|
|||
PyObject* parse_bytes(PyObject UNUSED *, PyObject *);
|
||||
uint16_t* translation_table(char);
|
||||
uint32_t decode_utf8(uint32_t*, uint32_t*, uint8_t byte);
|
||||
Savepoint* savepoints_pop(SavepointBuffer *);
|
||||
Savepoint* savepoints_push(SavepointBuffer *);
|
||||
void cursor_reset(Cursor*);
|
||||
Cursor* cursor_copy(Cursor*);
|
||||
void cursor_copy_to(Cursor *src, Cursor *dest);
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* savepoints.c
|
||||
* Copyright (C) 2016 Kovid Goyal <kovid at kovidgoyal.net>
|
||||
*
|
||||
* Distributed under terms of the GPL3 license.
|
||||
*/
|
||||
|
||||
#include "data-types.h"
|
||||
|
||||
Savepoint* savepoints_push(SavepointBuffer *self) {
|
||||
Savepoint *ans = self->buf + ((self->start_of_data + self->count) % SAVEPOINTS_SZ);
|
||||
if (self->count == SAVEPOINTS_SZ) self->start_of_data = (self->start_of_data + 1) % SAVEPOINTS_SZ;
|
||||
else self->count++;
|
||||
return ans;
|
||||
}
|
||||
|
||||
Savepoint* savepoints_pop(SavepointBuffer *self) {
|
||||
if (self->count == 0) return NULL;
|
||||
self->count--;
|
||||
return self->buf + ((self->start_of_data + self->count) % SAVEPOINTS_SZ);
|
||||
}
|
||||
|
|
@ -567,6 +567,19 @@ void screen_linefeed(Screen *self, uint8_t UNUSED ch) {
|
|||
screen_ensure_bounds(self, false);
|
||||
}
|
||||
|
||||
static inline Savepoint* savepoints_push(SavepointBuffer *self) {
|
||||
Savepoint *ans = self->buf + ((self->start_of_data + self->count) % SAVEPOINTS_SZ);
|
||||
if (self->count == SAVEPOINTS_SZ) self->start_of_data = (self->start_of_data + 1) % SAVEPOINTS_SZ;
|
||||
else self->count++;
|
||||
return ans;
|
||||
}
|
||||
|
||||
static inline Savepoint* savepoints_pop(SavepointBuffer *self) {
|
||||
if (self->count == 0) return NULL;
|
||||
self->count--;
|
||||
return self->buf + ((self->start_of_data + self->count) % SAVEPOINTS_SZ);
|
||||
}
|
||||
|
||||
void screen_save_cursor(Screen *self) {
|
||||
SavepointBuffer *pts = self->linebuf == self->main_linebuf ? &self->main_savepoints : &self->alt_savepoints;
|
||||
Savepoint *sp = savepoints_push(pts);
|
||||
|
|
|
|||
Loading…
Reference in a new issue