Ignore:
File:
1 edited

Legend:

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

    r79ae36dd rffa2c8ef  
    4646#include "top.h"
    4747
    48 #define USEC_COUNT  1000000
    49 
    5048static sysarg_t warn_col = 0;
    5149static sysarg_t warn_row = 0;
    52 static suseconds_t timeleft = 0;
    53 
    54 console_ctrl_t *console;
    5550
    5651static void screen_style_normal(void)
    5752{
    58         console_flush(console);
    59         console_set_style(console, STYLE_NORMAL);
     53        fflush(stdout);
     54        console_set_style(fphone(stdout), STYLE_NORMAL);
    6055}
    6156
    6257static void screen_style_inverted(void)
    6358{
    64         console_flush(console);
    65         console_set_style(console, STYLE_INVERTED);
     59        fflush(stdout);
     60        console_set_style(fphone(stdout), STYLE_INVERTED);
    6661}
    6762
    6863static void screen_moveto(sysarg_t col, sysarg_t row)
    6964{
    70         console_flush(console);
    71         console_set_pos(console, col, row);
     65        fflush(stdout);
     66        console_set_pos(fphone(stdout), col, row);
    7267}
    7368
    7469static void screen_get_pos(sysarg_t *col, sysarg_t *row)
    7570{
    76         console_flush(console);
    77         console_get_pos(console, col, row);
     71        fflush(stdout);
     72        console_get_pos(fphone(stdout), col, row);
    7873}
    7974
    8075static void screen_get_size(sysarg_t *col, sysarg_t *row)
    8176{
    82         console_flush(console);
    83         console_get_size(console, col, row);
     77        fflush(stdout);
     78        console_get_size(fphone(stdout), col, row);
    8479}
    8580
     
    8984       
    9085        if (clear) {
    91                 console_flush(console);
    92                 console_clear(console);
     86                fflush(stdout);
     87                console_clear(fphone(stdout));
    9388        }
    9489       
     
    116111void screen_init(void)
    117112{
    118         console = console_init(stdin, stdout);
    119        
    120         console_flush(console);
    121         console_cursor_visibility(console, false);
     113        fflush(stdout);
     114        console_cursor_visibility(fphone(stdout), false);
    122115       
    123116        screen_restart(true);
     
    128121        screen_restart(true);
    129122       
    130         console_flush(console);
    131         console_cursor_visibility(console, true);
     123        fflush(stdout);
     124        console_cursor_visibility(fphone(stdout), true);
    132125}
    133126
     
    261254        uint64_t used;
    262255        uint64_t free;
    263         const char *total_suffix;
    264         const char *unavail_suffix;
    265         const char *used_suffix;
    266         const char *free_suffix;
    267        
    268         bin_order_suffix(data->physmem->total, &total, &total_suffix, false);
    269         bin_order_suffix(data->physmem->unavail, &unavail, &unavail_suffix, false);
    270         bin_order_suffix(data->physmem->used, &used, &used_suffix, false);
    271         bin_order_suffix(data->physmem->free, &free, &free_suffix, false);
    272        
    273         printf("memory: %" PRIu64 "%s total, %" PRIu64 "%s unavail, %"
    274             PRIu64 "%s used, %" PRIu64 "%s free", total, total_suffix,
     256        char total_suffix;
     257        char unavail_suffix;
     258        char used_suffix;
     259        char free_suffix;
     260       
     261        order_suffix(data->physmem->total, &total, &total_suffix);
     262        order_suffix(data->physmem->unavail, &unavail, &unavail_suffix);
     263        order_suffix(data->physmem->used, &used, &used_suffix);
     264        order_suffix(data->physmem->free, &free, &free_suffix);
     265       
     266        printf("memory: %" PRIu64 "%c total, %" PRIu64 "%c unavail, %"
     267            PRIu64 "%c used, %" PRIu64 "%c free", total, total_suffix,
    275268            unavail, unavail_suffix, used, used_suffix, free, free_suffix);
    276269        screen_newline();
     
    302295               
    303296                uint64_t resmem;
    304                 const char *resmem_suffix;
    305                 bin_order_suffix(task->resmem, &resmem, &resmem_suffix, true);
     297                char resmem_suffix;
     298                order_suffix(task->resmem, &resmem, &resmem_suffix);
    306299               
    307300                uint64_t virtmem;
    308                 const char *virtmem_suffix;
    309                 bin_order_suffix(task->virtmem, &virtmem, &virtmem_suffix, true);
    310                
    311                 printf("%-8" PRIu64 " %7zu %7" PRIu64 "%s ",
     301                char virtmem_suffix;
     302                order_suffix(task->virtmem, &virtmem, &virtmem_suffix);
     303               
     304                printf("%-8" PRIu64 " %7zu %9" PRIu64 "%c ",
    312305                    task->task_id, task->threads, resmem, resmem_suffix);
    313306                print_percent(perc->resmem, 2);
    314                 printf(" %6" PRIu64 "%s ", virtmem, virtmem_suffix);
     307                printf(" %8" PRIu64 "%c ", virtmem, virtmem_suffix);
    315308                print_percent(perc->virtmem, 2);
    316309                puts(" ");
     
    515508        }
    516509       
    517         console_flush(console);
     510        fflush(stdout);
    518511}
    519512
     
    528521       
    529522        screen_newline();
    530         console_flush(console);
    531 }
    532 
    533 /** Get char with timeout
    534  *
    535  */
    536 int 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;
     523        fflush(stdout);
    567524}
    568525
Note: See TracChangeset for help on using the changeset viewer.