X-Git-Url: https://git.xinqibao.xyz/st.git/blobdiff_plain/c6853fe18564437fe0a4cb06565a0a7d63d40b5a..12de47a93393e098d5d48333290a5710a543c3d6:/st.c?ds=inline diff --git a/st.c b/st.c index 4fc4d3d..b7dfd55 100644 --- a/st.c +++ b/st.c @@ -164,7 +164,7 @@ typedef struct { int col; /* nb col */ Line* line; /* screen */ Line* alt; /* alternate screen */ - bool* dirty; /* dirtyness of lines */ + bool* dirty; /* dirtyness of lines */ TCursor c; /* cursor */ int top; /* top scroll limit */ int bot; /* bottom scroll limit */ @@ -172,6 +172,7 @@ typedef struct { int esc; /* escape state flags */ char title[ESC_TITLE_SIZ]; int titlelen; + bool *tabs; } Term; /* Purely graphic info */ @@ -847,12 +848,16 @@ tcursor(int mode) { void treset(void) { + unsigned i; term.c = (TCursor){{ .mode = ATTR_NULL, .fg = DefaultFG, .bg = DefaultBG }, .x = 0, .y = 0, .state = CURSOR_DEFAULT}; - + + memset(term.tabs, 0, term.col * sizeof(*term.tabs)); + for (i = TAB; i < term.col; i += TAB) + term.tabs[i] = 1; term.top = 0, term.bot = term.row - 1; term.mode = MODE_WRAP; tclearregion(0, 0, term.col-1, term.row-1); @@ -865,12 +870,14 @@ tnew(int col, int row) { term.line = malloc(term.row * sizeof(Line)); term.alt = malloc(term.row * sizeof(Line)); term.dirty = malloc(term.row * sizeof(*term.dirty)); + term.tabs = malloc(term.col * sizeof(*term.tabs)); for(row = 0; row < term.row; row++) { term.line[row] = malloc(term.col * sizeof(Glyph)); term.alt [row] = malloc(term.col * sizeof(Glyph)); term.dirty[row] = 0; } + memset(term.tabs, 0, term.col * sizeof(*term.tabs)); /* setup screen */ treset(); } @@ -1196,6 +1203,18 @@ csihandle(void) { DEFAULT(escseq.arg[0], 1); tmoveto(0, term.c.y-escseq.arg[0]); break; + case 'g': /* TBC -- Tabulation clear */ + switch (escseq.arg[0]) { + case 0: /* clear current tab stop */ + term.tabs[term.c.x] = 0; + break; + case 3: /* clear all the tabs */ + memset(term.tabs, 0, term.col * sizeof(*term.tabs)); + break; + default: + goto unknown; + } + break; case 'G': /* CHA -- Move to