Changeset 1affcdf3 in mainline for uspace/app/top/screen.c


Ignore:
Timestamp:
2011-06-10T19:33:41Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1878386
Parents:
13ecdac9 (diff), 79a141a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/top/screen.c

    r13ecdac9 r1affcdf3  
    4646#include "top.h"
    4747
     48#define USEC_COUNT  1000000
     49
    4850static sysarg_t warn_col = 0;
    4951static sysarg_t warn_row = 0;
     52static suseconds_t timeleft = 0;
     53
     54console_ctrl_t *console;
    5055
    5156static void screen_style_normal(void)
    5257{
    53         fflush(stdout);
    54         console_set_style(fphone(stdout), STYLE_NORMAL);
     58        console_flush(console);
     59        console_set_style(console, STYLE_NORMAL);
    5560}
    5661
    5762static void screen_style_inverted(void)
    5863{
    59         fflush(stdout);
    60         console_set_style(fphone(stdout), STYLE_INVERTED);
     64        console_flush(console);
     65        console_set_style(console, STYLE_INVERTED);
    6166}
    6267
    6368static void screen_moveto(sysarg_t col, sysarg_t row)
    6469{
    65         fflush(stdout);
    66         console_set_pos(fphone(stdout), col, row);
     70        console_flush(console);
     71        console_set_pos(console, col, row);
    6772}
    6873
    6974static void screen_get_pos(sysarg_t *col, sysarg_t *row)
    7075{
    71         fflush(stdout);
    72         console_get_pos(fphone(stdout), col, row);
     76        console_flush(console);
     77        console_get_pos(console, col, row);
    7378}
    7479
    7580static void screen_get_size(sysarg_t *col, sysarg_t *row)
    7681{
    77         fflush(stdout);
    78         console_get_size(fphone(stdout), col, row);
     82        console_flush(console);
     83        console_get_size(console, col, row);
    7984}
    8085
     
    8489       
    8590        if (clear) {
    86                 fflush(stdout);
    87                 console_clear(fphone(stdout));
     91                console_flush(console);
     92                console_clear(console);
    8893        }
    8994       
     
    111116void screen_init(void)
    112117{
    113         fflush(stdout);
    114         console_cursor_visibility(fphone(stdout), false);
     118        console = console_init(stdin, stdout);
     119       
     120        console_flush(console);
     121        console_cursor_visibility(console, false);
    115122       
    116123        screen_restart(true);
     
    121128        screen_restart(true);
    122129       
    123         fflush(stdout);
    124         console_cursor_visibility(fphone(stdout), true);
     130        console_flush(console);
     131        console_cursor_visibility(console, true);
    125132}
    126133
     
    508515        }
    509516       
    510         fflush(stdout);
     517        console_flush(console);
    511518}
    512519
     
    521528       
    522529        screen_newline();
    523         fflush(stdout);
     530        console_flush(console);
     531}
     532
     533/** Get char with timeout
     534 *
     535 */
     536int tgetchar(unsigned int sec)
     537{
     538        /*
     539         * Reset timeleft whenever it is not positive.
     540         */
     541       
     542        if (timeleft <= 0)
     543                timeleft = sec * USEC_COUNT;
     544       
     545        /*
     546         * Wait to see if there is any input. If so, take it and
     547         * update timeleft so that the next call to tgetchar()
     548         * will not wait as long. If there is no input,
     549         * make timeleft zero and return -1.
     550         */
     551       
     552        wchar_t c = 0;
     553       
     554        while (c == 0) {
     555                kbd_event_t event;
     556               
     557                if (!console_get_kbd_event_timeout(console, &event, &timeleft)) {
     558                        timeleft = 0;
     559                        return -1;
     560                }
     561               
     562                if (event.type == KEY_PRESS)
     563                        c = event.c;
     564        }
     565       
     566        return (int) c;
    524567}
    525568
Note: See TracChangeset for help on using the changeset viewer.