diff options
Diffstat (limited to 'ed.refresh.c')
-rw-r--r-- | ed.refresh.c | 60 |
1 files changed, 45 insertions, 15 deletions
diff --git a/ed.refresh.c b/ed.refresh.c index e1e574d43bb3..a301dfe3dceb 100644 --- a/ed.refresh.c +++ b/ed.refresh.c @@ -1,4 +1,4 @@ -/* $Header: /p/tcsh/cvsroot/tcsh/ed.refresh.c,v 3.47 2011/02/27 00:14:51 christos Exp $ */ +/* $Header: /p/tcsh/cvsroot/tcsh/ed.refresh.c,v 3.51 2015/06/06 21:19:07 christos Exp $ */ /* * ed.refresh.c: Lower level screen refreshing functions */ @@ -32,7 +32,7 @@ */ #include "sh.h" -RCSID("$tcsh: ed.refresh.c,v 3.47 2011/02/27 00:14:51 christos Exp $") +RCSID("$tcsh: ed.refresh.c,v 3.51 2015/06/06 21:19:07 christos Exp $") #include "ed.h" /* #define DEBUG_UPDATE */ @@ -46,7 +46,7 @@ static int vcursor_h, vcursor_v; static int rprompt_h, rprompt_v; static int MakeLiteral (Char *, int, Char); -static int Draw (Char *, int); +static int Draw (Char *, int, int); static void Vdraw (Char, int); static void RefreshPromptpart (Char *); static void update_line (Char *, Char *, int); @@ -159,15 +159,44 @@ static int MakeLiteral(Char *str, int len, Char addlit) return i | LITERAL; } +/* draw char at cp, expand tabs, ctl chars */ static int -Draw(Char *cp, int nocomb) /* draw char at cp, expand tabs, ctl chars */ +Draw(Char *cp, int nocomb, int drawPrompt) { int w, i, lv, lh; Char c, attr; +#ifdef WIDE_STRINGS + if (!drawPrompt) { /* draw command-line */ + attr = 0; + c = *cp; + } else { /* draw prompt */ + /* prompt with attributes(UNDER,BOLD,STANDOUT) */ + if (*cp & (UNDER | BOLD | STANDOUT)) { /* *cp >= STANDOUT */ + + /* example) + * We can't distinguish whether (*cp=)0x02ffffff is + * U+02FFFFFF or U+00FFFFFF|STANDOUT. + * We handle as U+00FFFFFF|STANDOUT, only when drawing prompt. */ + attr = (*cp & ATTRIBUTES); + /* ~(UNDER | BOLD | STANDOUT) = 0xf1ffffff */ + c = *cp & ~(UNDER | BOLD | STANDOUT); + + /* if c is ctrl code, we handle *cp as havnig no attributes */ + if ((c < 0x20 && c >= 0) || c == 0x7f) { + attr = 0; + c = *cp; + } + } else { /* prompt without attributes */ + attr = 0; + c = *cp; + } + } +#else attr = *cp & ~CHAR; c = *cp & CHAR; - w = NLSClassify(c, nocomb); +#endif + w = NLSClassify(c, nocomb, drawPrompt); switch (w) { case NLSCLASS_NL: Vdraw('\0', 0); /* assure end of line */ @@ -201,10 +230,11 @@ Draw(Char *cp, int nocomb) /* draw char at cp, expand tabs, ctl chars */ case NLSCLASS_ILLEGAL2: case NLSCLASS_ILLEGAL3: case NLSCLASS_ILLEGAL4: - Vdraw('\\' | attr, 1); - Vdraw('U' | attr, 1); - Vdraw('+' | attr, 1); - for (i = 8 * NLSCLASS_ILLEGAL_SIZE(w) - 4; i >= 0; i -= 4) + case NLSCLASS_ILLEGAL5: + Vdraw('\\', 1); + Vdraw('U', 1); + Vdraw('+', 1); + for (i = 16 + 4 * (-w-5); i >= 0; i -= 4) Vdraw("0123456789ABCDEF"[(c >> i) & 15] | attr, 1); break; case 0: @@ -302,7 +332,7 @@ RefreshPromptpart(Char *buf) } } else - cp += Draw(cp, cp == buf); + cp += Draw(cp, cp == buf, 1); } } @@ -354,7 +384,7 @@ Refresh(void) cur_v = vcursor_v; Cursor = cp; } - cp += Draw(cp, cp == InputBuf); + cp += Draw(cp, cp == InputBuf, 0); } if (cur_h == -1) { /* if I haven't been set yet, I'm at the end */ @@ -1126,7 +1156,7 @@ RefCursor(void) cp++; continue; } - w = NLSClassify(*cp & CHAR, cp == Prompt); + w = NLSClassify(*cp & CHAR, cp == Prompt, 0); cp++; switch(w) { case NLSCLASS_NL: @@ -1158,7 +1188,7 @@ RefCursor(void) } for (cp = InputBuf; cp < Cursor;) { /* do input buffer to Cursor */ - w = NLSClassify(*cp & CHAR, cp == InputBuf); + w = NLSClassify(*cp & CHAR, cp == InputBuf, 0); cp++; switch(w) { case NLSCLASS_NL: @@ -1251,7 +1281,7 @@ RefPlusOne(int l) } cp = Cursor - l; c = *cp & CHAR; - w = NLSClassify(c, cp == InputBuf); + w = NLSClassify(c, cp == InputBuf, 0); switch(w) { case NLSCLASS_CTRL: PutPlusOne('^', 1); @@ -1299,7 +1329,7 @@ ClearDisp(void) CursorV = 0; /* clear the display buffer */ CursorH = 0; for (i = 0; i < TermV; i++) - (void) memset(Display[i], 0, TermH * sizeof(Display[0][0])); + (void) memset(Display[i], 0, (TermH + 1) * sizeof(Display[0][0])); OldvcV = 0; litlen = 0; } |