diff options
Diffstat (limited to 'payloads/libpayload/curses')
-rw-r--r-- | payloads/libpayload/curses/colors.c | 3 | ||||
-rw-r--r-- | payloads/libpayload/curses/keyboard.c | 23 | ||||
-rw-r--r-- | payloads/libpayload/curses/tinycurses.c | 53 |
3 files changed, 35 insertions, 44 deletions
diff --git a/payloads/libpayload/curses/colors.c b/payloads/libpayload/curses/colors.c index 045df83ba3..34091498c0 100644 --- a/payloads/libpayload/curses/colors.c +++ b/payloads/libpayload/curses/colors.c @@ -36,7 +36,8 @@ unsigned char color_pairs[256] = { [0] = 0x07, }; -int start_color(void) { +int start_color(void) +{ return 0; } diff --git a/payloads/libpayload/curses/keyboard.c b/payloads/libpayload/curses/keyboard.c index 6ab5dd0cf7..3ec4d9d7bf 100644 --- a/payloads/libpayload/curses/keyboard.c +++ b/payloads/libpayload/curses/keyboard.c @@ -174,45 +174,38 @@ struct { static int cook_scancodes(unsigned char code) { static int modifiers = 0; - int ch = 0, sc, shift; + int ch = 0, sc, shift; - switch(code) { + switch (code) { case DOWN(SCANCODE_RSHIFT): case DOWN(SCANCODE_LSHIFT): modifiers |= SHIFT_MODIFIER; return 0; - case UP(SCANCODE_RSHIFT): case UP(SCANCODE_LSHIFT): modifiers &= ~SHIFT_MODIFIER; return 0; - case UP(SCANCODE_CAPSLOCK): if (modifiers & CAPSLOCK_MODIFIER) modifiers &= ~CAPSLOCK_MODIFIER; else modifiers |= CAPSLOCK_MODIFIER; return 0; - case DOWN(SCANCODE_LALT): modifiers |= ALT_MODIFIER; return 0; - case UP(SCANCODE_LALT): modifiers &= ~ALT_MODIFIER; return 0; - case DOWN(SCANCODE_LCTRL): modifiers |= CTRL_MODIFIER; return 0; - case UP(SCANCODE_LCTRL): modifiers &= ~CTRL_MODIFIER; return 0; } - /* Only process keys on an upstroke */ - + /* Only process keys on an upstroke. */ if (!ISUP(code)) return 0; @@ -231,8 +224,8 @@ static int cook_scancodes(unsigned char code) return ch; } -static int curses_getchar(int delay) { - +static int curses_getchar(int delay) +{ unsigned char c = 0; int ret; @@ -243,7 +236,7 @@ static int curses_getchar(int delay) { if ((c & 1) == 0) { if ((curses_flags & F_ENABLE_SERIAL) && - serial_havechar()) { + serial_havechar()) { c = serial_getchar(); return cook_serial(c); } @@ -258,9 +251,9 @@ static int curses_getchar(int delay) { if (ret != 0) { return ret; - } + } - } while(1); + } while (1); return ERR; } diff --git a/payloads/libpayload/curses/tinycurses.c b/payloads/libpayload/curses/tinycurses.c index dc6b77818b..946cdeb18b 100644 --- a/payloads/libpayload/curses/tinycurses.c +++ b/payloads/libpayload/curses/tinycurses.c @@ -150,20 +150,22 @@ WINDOW *derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx) int flags = _SUBWIN; /* Make sure window fits inside the original one. */ - if (begy < 0 || begx < 0 || orig == 0 || num_lines < 0 || num_columns < 0) - return NULL; + if (begy < 0 || begx < 0 || orig == 0 || num_lines < 0 + || num_columns < 0) + return NULL; + if (begy + num_lines > orig->_maxy + 1 || begx + num_columns > orig->_maxx + 1) - return NULL; + return NULL; if (num_lines == 0) - num_lines = orig->_maxy + 1 - begy; + num_lines = orig->_maxy + 1 - begy; if (num_columns == 0) - num_columns = orig->_maxx + 1 - begx; + num_columns = orig->_maxx + 1 - begx; if (orig->_flags & _ISPAD) - flags |= _ISPAD; + flags |= _ISPAD; //// if ((win = _nc_makenew(num_lines, num_columns, orig->_begy + begy, //// orig->_begx + begx, flags)) == 0) @@ -175,7 +177,7 @@ WINDOW *derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx) win->_nc_bkgd = orig->_nc_bkgd; for (i = 0; i < num_lines; i++) - win->_line[i].text = &orig->_line[begy++].text[begx]; + win->_line[i].text = &orig->_line[begy++].text[begx]; win->_parent = orig; @@ -217,11 +219,9 @@ WINDOW *initscr(void) // def_prog_mode(); if (curses_flags & F_ENABLE_CONSOLE) { - - /* Clear the screen and kill the cursor */ - - vga_clear(); - vga_cursor_enable(0); + /* Clear the screen and kill the cursor. */ + vga_clear(); + vga_cursor_enable(0); } // Speaker init? @@ -313,7 +313,8 @@ WINDOW *newwin(int num_lines, int num_columns, int begy, int begx) win->_attrs = A_NORMAL; for (i = 0; i < num_lines; i++) - win->_line[i].text = (NCURSES_CH_T *)&linebuf_list[linebuf_count++]; + win->_line[i].text = + (NCURSES_CH_T *)&linebuf_list[linebuf_count++]; return win; } @@ -479,7 +480,7 @@ int wclrtoeol(WINDOW *win) { /* TODO */ return(*(int *)0); } int wcolor_set(WINDOW *win, short color_pair_number, void *opts) { if (!opts && (color_pair_number >= 0) - && (color_pair_number < COLOR_PAIRS)) { + && (color_pair_number < COLOR_PAIRS)) { SET_WINDOW_PAIR(win, color_pair_number); if_EXT_COLORS(win->_color = color_pair_number); return OK; @@ -511,7 +512,7 @@ int whline(WINDOW *win, chtype ch, int n) start = win->_curx; end = start + n - 1; if (end > win->_maxx) - end = win->_maxx; + end = win->_maxx; CHANGED_RANGE(line, start, end); @@ -526,8 +527,8 @@ int whline(WINDOW *win, chtype ch, int n) wch = _nc_render(win, wch); while (end >= start) { - line->text[end] = wch; - end--; + line->text[end] = wch; + end--; } //// _nc_synchook(win); @@ -570,25 +571,21 @@ int wnoutrefresh(WINDOW *win) if (curses_flags & F_ENABLE_CONSOLE) { attr_t attr = win->_line[y].text[x].attr; - unsigned int c = ((int) color_pairs[PAIR_NUMBER(attr)]) << 8; - - /* Handle some of the attributes */ + unsigned int c = + ((int)color_pairs[PAIR_NUMBER(attr)]) << 8; - if (attr & A_BOLD) { + /* Handle some of the attributes. */ + if (attr & A_BOLD) c |= 0x0800; - } - if (attr & A_DIM) { + if (attr & A_DIM) c &= ~0x800; - } if (attr & A_REVERSE) { - unsigned char tmp = (c >> 8) & 0xF; - c = (c >> 4) & 0xF00; + unsigned char tmp = (c >> 8) & 0xf; + c = (c >> 4) & 0xf00; c |= tmp << 12; } c |= win->_line[y].text[x].chars[0]; - - vga_putc(y, x, c); } } |