Changeset 237d02c
- Timestamp:
- Feb 26, 2011, 12:58:30 AM (14 years ago)
- Branches:
- master, release-1.10, release-1.8, release-1.9
- Children:
- cb6c9e1
- Parents:
- 7659079
- git-author:
- David Benjamin <davidben@mit.edu> (02/25/11 15:25:58)
- git-committer:
- David Benjamin <davidben@mit.edu> (02/26/11 00:58:30)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
fmtext.c
r7659079 r237d02c 7 7 { 8 8 f->buff = g_string_new(""); 9 f->default_attrs = OWL_FMTEXT_ATTR_NONE;10 f->default_fgcolor = OWL_COLOR_DEFAULT;11 f->default_bgcolor = OWL_COLOR_DEFAULT;12 9 } 13 10 … … 17 14 { 18 15 g_string_truncate(f->buff, 0); 19 f->default_attrs = OWL_FMTEXT_ATTR_NONE;20 f->default_fgcolor = OWL_COLOR_DEFAULT;21 f->default_bgcolor = OWL_COLOR_DEFAULT;22 16 } 23 17 … … 100 94 } 101 95 102 /* Add the attribute 'attr' to the default atts for the text in 'f' */103 void owl_fmtext_addattr(owl_fmtext *f, char attr)104 {105 /* add the attribute to all text */106 f->default_attrs |= attr;107 }108 109 /* Set the default foreground color for this fmtext to 'color'.110 * Only affects text that is colored default.111 */112 void owl_fmtext_colorize(owl_fmtext *f, int color)113 {114 f->default_fgcolor = color;115 }116 117 /* Set the default foreground color for this fmtext to 'color'.118 * Only affects text that is colored default.119 */120 void owl_fmtext_colorizebg(owl_fmtext *f, int color)121 {122 f->default_bgcolor = color;123 }124 125 96 /* Internal function. Parse attrbute character. */ 126 97 static void _owl_fmtext_update_attributes(gunichar c, char *attr, short *fgcolor, short *bgcolor) … … 235 206 * must already be initiatlized with curses 236 207 */ 237 static void _owl_fmtext_curs_waddstr(const owl_fmtext *f, WINDOW *w, int do_search )208 static void _owl_fmtext_curs_waddstr(const owl_fmtext *f, WINDOW *w, int do_search, char default_attrs, short default_fgcolor, short default_bgcolor) 238 209 { 239 210 /* char *tmpbuff; */ … … 250 221 s = f->buff->str; 251 222 /* Set default attributes. */ 252 attr = f->default_attrs;253 fg = f->default_fgcolor;254 bg = f->default_bgcolor;223 attr = default_attrs; 224 fg = default_fgcolor; 225 bg = default_bgcolor; 255 226 _owl_fmtext_wattrset(w, attr); 256 227 _owl_fmtext_update_colorpair(fg, bg, &pair); … … 295 266 /* Deal with new attributes. Initialize to defaults, then 296 267 process all consecutive formatting characters. */ 297 attr = f->default_attrs;298 fg = f->default_fgcolor;299 bg = f->default_bgcolor;268 attr = default_attrs; 269 fg = default_fgcolor; 270 bg = default_bgcolor; 300 271 while (owl_fmtext_is_format_char(g_utf8_get_char(p))) { 301 272 _owl_fmtext_update_attributes(g_utf8_get_char(p), &attr, &fg, &bg); 302 273 p = g_utf8_next_char(p); 303 274 } 304 _owl_fmtext_wattrset(w, attr | f->default_attrs);305 if (fg == OWL_COLOR_DEFAULT) fg = f->default_fgcolor;306 if (bg == OWL_COLOR_DEFAULT) bg = f->default_bgcolor;275 _owl_fmtext_wattrset(w, attr | default_attrs); 276 if (fg == OWL_COLOR_DEFAULT) fg = default_fgcolor; 277 if (bg == OWL_COLOR_DEFAULT) bg = default_bgcolor; 307 278 _owl_fmtext_update_colorpair(fg, bg, &pair); 308 279 _owl_fmtext_wcolor_set(w, pair); … … 322 293 } 323 294 324 void owl_fmtext_curs_waddstr(const owl_fmtext *f, WINDOW *w )325 { 326 _owl_fmtext_curs_waddstr(f, w, 1 );327 } 328 329 void owl_fmtext_curs_waddstr_without_search(const owl_fmtext *f, WINDOW *w )330 { 331 _owl_fmtext_curs_waddstr(f, w, 0 );295 void owl_fmtext_curs_waddstr(const owl_fmtext *f, WINDOW *w, char default_attrs, short default_fgcolor, short default_bgcolor) 296 { 297 _owl_fmtext_curs_waddstr(f, w, 1, default_attrs, default_fgcolor, default_bgcolor); 298 } 299 300 void owl_fmtext_curs_waddstr_without_search(const owl_fmtext *f, WINDOW *w, char default_attrs, short default_fgcolor, short default_bgcolor) 301 { 302 _owl_fmtext_curs_waddstr(f, w, 0, default_attrs, default_fgcolor, default_bgcolor); 332 303 } 333 304 … … 336 307 int col = start, numcopied = 0; 337 308 char *ptr; 338 339 /* Copy the default attributes. */340 out->default_attrs = in->default_attrs;341 out->default_fgcolor = in->default_fgcolor;342 out->default_bgcolor = in->default_bgcolor;343 309 344 310 for (ptr = in->buff->str; … … 387 353 /* ptr1 now holds the starting point */ 388 354 389 /* copy the default attributes */390 out->default_attrs = in->default_attrs;391 out->default_fgcolor = in->default_fgcolor;392 out->default_bgcolor = in->default_bgcolor;393 394 355 /* copy in the next 'lines' lines */ 395 356 if (lines < 1) return(-1); … … 415 376 const char *ptr_s, *ptr_e, *ptr_c, *last; 416 377 int col, st, padding, chwidth; 417 418 /* copy the default attributes */419 out->default_attrs = in->default_attrs;420 out->default_fgcolor = in->default_fgcolor;421 out->default_bgcolor = in->default_bgcolor;422 378 423 379 last = in->buff->str + in->buff->len - 1; … … 588 544 { 589 545 dst->buff = g_string_new(src->buff->str); 590 dst->default_attrs = src->default_attrs;591 dst->default_fgcolor = src->default_fgcolor;592 dst->default_bgcolor = src->default_bgcolor;593 546 } 594 547 -
message.c
r3472845 r237d02c 525 525 owl_fmtext_truncate_lines(&(m->fmtext->fmtext), aline, bline-aline, &a); 526 526 owl_fmtext_truncate_cols(&a, acol, bcol, &b); 527 owl_fmtext_colorize(&b, fgcolor); 528 owl_fmtext_colorizebg(&b, bgcolor); 529 530 owl_fmtext_curs_waddstr(&b, win); 527 528 owl_fmtext_curs_waddstr(&b, win, OWL_FMTEXT_ATTR_NONE, fgcolor, bgcolor); 531 529 532 530 owl_fmtext_cleanup(&a); -
owl.h
r7659079 r237d02c 276 276 typedef struct _owl_fmtext { 277 277 GString *buff; 278 char default_attrs;279 short default_fgcolor;280 short default_bgcolor;281 278 } owl_fmtext; 282 279 -
viewwin.c
rddbbcffa r237d02c 106 106 owl_fmtext_truncate_cols(&fm1, v->rightshift, wincols-1+v->rightshift, &fm2); 107 107 108 owl_fmtext_curs_waddstr(&fm2, curswin );108 owl_fmtext_curs_waddstr(&fm2, curswin, OWL_FMTEXT_ATTR_NONE, OWL_COLOR_DEFAULT, OWL_COLOR_DEFAULT); 109 109 110 110 owl_fmtext_cleanup(&fm1);
Note: See TracChangeset
for help on using the changeset viewer.