diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/globals.h | 5 | ||||
| -rw-r--r-- | src/util.c | 23 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/globals.h b/src/globals.h index 58fc0cd..6077057 100644 --- a/src/globals.h +++ b/src/globals.h @@ -43,6 +43,9 @@ #define SAVE_MAGIC "PORTv3" #define MAGIC_LEN 6 +#define BOLD_THRESHOLD 50 +#define ABS(x) (((x)<0)?-(x):(x)) + typedef unsigned long long ullong; typedef unsigned long ulong; typedef unsigned int uint; @@ -143,6 +146,8 @@ void print_history(struct stock_t*); void print_usage(int argc, char *argv[]); void print_version(void); void sig_handler(int); +void use_bold(void); +void stop_bold(void); void use_color(int); void stop_color(int); @@ -225,10 +225,16 @@ void print_handler(struct player_t *player) else if(last_buy->price.cents > stock->current_price.cents) col = COL_RED; + if(ABS((signed)last_buy->price.cents - (signed)stock->current_price.cents) >= BOLD_THRESHOLD) + use_bold(); + use_color(col); output("%5llu.%02llu", stock->current_price.cents / 100, stock->current_price.cents % 100); stop_color(col); + if(ABS((signed)last_buy->price.cents - (signed)stock->current_price.cents) >= BOLD_THRESHOLD) + stop_bold(); + output(" = $%6llu.%02llu\n", total_value / 100, total_value % 100); portfolio_value += stock->current_price.cents * stock->count; @@ -603,3 +609,20 @@ void batch_init(void) { batch_mode = true; } + +void use_bold(void) +{ + /* curses mode always has A_BOLD set, so this only applies to HTML mode */ + if(html_out) + { + output("<b>"); + } +} + +void stop_bold(void) +{ + if(html_out) + { + output("</b>"); + } +} |