diff options
author | Thomas White <taw@bitwiz.org.uk> | 2016-03-28 17:44:52 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2016-03-28 17:44:52 +0200 |
commit | 57dac45b3405edee4300c11411fbf712916437bb (patch) | |
tree | d41b029753acc673bcfa681899bf8180991f7348 /src | |
parent | fa311f41ff4bde6725a4a53a90fb3c1fa481cbf1 (diff) |
Restore text colours
Diffstat (limited to 'src')
-rw-r--r-- | src/frame.c | 22 | ||||
-rw-r--r-- | src/frame.h | 3 | ||||
-rw-r--r-- | src/sc_interp.c | 4 |
3 files changed, 22 insertions, 7 deletions
diff --git a/src/frame.c b/src/frame.c index 3f3e708..d220436 100644 --- a/src/frame.c +++ b/src/frame.c @@ -39,6 +39,7 @@ struct text_run size_t offs_bytes; size_t len_bytes; PangoFontDescription *fontdesc; + double col[4]; }; @@ -273,6 +274,7 @@ void wrap_paragraph(Paragraph *para, PangoContext *pc, double w) PangoAttribute *attr; const char *run_text; + guint16 r, g, b; run_text = sc_block_contents(para->runs[i].scblock) + para->runs[i].offs_bytes; @@ -280,11 +282,19 @@ void wrap_paragraph(Paragraph *para, PangoContext *pc, double w) attr = pango_attr_font_desc_new(para->runs[i].fontdesc); attr->start_index = pos; attr->end_index = pos + para->runs[i].len_bytes; - pos += para->runs[i].len_bytes; + pango_attr_list_insert(attrs, attr); - strncat(text, run_text, para->runs[i].len_bytes); + r = para->runs[i].col[0] * 65535; + g = para->runs[i].col[1] * 65535; + b = para->runs[i].col[2] * 65535; + attr = pango_attr_foreground_new(r, g, b); + attr->start_index = pos; + attr->end_index = pos + para->runs[i].len_bytes; pango_attr_list_insert(attrs, attr); + pos += para->runs[i].len_bytes; + strncat(text, run_text, para->runs[i].len_bytes); + } if ( para->layout == NULL ) { @@ -302,7 +312,7 @@ void wrap_paragraph(Paragraph *para, PangoContext *pc, double w) void add_run(Paragraph *para, SCBlock *scblock, size_t offs_bytes, - size_t len_bytes, PangoFontDescription *fdesc, int eop) + size_t len_bytes, PangoFontDescription *fdesc, double col[4]) { struct text_run *runs_new; @@ -323,9 +333,11 @@ void add_run(Paragraph *para, SCBlock *scblock, size_t offs_bytes, para->runs[para->n_runs].offs_bytes = offs_bytes; para->runs[para->n_runs].len_bytes = len_bytes; para->runs[para->n_runs].fontdesc = pango_font_description_copy(fdesc); + para->runs[para->n_runs].col[0] = col[0]; + para->runs[para->n_runs].col[1] = col[1]; + para->runs[para->n_runs].col[2] = col[2]; + para->runs[para->n_runs].col[3] = col[3]; para->n_runs++; - - if ( eop ) para->open = 0; } diff --git a/src/frame.h b/src/frame.h index 99e5df4..2652a27 100644 --- a/src/frame.h +++ b/src/frame.h @@ -110,7 +110,8 @@ extern PangoLayout *paragraph_layout(Paragraph *para); extern double paragraph_height(Paragraph *para); extern void add_run(Paragraph *para, SCBlock *scblock, size_t offs_bytes, - size_t len_bytes, PangoFontDescription *fdesc, int eop); + size_t len_bytes, PangoFontDescription *fdesc, + double col[4]); extern void add_callback_para(struct frame *fr, double w, double h, SCCallbackDrawFunc draw_func, diff --git a/src/sc_interp.c b/src/sc_interp.c index 282cea4..943afd3 100644 --- a/src/sc_interp.c +++ b/src/sc_interp.c @@ -819,6 +819,7 @@ static int add_text(struct frame *fr, PangoContext *pc, SCBlock *bl, const char *text = sc_block_contents(bl); size_t start, len_bytes; PangoFontDescription *fontdesc; + double *col; /* Empty block? */ if ( text == NULL ) return 1; @@ -828,6 +829,7 @@ static int add_text(struct frame *fr, PangoContext *pc, SCBlock *bl, if ( len_chars == 0 ) return 1; fontdesc = sc_interp_get_fontdesc(scin); + col = sc_interp_get_fgcol(scin); len_bytes = strlen(text); start = 0; @@ -848,7 +850,7 @@ static int add_text(struct frame *fr, PangoContext *pc, SCBlock *bl, start += 1; } else { Paragraph *para = last_open_para(fr); - add_run(para, bl, start, len, fontdesc, 0); + add_run(para, bl, start, len, fontdesc, col); start += len; } |