/* The following routines are partially supported. */ void SLsmg_write_color_chars (SLsmg_Char_Type *s, unsigned int len) { #if 1 SLsmg_write_raw (s, len); #else SLsmg_Char_Type *smax, sh; char buf[32], *b, *bmax; int color, save_color; if (Smg_Inited == 0) return; smax = s + len; b = buf; bmax = b + sizeof (buf); save_color = This_Color; while (s < smax) { sh = *s++; color = SLSMG_EXTRACT_COLOR(sh); #ifdef REQUIRES_NON_BCE_SUPPORT if (Bce_Color_Offset) { if (color & 0x80) color = ((color & 0x7F) + Bce_Color_Offset) | 0x80; else color = ((color & 0x7F) + Bce_Color_Offset) & 0x7F; } #endif if ((color != This_Color) || (b == bmax)) { if (b != buf) { SLsmg_write_nchars (buf, (int) (b - buf)); b = buf; } This_Color = color; } *b++ = (char) SLSMG_EXTRACT_CHAR(sh); } if (b != buf) SLsmg_write_nchars (buf, (unsigned int) (b - buf)); This_Color = save_color; #endif }
static void rline_update(unsigned char *buf, int len, int col) { SLsmg_gotorc (SLtt_Screen_Rows - 1, 0); SLsmg_set_color(2); if( buf ) { SLsmg_write_nchars ((char *) buf, len); } SLsmg_erase_eol (); SLsmg_gotorc (SLtt_Screen_Rows - 1, col); SLsmg_refresh (); }
void vtDrawText(VTScreenView *view, int col, int row, char *mbstring, int length, int width) { SLsmg_gotorc(row, col); SLsmg_write_nchars(mbstring, length); SLsmg_gotorc(row, col + length - 1); //SLsmg_refresh(); /* mbstring[length] = 0; printf("text. col: %d row: %d length: %d width: %d string: %s\n", col, row, length, width, mbstring); */ }
/* * Place some text on the screen using an attribute */ static errr Term_text_sla(int x, int y, int n, byte a, cptr s) { /* Move the cursor */ SLsmg_gotorc(y, x); /* Set the color */ if (can_use_color) SLsmg_set_color(colortable[a&0x0F]); /* Dump the string */ SLsmg_write_nchars((char *)s, n); /* Success */ return 0; }
extern void tty_print_char(int c) { #ifdef HAVE_SLANG /* We cannot use SLsmg_write_char here because the Debian and Redhat * people thought changing the API of an external project was fun, * especially when it depends on the preprocessor symbol UTF8 being * defined or not. Congratulations! At least, they left the API call * for SLsmg_write_nchars as it has always been. */ char ch; ch = c; SLsmg_write_nchars(&ch, 1); #else addch(c); #endif }
static int update_status_line (int col_flag) { unsigned char star0, star1; char buf[32], *b; int num; if (IN_MINI_WINDOW) return 0; SLsmg_gotorc (JWindow->rows + JWindow->sy, 0); SLsmg_set_color (JSTATUS_COLOR); b = buf; if (JWindow->hscroll_column != 1) *b++ = '<'; else *b++ = '-'; if (CBuf->flags & BUFFER_MODIFIED) star0 = star1 = '*'; else star0 = star1 = '-'; if ((CBuf->flags & READ_ONLY) #if JED_HAS_LINE_ATTRIBUTES || (CLine->flags & JED_LINE_IS_READONLY) #endif ) star0 = star1 = '%'; #if JED_HAS_SUBPROCESSES if (CBuf->subprocess) star1 = 'S'; #endif *b++ = star0; *b++ = star1; if (CBuf->marks != NULL) *b++ = 'm'; else *b++ = '-'; if (CBuf->flags & FILE_MODIFIED) *b++ = 'd'; else *b++ = '-'; if (CBuf->spots != NULL) *b++ = 's'; else *b++ = '-'; if (CBuf->flags & BINARY_FILE) *b++ = 'B'; #ifdef IBMPC_SYSTEM else if ((CBuf->flags & ADD_CR_ON_WRITE_FLAG) == 0) *b++ = 'L'; #else # ifdef __unix__ else if (CBuf->flags & ADD_CR_ON_WRITE_FLAG) *b++ = 'C'; # endif #endif else *b++ = '-'; if (CBuf->flags & UNDO_ENABLED) *b++ = '+'; else *b++ = '-'; SLsmg_write_nchars (buf, (unsigned int) (b - buf)); finish_status (col_flag); if (Defining_Keyboard_Macro) SLsmg_write_string (" [Macro]"); num = Jed_Num_Screen_Cols - SLsmg_get_column (); star1 = '-'; while (num > 0) { SLsmg_write_nchars ((char *) &star1, 1); num--; } SLsmg_set_color (0); Point_Cursor_Flag = 1; return 1; }
static void finish_status(int col_flag) { char *v, ch; Line *l; int top, rows, narrows; char buf[256]; char *str; v = CBuf->status_line; if (*v == 0) v = Default_Status_Line; while (1) { char *v0 = v; while (1) { ch = *v; if (ch == 0) { SLsmg_write_nchars (v0, (unsigned int) (v-v0)); return; } if (ch == '%') { SLsmg_write_nchars (v0, (unsigned int) (v-v0)); break; } v++; } /* At this point *v == '%' */ v++; ch = *v++; switch (ch) { case 'F': SLsmg_write_string (CBuf->dir); str = CBuf->file; break; case 'S': /* stack depth */ sprintf(buf, "%03d", SLstack_depth()); str = buf; break; case 'a': if (CBuf->flags & ABBREV_MODE) str = " abbrev"; else str = NULL; break; case 'f': str = CBuf->file; break; case 'n': narrows = jed_count_narrows (); if (narrows) { sprintf (buf, " Narrow[%d]", narrows); str = buf; } else str = NULL; break; case 'o': if (CBuf->flags & OVERWRITE_MODE) str = " Ovwrt"; else str = NULL; break; case 'O': if (CBuf->flags & OVERWRITE_MODE) str = " ovr"; else str = " ins"; break; case 'b': str = CBuf->name; break; case 'p': str = buf; if (0 == User_Prefers_Line_Numbers) { top = JWindow->sy; rows = JWindow->rows - 1; l = JScreen[top + rows].line; if (l == CBuf->end) l = NULL; if (JScreen[top].line == CBuf->beg) { if (l == NULL) str = "All"; else str = "Top"; } else if (l == NULL) str = "Bot"; else { sprintf(buf, "%d%%", (int) ((LineNum * 100L) / (long) Max_LineNum)); } } else { if (User_Prefers_Line_Numbers == 1) sprintf(buf, "%u/%u", LineNum, Max_LineNum); else { if (col_flag) (void) calculate_column (); sprintf(buf, "%u/%u,%d", LineNum, Max_LineNum, Absolute_Column); } } break; case 'l': sprintf(buf, "%u", LineNum); str=buf; break; case 'L': sprintf(buf, "%u", Max_LineNum); str=buf; break; case 'v': SLsmg_write_string (Jed_Version_String); if (Jed_UTF8_Mode) str = "U"; else str = NULL; break; case 'm': str = CBuf->mode_string; break; case 't': str = status_get_time(); break; case 'c': if (col_flag) (void) calculate_column (); sprintf(buf, "%d", Absolute_Column); str = buf; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { char fmt[16]; int num = ch - '0'; while (isdigit(*v)) { num = num * 10 + (*v - '0'); v++; } if ((num < 0) || (-1 == SLsnprintf (fmt, sizeof(fmt), "%s%du", ((ch == '0') ? "%0" : "%"), num))) strcpy (fmt, "%u"); str = "*"; switch (*v++) { default: v--; break; case 'c': if (col_flag) (void) calculate_column (); if (-1 != SLsnprintf (buf, sizeof (buf), fmt, (unsigned int)Absolute_Column)) str = buf; break; case 'l': if (-1 != SLsnprintf (buf, sizeof (buf), fmt, LineNum)) str = buf; break; case 'L': if (-1 != SLsnprintf (buf, sizeof (buf), fmt, Max_LineNum)) str = buf; break; } } break; case '%': str = "%"; break; case 0: return; default: str = NULL; } if (str != NULL) SLsmg_write_string (str); } }
static void display_line (Line *line, int sy, int sx) { unsigned int len; int hscroll_col; int is_mini; Screen_Type *s; #if JED_HAS_LINE_MARKS Mark *line_marks; #endif int num_columns; int color_set; SLsmg_Tab_Width = Buffer_Local.tab; (void) SLsmg_embedded_escape_mode (CBuf->flags & SMG_EMBEDDED_ESCAPE); is_mini = (sy + 1 == Jed_Num_Screen_Rows); SLsmg_gotorc (sy, sx); SLsmg_set_color (0); s = JScreen + sy; s->line = line; s->is_modified = 0; if (line == NULL) { SLsmg_erase_eol (); return; } hscroll_col = JWindow->hscroll_column - 1; if ((line == HScroll_Line) && Wants_HScroll && HScroll) hscroll_col += HScroll; num_columns = JWindow->width; if (hscroll_col || sx #if JED_HAS_DISPLAY_LINE_NUMBERS || (CBuf->line_num_display_size) #endif ) { int tmp = hscroll_col - sx; #if JED_HAS_DISPLAY_LINE_NUMBERS tmp -= CBuf->line_num_display_size; num_columns -= CBuf->line_num_display_size; #endif SLsmg_set_screen_start (NULL, &tmp); sx = 0; } len = line->len; if (is_mini) { SLsmg_Newline_Behavior = SLSMG_NEWLINE_PRINTABLE; SLsmg_write_string ((char *)Mini_Info.prompt); } else { SLsmg_Newline_Behavior = 0; if (len && (line->data[len - 1] == '\n')) len--; } color_set = 0; #if JED_HAS_LINE_ATTRIBUTES if (line->flags & JED_LINE_COLOR_BITS) { SLsmg_set_color (JED_GET_LINE_COLOR(line)); color_set = 1; } #endif #if JED_HAS_LINE_MARKS line_marks = CBuf->user_marks; if (color_set == 0) while (line_marks != NULL) { if ((line_marks->line == line) && (line_marks->flags & JED_LINE_MARK)) { SLsmg_set_color (line_marks->flags & MARK_COLOR_MASK); color_set = 1; break; } line_marks = line_marks->next; } #endif if (len) { if ((color_set == 0) && Mode_Has_Syntax_Highlight && (line != &Eob_Line) #if !defined(IBMPC_SYSTEM) && (*tt_Use_Ansi_Colors && Term_Supports_Color) #endif && Wants_Syntax_Highlight) write_syntax_highlight (sy, line, len); else { if ((is_mini == 0) && Jed_Highlight_WS & HIGHLIGHT_WS_TRAILING) { unsigned char *pmin = line->data; unsigned char *pmax = pmin + len; unsigned char *p = pmax; while (p > pmin) { p--; if ((*p != ' ') && (*p != '\t')) { p++; break; } } SLsmg_write_nchars ((char *)pmin, p - pmin); if (p != pmax) { SLsmg_set_color (JTWS_COLOR); SLsmg_write_nchars ((char *)p, pmax - p); SLsmg_set_color (0); } } else SLsmg_write_nchars ((char *)line->data, len); } } #if JED_HAS_LINE_ATTRIBUTES if ((line->next != NULL) && (line->next->flags & JED_LINE_HIDDEN)) { SLsmg_set_color (JDOTS_COLOR); SLsmg_write_string ("..."); SLsmg_set_color (0); } #endif SLsmg_erase_eol (); if (Jed_Dollar) { char dollar = (char) Jed_Dollar; if (hscroll_col + num_columns <= SLsmg_get_column ()) { SLsmg_gotorc (sy, hscroll_col + num_columns - 1); SLsmg_set_color (JDOLLAR_COLOR); SLsmg_write_nchars (&dollar, 1); } if (hscroll_col) { SLsmg_gotorc (sy, hscroll_col); SLsmg_set_color (JDOLLAR_COLOR); SLsmg_write_nchars (&dollar, 1); } } if ((s->hi0 != NULL) && Wants_Attributes) { int c; len = (int) (s->hi1 - s->hi0); if (len && (s->hi0[len - 1] == '\n')) len--; if (len) { c = jed_compute_effective_length (line->data, s->hi0); if (is_mini) c += Mini_Info.effective_prompt_len; SLsmg_gotorc (sy, c); SLsmg_set_color (JREGION_COLOR); SLsmg_write_nchars ((char *)s->hi0, len); } } /* if (hscroll_col + sx) */ SLsmg_set_screen_start (NULL, NULL); SLsmg_set_color (0); }
void display_write_chars(char *str, int len) { SLsmg_write_nchars(str, len); }
void display_write_str(char *str) { SLsmg_write_nchars(str, strlen(str)); }