From: Aurélien Aptel Date: Wed, 13 May 2009 23:03:17 +0000 (+0200) Subject: handle tabulation (still not perfect) X-Git-Url: https://git.danieliu.xyz/?a=commitdiff_plain;h=1cf8b77d2798a43c979b71e16fd45d63b808f569;p=st.git handle tabulation (still not perfect) --- diff --git a/st.c b/st.c index ef0fd17..79fb161 100644 --- a/st.c +++ b/st.c @@ -558,6 +558,17 @@ escreset(void) { memset(&escseq, 0, sizeof(escseq)); } +void +tputtab(void) { + int space = TAB - term.c.x % TAB; + + if(term.c.x + space >= term.col) + space--; + + for(; space > 0; space--) + tputc(' '); +} + void tputc(char c) { static int inesc = 0; @@ -574,6 +585,9 @@ tputc(char c) { tsetchar(c); tcursor(CSright); break; + case '\t': + tputtab(); + break; case '\b': tcursor(CSleft); break; diff --git a/st.h b/st.h index 87db5c2..4652a33 100644 --- a/st.h +++ b/st.h @@ -66,6 +66,8 @@ enum { CRset=1 , CRupdate=2 }; /* Character state */ enum { TMwrap=1 , TMinsert=2 }; /* Terminal mode */ enum { SCupdate, SCredraw }; /* screen draw mode */ +typedef int Color; + typedef struct { char c; /* character code */ char mode; /* attribute flags */