| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9eedc3c commit aeb5f61
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | #ifndef lint | |
| 2 | - static char *RCSid() { return RCSid("$Id: term.c,v 1.305 2015/01/24 23:54:32 sfeam Exp $"); } | ||
| 2 | + static char *RCSid() { return RCSid("$Id: term.c,v 1.306 2015/02/18 19:14:28 sfeam Exp $"); } | ||
| 3 | 3 | #endif | |
| 4 | 4 | ||
| 5 | 5 | /* GNUPLOT - term.c */ | |
@@ -2585,6 +2585,17 @@ int len; | |||
| 2585 | 2585 | return len; | |
| 2586 | 2586 | } | |
| 2587 | 2587 | ||
| 2588 | + /* | ||
| 2589 | + * Use estimate.trm to mock up a non-enhanced approximation of the | ||
| 2590 | + * original string. | ||
| 2591 | + */ | ||
| 2592 | + char * | ||
| 2593 | + estimate_plaintext(char *enhancedtext) | ||
| 2594 | + { | ||
| 2595 | + estimate_strlen(enhancedtext); | ||
| 2596 | + return ENHest_plaintext; | ||
| 2597 | + } | ||
| 2598 | + | ||
| 2588 | 2599 | void | |
| 2589 | 2600 | ignore_enhanced(TBOOLEAN flag) | |
| 2590 | 2601 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | /* | |
| 2 | - * $Id: term_api.h,v 1.136 2014/09/05 21:51:38 sfeam Exp $ | ||
| 2 | + * $Id: term_api.h,v 1.137 2014/12/28 13:09:36 markisch Exp $ | ||
| 3 | 3 | */ | |
| 4 | 4 | ||
| 5 | 5 | /* GNUPLOT - term_api.h */ | |
@@ -467,6 +467,7 @@ struct termentry *change_term __PROTO((const char *name, int length)); | |||
| 467 | 467 | ||
| 468 | 468 | void write_multiline __PROTO((unsigned int, unsigned int, char *, JUSTIFY, VERT_JUSTIFY, int, const char *)); | |
| 469 | 469 | int estimate_strlen __PROTO((char *)); | |
| 470 | + char *estimate_plaintext __PROTO((char *)); | ||
| 470 | 471 | void list_terms __PROTO((void)); | |
| 471 | 472 | char* get_terminals_names __PROTO((void)); | |
| 472 | 473 | struct termentry *set_term __PROTO((void)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | /* Hello, Emacs, this is -*-C-*- | |
| 2 | - * $Id: estimate.trm,v 1.10 2010/07/28 20:43:59 sfeam Exp $ | ||
| 2 | + * $Id: estimate.trm,v 1.11 2012/05/06 00:31:36 sfeam Exp $ | ||
| 3 | 3 | * | |
| 4 | 4 | */ | |
| 5 | 5 | ||
@@ -12,6 +12,7 @@ | |||
| 12 | 12 | * On return from ENHest_put_text() | |
| 13 | 13 | * (*term)->xmax = estimated string width | |
| 14 | 14 | * (*term)->ymax = estimated string height (in tenths of a character height) | |
| 15 | + * ENHest_plaintext = non-enhanced text approximation of original string | ||
| 15 | 16 | * | |
| 16 | 17 | * AUTHORS | |
| 17 | 18 | * | |
@@ -36,6 +37,9 @@ static double ENHest_fragment_width; | |||
| 36 | 37 | static double ENHest_fontsize; | |
| 37 | 38 | static double ENHest_min_height, ENHest_max_height; | |
| 38 | 39 | static double ENHest_total_width; | |
| 40 | + static char *ENHest_plaintext = NULL; | ||
| 41 | + static int ENHest_plaintext_buflen = 0; | ||
| 42 | + static int ENHest_plaintext_pos = 0; | ||
| 39 | 43 | ||
| 40 | 44 | static TBOOLEAN ENHest_opened_string; | |
| 41 | 45 | static TBOOLEAN ENHest_show = TRUE; | |
@@ -125,13 +129,22 @@ ENHest_put_text(unsigned int x, unsigned int y, const char *str) | |||
| 125 | 129 | ENHest_total_width = 0.0; | |
| 126 | 130 | strncpy(enhanced_escape_format,".",sizeof(enhanced_escape_format)); | |
| 127 | 131 | ||
| 132 | + /* buffer in which we will return plaintext version of enhanced text string */ | ||
| 133 | + while (ENHest_plaintext_buflen < strlen(str)) { | ||
| 134 | + ENHest_plaintext_buflen += MAX_ID_LEN; | ||
| 135 | + ENHest_plaintext = gp_realloc(ENHest_plaintext, ENHest_plaintext_buflen+1, "ENHest_plaintext"); | ||
| 136 | + } | ||
| 137 | + ENHest_plaintext[0] = '\0'; | ||
| 138 | + ENHest_plaintext_pos = 0; | ||
| 139 | + | ||
| 128 | 140 | /* If no enhanced text processing is needed, strlen() is sufficient */ | |
| 129 | 141 | if (ignore_enhanced_text || !strpbrk(str, "{}^_@&~\n")) { | |
| 130 | 142 | if (encoding == S_ENC_UTF8) | |
| 131 | 143 | term->xmax = strwidth_utf8(str); | |
| 132 | 144 | else | |
| 133 | 145 | term->xmax = strlen(str); | |
| 134 | 146 | term->ymax = 10; | |
| 147 | + strcpy(ENHest_plaintext, str); | ||
| 135 | 148 | return; | |
| 136 | 149 | } | |
| 137 | 150 | ||
@@ -148,6 +161,7 @@ ENHest_put_text(unsigned int x, unsigned int y, const char *str) | |||
| 148 | 161 | break; /* end of string */ | |
| 149 | 162 | } | |
| 150 | 163 | ||
| 164 | + ENHest_plaintext[ENHest_plaintext_pos] = '\0'; | ||
| 151 | 165 | if (ENHest_x > 0.0 && ENHest_x < 1.0) | |
| 152 | 166 | ENHest_x = 1; | |
| 153 | 167 | term->xmax = ENHest_total_width; | |
@@ -176,6 +190,8 @@ ENHest_writec(int c) | |||
| 176 | 190 | } | |
| 177 | 191 | } else | |
| 178 | 192 | ENHest_fragment_width += ENHest_fontsize; | |
| 193 | + | ||
| 194 | + ENHest_plaintext[ENHest_plaintext_pos++] = c; | ||
| 179 | 195 | } | |
| 180 | 196 | ||
| 181 | 197 | /* | |
@@ -200,7 +216,7 @@ size_t strwidth_utf8(const char *s) { | |||
| 200 | 216 | ||
| 201 | 217 | ||
| 202 | 218 | static struct termentry ENHest = { | |
| 203 | - "estimate", "estimate width of enhanced text string", | ||
| 219 | + "estimate", NULL, | ||
| 204 | 220 | 1, 1, 1, 1, 1, 1, | |
| 205 | 221 | NULL, NULL, NULL, | |
| 206 | 222 | NULL, NULL, NULL, NULL, NULL, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments