Mark prompt lines

This commit is contained in:
Kovid Goyal 2021-07-12 14:54:44 +05:30
parent 46b9aca16e
commit 0d4237f802
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 36 additions and 3 deletions

View File

@ -83,8 +83,12 @@ typedef enum { TILING, SCALED, MIRRORED } BackgroundImageLayout;
#define COL_MASK 0xFFFFFFFF
#define DECORATION_FG_CODE 58
#define CHAR_IS_BLANK(ch) ((ch) == 32 || (ch) == 0)
#define CONTINUED_MASK 1
#define TEXT_DIRTY_MASK 2
enum {
CONTINUED_MASK=1,
TEXT_DIRTY_MASK=2,
PROMPT_START_MASK=4,
OUTPUT_START_MASK=8
};
#define FG 1
#define BG 2

View File

@ -56,6 +56,19 @@ linebuf_mark_line_as_not_continued(LineBuf *self, index_type y) {
self->line_attrs[y] &= ~CONTINUED_MASK;
}
void
linebuf_mark_line_as_prompt_start(LineBuf *self, index_type y) {
self->line_attrs[y] |= PROMPT_START_MASK;
self->line_attrs[y] &= ~OUTPUT_START_MASK;
}
void
linebuf_mark_line_as_output_start(LineBuf *self, index_type y) {
self->line_attrs[y] &= ~PROMPT_START_MASK;
self->line_attrs[y] |= OUTPUT_START_MASK;
}
static PyObject*
clear(LineBuf *self, PyObject *a UNUSED) {

View File

@ -99,6 +99,8 @@ void linebuf_rewrap(LineBuf *self, LineBuf *other, index_type *, index_type *, H
void linebuf_mark_line_dirty(LineBuf *self, index_type y);
void linebuf_mark_line_clean(LineBuf *self, index_type y);
void linebuf_mark_line_as_not_continued(LineBuf *self, index_type y);
void linebuf_mark_line_as_prompt_start(LineBuf *self, index_type y);
void linebuf_mark_line_as_output_start(LineBuf *self, index_type y);
unsigned int linebuf_char_width_at(LineBuf *self, index_type x, index_type y);
void linebuf_refresh_sprite_positions(LineBuf *self);
void historybuf_add_line(HistoryBuf *self, const Line *line, ANSIBuf*);

View File

@ -1712,7 +1712,21 @@ clipboard_control(Screen *self, int code, PyObject *data) {
void
shell_prompt_marking(Screen *self, PyObject *data) {
printf("prompt_marking: x=%d y=%d ", self->cursor->x, self->cursor->y); PyObject_Print(data, stdout, 0); printf("\n");
if (PyUnicode_READY(data) != 0) { PyErr_Clear(); return; }
if (PyUnicode_GET_LENGTH(data) > 0 && self->cursor->y < self->lines) {
Py_UCS4 ch = PyUnicode_READ_CHAR(data, 0);
switch (ch) {
case 'A':
linebuf_mark_line_as_prompt_start(self->linebuf, self->cursor->y); break;
case 'C':
linebuf_mark_line_as_output_start(self->linebuf, self->cursor->y); break;
}
}
if (global_state.debug_rendering) {
fprintf(stderr, "prompt_marking: x=%d y=%d op=", self->cursor->x, self->cursor->y);
PyObject_Print(data, stderr, 0);
fprintf(stderr, "\n");
}
}
void