Skip to content

Commit

Permalink
renamed winch to sig_winch. current fg and bg colors are kept if they…
Browse files Browse the repository at this point in the history
… are not specified in :cellcolor. added comments in tui.c
  • Loading branch information
andmarti1424 committed Dec 15, 2017
1 parent 03c38aa commit 61a4ae6
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/cmds_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ void do_commandmode(struct block * sb) {
} else if (find_val(sb, OKEY_ENTER)) {

if ( ! wcscmp(inputline, L"refresh")) {
winchg();
sig_winchg();

} else if ( ! wcscmp(inputline, L"help") || ! wcscmp(inputline, L"h") ) {
help();
Expand Down
4 changes: 2 additions & 2 deletions src/cmds_normal.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#include "history.h"
#include "hide_show.h"
#include "shift.h"
#include "main.h" // for winchg
#include "main.h" // for sig_winchg
#include "interp.h"
#include "freeze.h"
#include "utils/extra.h"
Expand Down Expand Up @@ -1059,7 +1059,7 @@ void do_normalmode(struct block * buf) {
}

case ctl('l'):
winchg();
sig_winchg();
break;

case L'@':
Expand Down
20 changes: 10 additions & 10 deletions src/color.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct dictionary * get_d_colors_param() {
* @brief Generate DEFAULT 'initcolor' colors
*
* Generate DEFAULT 'initcolor' colors.
*
*
* Example usage:
* @code
* start_default_ucolors();
Expand Down Expand Up @@ -307,13 +307,13 @@ void chg_color(char * str) {
* supports undo / redo
*/
/**
* @brief TODO <brief function description>
* @brief
*
* Changes coloring and format for cell or range of cells.
*
* Format options: bold, underline.
*
* This funciton supports undo/redo.
* This function supports undo/redo.
*
* Example usage:
* @code
Expand Down Expand Up @@ -368,8 +368,8 @@ void color_cell(int r, int c, int rf, int cf, char * str) {
n = lookat(i, j);
if (n->ucolor == NULL) {
n->ucolor = (struct ucolor *) malloc(sizeof(struct ucolor));
n->ucolor->fg = WHITE;
n->ucolor->bg = BLACK;
n->ucolor->fg = NONE_COLOR;
n->ucolor->bg = NONE_COLOR;
n->ucolor->bold = 0;
n->ucolor->dim = 0;
n->ucolor->reverse = 0;
Expand Down Expand Up @@ -406,9 +406,9 @@ void color_cell(int r, int c, int rf, int cf, char * str) {
}

/**
* @brief TODO <brief function description>
* @brief
*
* TODO Write longer function description.
* Cleans format from a range of cells
*
* Example usage:
* @code
Expand Down Expand Up @@ -467,7 +467,7 @@ void unformat(int r, int c, int rf, int cf) {
}

/**
* @brief TODO <brief function description>
* @brief
*
* This function receives two ucolor variables and returns 1 if both have the
* same values, returns 0 otherwise.
Expand Down Expand Up @@ -508,7 +508,7 @@ int same_ucolor(struct ucolor * u, struct ucolor * v) {

int redefine_color(char * color, int r, int g, int b) {
#if defined(NCURSES) && defined(USECOLORS)
extern void winchg();
extern void sig_winchg();
if (
! atoi(get_conf_value("nocurses"))
&& has_colors() && can_change_color()
Expand All @@ -519,7 +519,7 @@ int redefine_color(char * color, int r, int g, int b) {
return -1;
}
if (init_color(atoi(s), r, g, b) == 0) {
winchg();
sig_winchg();
if (! loading) sc_info("Color %s redefined to %d %d %d.", color, r, g, b);
return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ void signals() {
void sig_abrt();
void sig_term();
void nopipe();
void winchg();
void sig_winchg();
void sig_tstp();
void sig_cont();

Expand All @@ -598,7 +598,7 @@ void signals() {
signal(SIGTERM, sig_term); // kill
signal(SIGPIPE, nopipe);
//(void) signal(SIGALRM, time_out);
signal(SIGWINCH, winchg);
signal(SIGWINCH, sig_winchg);
//(void) signal(SIGBUS, doquit);
//(void) signal(SIGFPE, doquit);
signal(SIGTSTP, sig_tstp);
Expand Down Expand Up @@ -644,7 +644,7 @@ void sig_tstp() {

void sig_cont() {
signal(SIGTSTP, sig_tstp); /* set handler back to this */
winchg();
sig_winchg();
reset_prog_mode();
refresh();
ui_update(TRUE);
Expand Down
2 changes: 1 addition & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void show_version_and_quit();
void sig_int();

// SIGWINCH signal - resize of terminal
void winchg();
void sig_winchg();

extern FILE * fdoutput; // output file descriptor (stdout or file)
extern unsigned int curmode;
Expand Down
37 changes: 19 additions & 18 deletions src/tui.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ SCREEN * sstdout;
srange * ranges;

/**
* \brief Called to start UI
* \brief Called to start UI
*
* \return none
*/
Expand Down Expand Up @@ -328,7 +328,7 @@ void ui_do_welcome() {
* \details This function is used to refresh the screen content. If
* the header flag is set, the first column of the screen gets
* refreshed.
*
*
* \param[in] header
*
* \return none
Expand Down Expand Up @@ -429,7 +429,7 @@ void ui_handle_cursor() {
* \details Internal function to print a string with alignment.
*
* JUSTIF: 0 left shift
*
*
* JUSTIF: 1 right shift
*
* \param[in] win
Expand Down Expand Up @@ -1143,15 +1143,11 @@ void ui_show_text(char * val) {


/**
* \brief TODO Document winchg()
*
* \brief
* UI function thats called after SIGWINCH signal.
* \return none
*/

// TODO Consider renaming this to sig_winchg for consistancy with
// the other signal funcitons.

void winchg() {
void sig_winchg() {
endwin();
refresh();
clear();
Expand Down Expand Up @@ -1306,22 +1302,29 @@ char * ui_query(char * initial_msg) {
*/

void ui_set_ucolor(WINDOW * w, struct ucolor * uc) {
short color;
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));
if (uc->bg == NONE_COLOR || uc->fg == NONE_COLOR) {
// get current window color;
attr_t a;
wattr_get(w, &a, &color, NULL);
} else {
color = (uc->fg+1)*9 + uc->bg + 2;
}
wattrset (w, attr | COLOR_PAIR(color));
}

/**
* \brief TODO Document ui_start_colors()
*
* \return none
*/

void ui_start_colors() {
if (! has_colors()) return;
int i, j;
Expand All @@ -1333,11 +1336,10 @@ void ui_start_colors() {
}

/**
* \brief TODO Document ui_pause()
*
* \brief
* UI function thats called after SIGTSTP signal.
* \return none
*/

void ui_pause() {
def_prog_mode();
set_term(sstderr);
Expand All @@ -1346,11 +1348,10 @@ void ui_pause() {
}

/**
* \brief TODO Document ui_resume
*
* \brief
* UI function thats called after SIGCONT signal.
* \return none
*/

void ui_resume() {
set_term(sstdout);
reset_prog_mode();
Expand Down
1 change: 1 addition & 0 deletions src/tui.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#endif
#include "color.h"

#define NONE_COLOR -2
#define DEFAULT_COLOR -1
#define BLACK COLOR_BLACK
#define RED COLOR_RED
Expand Down

0 comments on commit 61a4ae6

Please sign in to comment.