diff options
author | andmarti1424 <andmarti@gmail.com> | 2017-04-05 23:35:38 -0300 |
---|---|---|
committer | andmarti1424 <andmarti@gmail.com> | 2017-04-05 23:35:38 -0300 |
commit | f89bd0bd11631b676ec1894486e24759f0ffe853 (patch) | |
tree | 7283f91a6b6e0922486523bd8d069b2d0a9fb043 | |
parent | 72706a74191583a2828215d2cf3bd7dee8e16eb6 (diff) |
cleaned color.c
-rw-r--r-- | src/cmds.c | 1 | ||||
-rw-r--r-- | src/cmds_command.c | 1 | ||||
-rw-r--r-- | src/cmds_normal.c | 1 | ||||
-rw-r--r-- | src/cmds_visual.c | 1 | ||||
-rw-r--r-- | src/color.c | 80 | ||||
-rw-r--r-- | src/color.h | 4 | ||||
-rw-r--r-- | src/exec.c | 1 | ||||
-rw-r--r-- | src/file.c | 1 | ||||
-rw-r--r-- | src/filter.c | 1 | ||||
-rw-r--r-- | src/gram.y | 1 | ||||
-rw-r--r-- | src/help.c | 17 | ||||
-rw-r--r-- | src/hide_show.c | 1 | ||||
-rw-r--r-- | src/input.c | 61 | ||||
-rw-r--r-- | src/interp.c | 2 | ||||
-rw-r--r-- | src/lex.c | 1 | ||||
-rw-r--r-- | src/main.c | 20 | ||||
-rw-r--r-- | src/range.c | 1 | ||||
-rw-r--r-- | src/sc.h | 1 | ||||
-rw-r--r-- | src/sort.c | 2 | ||||
-rw-r--r-- | src/trigger.c | 1 | ||||
-rw-r--r-- | src/tui.c | 164 | ||||
-rw-r--r-- | src/tui.h | 4 | ||||
-rw-r--r-- | src/undo.c | 1 | ||||
-rw-r--r-- | src/vmtbl.c | 4 | ||||
-rw-r--r-- | src/xlsx.c | 2 |
25 files changed, 164 insertions, 210 deletions
@@ -9,7 +9,6 @@ #include "buffer.h" #include "tui.h" #include "conf.h" // for conf parameters -#include "color.h" // for set_ucolor #include "xmalloc.h" // for scxfree #include "vmtbl.h" // for growtbl #include "utils/string.h" // for add_char diff --git a/src/cmds_command.c b/src/cmds_command.c index 618d6fb..2b6d42c 100644 --- a/src/cmds_command.c +++ b/src/cmds_command.c @@ -4,7 +4,6 @@ #include <ctype.h> // for isprint() #include <wordexp.h> #include "sc.h" // for rescol -#include "color.h" // for set_ucolor #include "conf.h" #include "cmds_command.h" #include "cmds_edit.h" diff --git a/src/cmds_normal.c b/src/cmds_normal.c index 3b04aa7..decc0ba 100644 --- a/src/cmds_normal.c +++ b/src/cmds_normal.c @@ -6,7 +6,6 @@ #include "cmds.h" #include "conf.h" #include "tui.h" -#include "color.h" // for set_ucolor #include "cmds_edit.h" #include "history.h" #include "hide_show.h" diff --git a/src/cmds_visual.c b/src/cmds_visual.c index eca4139..28e2d72 100644 --- a/src/cmds_visual.c +++ b/src/cmds_visual.c @@ -7,7 +7,6 @@ #include "macros.h" #include "cmds.h" #include "conf.h" -#include "color.h" // for set_ucolor #include "hide_show.h" #include "shift.h" #include "yank.h" diff --git a/src/color.c b/src/color.c index b6415ad..6821423 100644 --- a/src/color.c +++ b/src/color.c @@ -10,7 +10,6 @@ #include "utils/dictionary.h" #include "utils/string.h" #include "range.h" -#include "color.h" #include "tui.h" #include "undo.h" #include "conf.h" @@ -26,7 +25,7 @@ struct dictionary * get_d_colors_param() { void start_default_ucolors() { // Initialize colors attributes - int i, j; + int i; for (i=0; i < N_INIT_PAIRS; i++) { ucolors[ i ].bold = 0; ucolors[ i ].dim = 0; @@ -46,80 +45,51 @@ void start_default_ucolors() { ucolors[ WELCOME ].bold = 1; ucolors[ CELL_SELECTION ].fg = BLUE; // cell selection in headings ucolors[ CELL_SELECTION ].bg = WHITE; - ucolors[ CELL_SELECTION_SC ].fg = BLACK; // cell selection in spreadsheet ucolors[ CELL_SELECTION_SC ].bg = WHITE; - ucolors[ NUMB ].fg = CYAN; ucolors[ NUMB ].bg = DEFAULT_COLOR; - ucolors[ STRG ].fg = MAGENTA; ucolors[ STRG ].bg = DEFAULT_COLOR; ucolors[ STRG ].bold = 0; - ucolors[ DATEF ].fg = YELLOW; ucolors[ DATEF ].bg = DEFAULT_COLOR; - ucolors[ EXPRESSION ].fg = YELLOW; ucolors[ EXPRESSION ].bg = DEFAULT_COLOR; - ucolors[ INFO_MSG ].fg = CYAN; ucolors[ INFO_MSG ].bg = DEFAULT_COLOR; ucolors[ INFO_MSG ].bold = 1; ucolors[ ERROR_MSG ].bg = RED; ucolors[ ERROR_MSG ].fg = WHITE; ucolors[ ERROR_MSG ].bold = 1; - ucolors[ MODE ].fg = WHITE; ucolors[ MODE ].bg = DEFAULT_COLOR; ucolors[ MODE ].bold = 1; - ucolors[ CELL_ID ].fg = RED; ucolors[ CELL_ID ].bg = DEFAULT_COLOR; ucolors[ CELL_ID ].bold = 1; - ucolors[ CELL_FORMAT ].fg = RED; + ucolors[ CELL_FORMAT ].fg = CYAN; ucolors[ CELL_FORMAT ].bg = DEFAULT_COLOR; ucolors[ CELL_CONTENT ].fg = CYAN; ucolors[ CELL_CONTENT ].bg = DEFAULT_COLOR; ucolors[ CELL_CONTENT ].bold = 1; - ucolors[ INPUT ].fg = WHITE; ucolors[ INPUT ].bg = DEFAULT_COLOR; - ucolors[ NORMAL ].fg = WHITE; ucolors[ NORMAL ].bg = DEFAULT_COLOR; - ucolors[ CELL_ERROR ].fg = RED; ucolors[ CELL_ERROR ].bg = DEFAULT_COLOR; ucolors[ CELL_ERROR ].bold = 1; - ucolors[ CELL_NEGATIVE ].fg = GREEN; ucolors[ CELL_NEGATIVE ].bg = DEFAULT_COLOR; - // Initialize all possible 81 init pairs - use_default_colors(); - for (i=0; i < 9; i++) // fg - for (j=0; j < 9; j++) // bg - init_pair( i*9+j+1, i-1, j-1); // i is fg and j is bg -} - -// Set a color -void set_ucolor(WINDOW * w, struct ucolor * uc) { - long attr = A_NORMAL; - if (uc->bold) attr |= A_BOLD; - if (uc->dim) attr |= A_DIM; - if (uc->reverse) attr |= A_REVERSE; - if (uc->standout) attr |= A_STANDOUT; - if (uc->blink) attr |= A_BLINK; - if (uc->underline) attr |= A_UNDERLINE; - wattrset (w, attr | COLOR_PAIR((uc->fg+1)*9 + uc->bg + 2)); + ui_start_colors(); // call specific ui startup routine } // Create a dictionary that stores the correspondence between macros and key // values (integers) defined in '.sc' files or through the color command. void set_colors_param_dict() { d_colors_param = create_dictionary(); - char str[3]; str[0]='\0'; @@ -141,7 +111,6 @@ void set_colors_param_dict() { put(d_colors_param, "CYAN", str); sprintf(str, "%d", WHITE); put(d_colors_param, "WHITE", str); - sprintf(str, "%d", HEADINGS); put(d_colors_param, "HEADINGS", str); sprintf(str, "%d", WELCOME); @@ -187,9 +156,11 @@ void free_colors_param_dict() { return; } -// Change color definition with users's one -// STR: color definition read from '.sc' file -// It can also be obtained at run time with the `:color str` command +/* + * Change color definition with users's one + * STR: color definition read from '.sc' file + * It can also be obtained at run time with the `:color str` command + */ void chg_color(char * str) { // Create key-value dictionary for the content of the string @@ -213,8 +184,8 @@ void chg_color(char * str) { (get(d_colors_param, get(d, "fg")) == NULL) || (get(d_colors_param, get(d, "bg")) == NULL) || (get(d_colors_param, get(d, "type")) == NULL) || - (atoi(get(d_colors_param, get(d, "fg"))) > COLOR_WHITE) || - (atoi(get(d_colors_param, get(d, "bg"))) > COLOR_WHITE) + (atoi(get(d_colors_param, get(d, "fg"))) > WHITE) || + (atoi(get(d_colors_param, get(d, "bg"))) > WHITE) ) { sc_error("One of the values specified is wrong. Please check the values of type, fg and bg."); destroy_dictionary(d); @@ -237,9 +208,11 @@ void chg_color(char * str) { return; } -// this functions is for coloring a cell, or a range of cells. -// it also applies a format such as bold or underline. -// supports undo / redo +/* + * this functions is for coloring a cell, or a range of cells. + * it also applies a format such as bold or underline. + * supports undo / redo + */ void color_cell(int r, int c, int rf, int cf, char * str) { if (any_locked_cells(r, c, rf, cf)) { sc_error("Locked cells encountered. Nothing changed"); @@ -301,7 +274,7 @@ void color_cell(int r, int c, int rf, int cf, char * str) { if (get(d, "fg") != '\0') n->ucolor->fg = atoi(get(d_colors_param, get(d, "fg"))); - if (get(d, "bold") != '\0') n->ucolor->bold = atoi(get(d, "bold")); + if (get(d, "bold") != '\0') n->ucolor->bold = atoi(get(d, "bold")); if (get(d, "dim") != '\0') n->ucolor->dim = atoi(get(d, "dim")); if (get(d, "reverse") != '\0') n->ucolor->reverse = atoi(get(d, "reverse")); if (get(d, "standout") != '\0') n->ucolor->standout = atoi(get(d, "standout")); @@ -372,8 +345,10 @@ void unformat(int r, int c, int rf, int cf) { return; } -// this function receives two ucolors variables and returns 1 if both have the same values -// returns 0 otherwise +/* + * this function receives two ucolors variables and returns 1 if both have the same values + * returns 0 otherwise + */ int same_ucolor(struct ucolor * u, struct ucolor * v) { if (u == NULL || v == NULL) return 0; @@ -390,12 +365,11 @@ int same_ucolor(struct ucolor * u, struct ucolor * v) { } int redefine_color(char * color, int r, int g, int b) { - void winchg(); - -#ifdef USECOLORS + #if defined(CURSES) && defined(USECOLORS) + extern void winchg(); if ( - ! atoi(get_conf_value("nocurses")) && - has_colors() && can_change_color() + ! atoi(get_conf_value("nocurses")) + && has_colors() && can_change_color() ) { char * s = get(d_colors_param, color); if (s == NULL) { @@ -408,9 +382,7 @@ int redefine_color(char * color, int r, int g, int b) { return 0; } } - -#endif if (! loading) sc_error("Could not redefine color"); - return -1; + #endif + return -1; } - diff --git a/src/color.h b/src/color.h index 8cfa433..804d973 100644 --- a/src/color.h +++ b/src/color.h @@ -1,5 +1,6 @@ #include "macros.h" -#include "tui.h" + +#define N_INIT_PAIRS 19 struct ucolor { int fg; @@ -16,7 +17,6 @@ struct ucolor ucolors[N_INIT_PAIRS]; struct dictionary * get_d_colors_param(); void start_default_ucolors(); -void set_ucolor(WINDOW * w, struct ucolor * uc); void color_cell(int r, int c, int rf, int cf, char * detail); void unformat(int r, int c, int rf, int cf); void set_colors_param_dict(); @@ -8,7 +8,6 @@ #include "macros.h" #include "conf.h" -#include "color.h" #include "utils/string.h" #include "tui.h" #include "sc.h" @@ -23,7 +23,6 @@ #include "utils/string.h" #include "utils/dictionary.h" #include "cmds_edit.h" -#include "color.h" #include "xmalloc.h" #include "y.tab.h" #include "xlsx.h" diff --git a/src/filter.c b/src/filter.c index 514506b..8d1da95 100644 --- a/src/filter.c +++ b/src/filter.c @@ -5,7 +5,6 @@ #include "macros.h" #include "tui.h" -#include "color.h" #include "conf.h" #include "xmalloc.h" #include "filter.h" @@ -3,7 +3,6 @@ #include "sc.h" #include "cmds.h" -#include "color.h" #include "interp.h" #include "macros.h" #include "sort.h" @@ -1,3 +1,4 @@ +#ifdef CURSES #include <ncurses.h> #include <unistd.h> #include <stdlib.h> @@ -8,7 +9,6 @@ #include "macros.h" #include "tui.h" #include "string.h" -#include "color.h" #include "utils/string.h" #include "help.h" #include "conf.h" @@ -102,7 +102,7 @@ void help() { wclrtobot(input_win); wrefresh(input_win); - set_ucolor(main_win, &ucolors[NORMAL]); + ui_set_ucolor(main_win, &ucolors[NORMAL]); wtimeout(input_win, -1); noecho(); curs_set(0); @@ -274,7 +274,7 @@ void find_word(char * word, char order) { if (look_result == -1) { sc_info("Pattern not found."); } - set_ucolor(input_win, &ucolors[NORMAL]); + ui_set_ucolor(input_win, &ucolors[NORMAL]); return; } @@ -289,14 +289,14 @@ int show_lines() { for (c = 0; c < strlen(long_help[lineno + delta]); c++) { if (long_help[lineno + delta][c] == '&') bold = ! bold; - bold ? set_ucolor(main_win, &ucolors[CELL_SELECTION_SC]) : set_ucolor(main_win, &ucolors[NORMAL]); + bold ? ui_set_ucolor(main_win, &ucolors[CELL_SELECTION_SC]) : ui_set_ucolor(main_win, &ucolors[NORMAL]); if (long_help[lineno + delta][c] == '&') { - set_ucolor(main_win, &ucolors[NORMAL]); + ui_set_ucolor(main_win, &ucolors[NORMAL]); continue; } else if (look_result != -1 && c >= look_result && c < look_result + strlen(word_looked) ) { - set_ucolor(main_win, &ucolors[CELL_SELECTION_SC]); + ui_set_ucolor(main_win, &ucolors[CELL_SELECTION_SC]); } mvwprintw(main_win, lineno, c, "%c", long_help[lineno + delta][c]); } @@ -310,3 +310,8 @@ int show_lines() { (void) wrefresh(main_win); return wgetch(input_win); } +#else +// implement this function if want to create another UI +void help() { +} +#endif diff --git a/src/hide_show.c b/src/hide_show.c index 99cd76a..35ded0c 100644 --- a/src/hide_show.c +++ b/src/hide_show.c @@ -4,7 +4,6 @@ #include "macros.h" #include "tui.h" #include "hide_show.h" -#include "color.h" // for set_ucolor #include "conf.h" #include "vmtbl.h" // for growtbl diff --git a/src/input.c b/src/input.c index d16b86d..8061614 100644 --- a/src/input.c +++ b/src/input.c @@ -28,9 +28,7 @@ int shall_quit; // Break loop if ESC key is pressed * When a timeout is reached, flush the buffer. */ void handle_input(struct block * buffer) { - - // For measuring timeout - struct timeval start_tv, m_tv; + struct timeval start_tv, m_tv; // For measuring timeout gettimeofday(&start_tv, NULL); gettimeofday(&m_tv, NULL); long msec = (m_tv.tv_sec - start_tv.tv_sec) * 1000L + @@ -40,7 +38,6 @@ void handle_input(struct block * buffer) { cmd_pending = 0; while ( ! has_cmd(buffer, msec) && msec <= CMDTIMEOUT ) { - // if command pending, refresh 'ef' only. Multiplier and cmd pending if (cmd_pending) ui_print_mult_pend(); @@ -82,51 +79,32 @@ void handle_input(struct block * buffer) { // Handle special characters input: BS TAG ENTER HOME END DEL PGUP // PGDOWN and alphanumeric characters if (is_idchar(d) || return_value != -1) { - // If in NORMAL, VISUAL or EDITION mode , change top left corner - // indicator + // If in NORMAL, VISUAL or EDITION mode , change top left corner indicator if ( (curmode == NORMAL_MODE && d >= ' ') || //FIXME (curmode == EDIT_MODE && d >= ' ') || (curmode == VISUAL_MODE && d >= ' ') ) { cmd_pending = 1; } - addto_buf(buffer, wd); // Replace maps in buffer replace_maps(buffer); - } gettimeofday(&m_tv, NULL); msec = (m_tv.tv_sec - start_tv.tv_sec) * 1000L + (m_tv.tv_usec - start_tv.tv_usec) / 1000L; } - - // timeout. Command incomplete - if (msec >= CMDTIMEOUT) { - - // No longer wait for a command, set flag. + if (msec >= CMDTIMEOUT) { // timeout. Command incomplete + cmd_pending = 0; // No longer wait for a command, set flag. + cmd_multiplier = 0; // Reset multiplier + } else { // Execute command or mapping cmd_pending = 0; - - // Reset multiplier - cmd_multiplier = 0; - - // Execute command or mapping - } else { - - cmd_pending = 0; - - // Clean second line - ui_clr_header(1); - - // Handle command and repeat as many times as the multiplier dictates - handle_mult( &cmd_multiplier, buffer, msec ); + ui_clr_header(1); // Clean second line + handle_mult( &cmd_multiplier, buffer, msec ); // Handle command and repeat as many times as the multiplier dictates } - ui_print_mult_pend(); - - // Flush the buffer - flush_buf(buffer); + flush_buf(buffer); // Flush the buffer return; } @@ -148,16 +126,9 @@ void break_waitcmd_loop(struct block * buffer) { } curmode = NORMAL_MODE; - - // No longer wait for command. Set flag. - cmd_pending = 0; - - // Reset the multiplier - cmd_multiplier = 0; - - // clean inputline - inputline[0] = L'\0'; - + cmd_pending = 0; // No longer wait for command. Set flag. + cmd_multiplier = 0; // Reset the multiplier + inputline[0] = L'\0'; // clean inputline flush_buf(buffer); update(TRUE); return; @@ -179,7 +150,6 @@ void fix_timeout(struct timeval * start_tv) { return; } - // Traverse 'stuffbuff' and determines if there is a valid command // Ej. buffer = "diw" int has_cmd (struct block * buf, long timeout) { @@ -239,7 +209,6 @@ void handle_mult(int * cmd_multiplier, struct block * buf, long timeout) { b_copy = b_copy->pnext; } } - //if (is_single_command(buf, timeout) == EDITION_CMD) // copybuffer(buf, lastcmd_buffer); // save stdin buffer content in lastcmd buffer exec_mult(buf, timeout); @@ -257,7 +226,6 @@ void exec_mult (struct block * buf, long timeout) { // Try to execute the whole buffer content if ((res = is_single_command(buf, timeout))) { if (res == EDITION_CMD) copybuffer(buf, lastcmd_buffer); // save stdin buffer content in lastcmd buffer - //cmd_multiplier--; exec_single_cmd(buf); // If not possible, traverse blockwise @@ -268,12 +236,9 @@ void exec_mult (struct block * buf, long timeout) { if ((res = is_single_command(auxb, timeout))) { if (res == EDITION_CMD) copybuffer(buf, lastcmd_buffer); // save stdin buffer content in lastcmd buffer - //cmd_multiplier--; exec_single_cmd(auxb); flush_buf(auxb); - - // Take the first K values from 'buf' - k++; + k++; // Take the first K values from 'buf' while ( k-- ) buf = dequeue(buf); // Execute again if (cmd_multiplier == 0) break; diff --git a/src/interp.c b/src/interp.c index 448757a..b7c594e 100644 --- a/src/interp.c +++ b/src/interp.c @@ -26,10 +26,10 @@ #include "sc.h" #include "macros.h" -#include "color.h" #include "cmds.h" #include "format.h" #include "conf.h" +#include "tui.h" #include "range.h" #include "xmalloc.h" // for scxfree #include "lex.h" // for atocol @@ -50,7 +50,6 @@ struct key statres[] = { #include "macros.h" #include "tui.h" #include "range.h" -#include "color.h" // for set_ucolor int yylex() { char * p = line + linelim; @@ -24,7 +24,6 @@ #include "conf.h" #include "buffer.h" #include "cmds.h" -#include "color.h" // for set_ucolor #include "vmtbl.h" // for growtbl #include "filter.h" #include "dep_graph.h" @@ -89,7 +88,7 @@ void read_stdin(); /********************************************************************* - MAIN LOOP + * MAIN LOOP *********************************************************************/ int main (int argc, char ** argv) { @@ -143,13 +142,14 @@ int main (int argc, char ** argv) { start_screen(); #ifdef USECOLORS - //if (has_colors() && get_d_colors_param() == NULL) { if (get_d_colors_param() == NULL) { start_default_ucolors(); - // in case we decide to change colors - // this creates a dictionary and stores in it - // the relationship between macros and the keys values - // that are defined in .sc files + /* + * in case we decide to change colors + * this creates a dictionary and stores in it + * the relationship between macros and the keys values + * that are defined in .sc files + */ set_colors_param_dict(); } #endif @@ -192,7 +192,7 @@ int main (int argc, char ** argv) { // 4. read sc file passed as argv load_sc(); - // initiate gui + // initiate ui FILE * f; if ( ! atoi(get_conf_value("nocurses"))) { // we show welcome screen if no spreadsheet was passed to SC-IM @@ -237,7 +237,7 @@ int main (int argc, char ** argv) { return shall_quit == -1 ? exit_app(-1) : exit_app(0); } /********************************************************************* - END OF MAIN LOOP + * END OF MAIN LOOP *********************************************************************/ extern graphADT graph; @@ -349,8 +349,6 @@ int exit_app(int status) { // Erase stdin erase_buf(buffer); - //timeout(-1); - // stop CURSES screen if (! atoi(get_conf_value("nocurses"))) stop_screen(); diff --git a/src/range.c b/src/range.c index ec750f3..4ce43ce 100644 --- a/src/range.c +++ b/src/range.c @@ -7,7 +7,6 @@ #include "sc.h" #include "marks.h" #include "macros.h" -#include "color.h" // for set_ucolor #include "conf.h" #include "xmalloc.h" // for scxfree @@ -70,7 +70,6 @@ struct ent { struct enode * expr; /* cell's contents */ short flags; int row, col; - //short nlastrow, nlastcol; struct ent * next; // used for yanklist, freeents list, undo.. char * format; /* printf format for this cell */ char cellerror; /* error in a cell? */ @@ -11,7 +11,7 @@ #include "yank.h" #include "cmds.h" #include "conf.h" -#include "color.h" // for set_ucolor +#include "color.h" #include "xmalloc.h" // for scxfree int compare(const void * row1, const void * row2); diff --git a/src/trigger.c b/src/trigger.c index 592ba02..b24fb89 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -23,7 +23,6 @@ Triggers need mode,type,file,function flags #include "utils/dictionary.h" #include "utils/string.h" #include "range.h" -#include "color.h" #include "tui.h" #include "undo.h" #include "conf.h" @@ -1,4 +1,5 @@ -/* this is the ncurses implementation of sc-im user interface, or called tui. +/* + * this is the ncurses implementation of sc-im user interface, or called tui. * it mainly consists on the following two windows: * main_win: window that shows the grid * input_win: state bar window and stdin input @@ -7,11 +8,9 @@ * ui_start_screen * ui_stop_screen * ui_show_header - * ui_update * ui_do_welcome * ui_handle_cursor - * ui_yyerror * ui_show_text * ui_bail @@ -19,8 +18,8 @@ * ui_winchg * ui_print_mult_pend * ui_show_celldetails - * - * these are now called from outside and shouldnt: + * ui_start_colors + * ui_set_ucolor * ui_clr_header * ui_print_mode * @@ -29,9 +28,9 @@ * calc_offscr_sc_cols * calc_offscr_sc_rows * - * once these two are arranged, and main.c and input.c cleaned, - * anyone that want to port this to another ui, just - * need to reimplement the first group functions. + * once these three are arranged, + * anyone who wants to port this to another ui, would just + * need to reimplement these functions and help() in help.c */ #include <string.h> #include <ncurses.h> @@ -49,7 +48,6 @@ #include "sc.h" #include "cmds.h" #include "cmds_visual.h" -#include "color.h" #include "conf.h" #include "version.h" #include "file.h" @@ -167,9 +165,9 @@ void sc_msg(char * s, int type, ...) { if ( ! atoi(get_conf_value("nocurses"))) { #ifdef USECOLORS if (type == ERROR_MSG) - set_ucolor(input_win, &ucolors[ERROR_MSG]); + ui_set_ucolor(input_win, &ucolors[ERROR_MSG]); else - set_ucolor(input_win, &ucolors[INFO_MSG]); + ui_set_ucolor(input_win, &ucolors[INFO_MSG]); #endif mvwprintw(input_win, 1, 0, "%s", t); wclrtoeol(input_win); @@ -196,13 +194,12 @@ void sc_msg(char * s, int type, ...) { // Welcome screen void do_welcome() { - char * msg_title = "SC-IM - SpreadSheet Calculator Improvised"; char * msg_by = "A SC fork by Andrés Martinelli"; char * msg_version = rev; char * msg_help = "Press :help<Enter> to get help "; char * msg_help2 = "Press <Enter> to enter NORMAL mode"; - int i=0; + int i; #ifdef USECOLORS wbkgd(main_win, COLOR_PAIR((ucolors[DEFAULT].fg+1) * 9 + ucolors[DEFAULT].bg + 2)); @@ -216,7 +213,7 @@ void do_welcome() { show_sc_row_headings(main_win, mxrow); #ifdef USECOLORS - set_ucolor(main_win, &ucolors[WELCOME]); + ui_set_ucolor(main_win, &ucolors[WELCOME]); #endif // show message @@ -225,43 +222,37 @@ void do_welcome() { mvwaddstr(main_win, LINES/2-1, COLS/2-strlen(msg_version)/2, msg_version); #ifdef USECOLORS - set_ucolor(main_win, &ucolors[WELCOME]); + ui_set_ucolor(main_win, &ucolors[WELCOME]); #endif - while (msg_help[i] != '\0') { + for (i=0; msg_help[i] != '\0'; i++) { if (msg_help[i] == '<') { #ifdef USECOLORS - set_ucolor(main_win, &ucolors[NUMB]); + ui_set_ucolor(main_win, &ucolors[NUMB]); #endif } mvwaddstr(main_win, LINES/2, COLS/2-strlen(msg_help)/2+i, &msg_help[i]); if (msg_help[i] == '>') { #ifdef USECOLORS - set_ucolor(main_win, &ucolors[WELCOME]); + ui_set_ucolor(main_win, &ucolors[WELCOME]); #endif } - i++; } - i=0; - while (msg_help2[i] != '\0') { + for (i=0; msg_help2[i] != '\0'; i++) { if (msg_help2[i] == '<') { #ifdef USECOLORS - set_ucolor(main_win, &ucolors[NUMB]); + ui_set_ucolor(main_win, &ucolors[NUMB]); #endif } mvwaddstr(main_win, LINES/2+1, COLS/2-strlen(msg_help2)/2+i, &msg_help2[i]); if (msg_help2[i] == '>') { #ifdef USECOLORS - set_ucolor(main_win, &ucolors[WELCOME]); + ui_set_ucolor(main_win, &ucolors[WELCOME]); #endif } - i++; } - //mvwaddstr(main_win, LINES/2 , COLS/2-strlen(msg_help)/2 , msg_help); //mvwaddstr(main_win, LINES/2+1, COLS/2-strlen(msg_help2)/2 , msg_help2); - wrefresh(main_win); - return; } @@ -341,7 +332,7 @@ void handle_cursor() { case INSERT_MODE: case EDIT_MODE: noecho(); - curs_set(1); // changes for NETBSD compatibility + curs_set(1); // changed for NETBSD compatibility break; default: noecho(); @@ -350,9 +341,11 @@ void handle_cursor() { return; } -/* Print string with alignment - JUSTIF: 0 left shift - JUSTIF: 1 right shift */ +/* + * internal function - Print string with alignment + * JUSTIF: 0 left shift + * JUSTIF: 1 right shift + */ void write_j(WINDOW * win, const char * word, const unsigned int row, const unsigned int justif) { (justif == 0) ? (wmove(win, row, 0) && wclrtoeol(win)) : wmove(win, row, COLS - strlen(word)); wprintw(win, "%s", word); @@ -367,7 +360,7 @@ void ui_print_mult_pend() { getyx(input_win, row_orig, col_orig); #ifdef USECOLORS - set_ucolor(input_win, &ucolors[MODE]); + ui_set_ucolor(input_win, &ucolors[MODE]); #endif // Show multiplier and pending operator char strm[COLS]; @@ -390,8 +383,10 @@ void ui_print_mult_pend() { wrefresh(input_win); } -// Show first and second row (header) -// Handle cursor position +/* + * Show first and second row (header) + * Handle cursor position + */ void ui_show_header() { ui_clr_header(0); ui_clr_header(1); @@ -419,7 +414,8 @@ void ui_show_header() { return; } -/* Clean a whole row +/* + * Clean a whole row * i = line to clean */ void ui_clr_header(int i) { @@ -436,14 +432,16 @@ void ui_clr_header(int i) { return; } -// Print current mode in the first row -// Print ':' (colon) or submode indicator +/* + * Print current mode in the first row + * Print ':' (colon) or submode indicator + */ void ui_print_mode() { unsigned int row = 0; // Print mode in first row char strm[22] = ""; #ifdef USECOLORS - set_ucolor(input_win, &ucolors[MODE]); + ui_set_ucolor(input_win, &ucolors[MODE]); #endif |