Changeset a35b458 in mainline for uspace/dist/src/c/demos/top/screen.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/dist/src/c/demos/top/screen.c

    r3061bc1 ra35b458  
    9898{
    9999        screen_style_normal();
    100        
     100
    101101        if (clear) {
    102102                console_flush(console);
    103103                console_clear(console);
    104104        }
    105        
     105
    106106        screen_moveto(0, 0);
    107107}
     
    112112        sysarg_t rows;
    113113        screen_get_size(&cols, &rows);
    114        
     114
    115115        sysarg_t c;
    116116        sysarg_t r;
    117117        screen_get_pos(&c, &r);
    118        
     118
    119119        sysarg_t i;
    120120        for (i = c + 1; i < cols; i++)
    121121                puts(" ");
    122        
     122
    123123        if (r + 1 < rows)
    124124                puts("\n");
     
    128128{
    129129        console = console_init(stdin, stdout);
    130        
     130
    131131        console_flush(console);
    132132        console_cursor_visibility(console, false);
    133        
     133
    134134        screen_restart(true);
    135135}
     
    141141
    142142        screen_restart(true);
    143        
     143
    144144        console_flush(console);
    145145        console_cursor_visibility(console, true);
     
    149149{
    150150        printf("%3" PRIu64 ".", ffloat.upper / ffloat.lower);
    151        
     151
    152152        unsigned int i;
    153153        uint64_t rest = (ffloat.upper % ffloat.lower) * 10;
     
    156156                rest = (rest % ffloat.lower) * 10;
    157157        }
    158        
     158
    159159        printf("%%");
    160160}
     
    165165        sysarg_t rows;
    166166        screen_get_size(&cols, &rows);
    167        
     167
    168168        sysarg_t c;
    169169        sysarg_t r;
    170170        screen_get_pos(&c, &r);
    171        
     171
    172172        if (c < cols) {
    173173                int pos = cols - c - 1;
     
    183183            data->hours, data->minutes, data->seconds,
    184184            data->udays, data->uhours, data->uminutes, data->useconds);
    185        
     185
    186186        size_t i;
    187187        for (i = 0; i < data->load_count; i++) {
     
    189189                stats_print_load_fragment(data->load[i], 2);
    190190        }
    191        
     191
    192192        screen_newline();
    193193}
     
    208208        size_t other = 0;
    209209        size_t invalid = 0;
    210        
     210
    211211        size_t i;
    212212        for (i = 0; i < data->threads_count; i++) {
    213213                total++;
    214                
     214
    215215                switch (data->threads[i].state) {
    216216                case Running:
     
    234234                }
    235235        }
    236        
     236
    237237        printf("threads: %zu total, %zu running, %zu ready, "
    238238            "%zu sleeping, %zu lingering, %zu other, %zu invalid",
     
    250250                        char busy_suffix;
    251251                        char idle_suffix;
    252                        
     252
    253253                        order_suffix(data->cpus[i].busy_cycles, &busy, &busy_suffix);
    254254                        order_suffix(data->cpus[i].idle_cycles, &idle, &idle_suffix);
    255                        
     255
    256256                        printf("cpu%u (%4" PRIu16 " MHz): busy cycles: "
    257257                            "%" PRIu64 "%c, idle cycles: %" PRIu64 "%c",
     
    264264                } else
    265265                        printf("cpu%u inactive", data->cpus[i].id);
    266                
     266
    267267                screen_newline();
    268268        }
     
    279279        const char *used_suffix;
    280280        const char *free_suffix;
    281        
     281
    282282        bin_order_suffix(data->physmem->total, &total, &total_suffix, false);
    283283        bin_order_suffix(data->physmem->unavail, &unavail, &unavail_suffix, false);
    284284        bin_order_suffix(data->physmem->used, &used, &used_suffix, false);
    285285        bin_order_suffix(data->physmem->free, &free, &free_suffix, false);
    286        
     286
    287287        printf("memory: %" PRIu64 "%s total, %" PRIu64 "%s unavail, %"
    288288            PRIu64 "%s used, %" PRIu64 "%s free", total, total_suffix,
     
    304304        sysarg_t rows;
    305305        screen_get_size(&cols, &rows);
    306        
    307         screen_newline();
    308        
     306
     307        screen_newline();
     308
    309309        printf("Operation modes:");
    310310        screen_newline();
    311        
     311
    312312        printf(" t .. tasks statistics");
    313313        screen_newline();
    314        
     314
    315315        printf(" i .. IPC statistics");
    316316        screen_newline();
    317        
     317
    318318        printf(" e .. exceptions statistics");
    319319        screen_newline();
    320        
     320
    321321        printf("      a .. toggle display of all/hot exceptions");
    322322        screen_newline();
     
    329329        printf("Other keys:");
    330330        screen_newline();
    331        
     331
    332332        printf(" s .. choose column to sort by");
    333333        screen_newline();
    334        
     334
    335335        printf(" r .. toggle reversed sorting");
    336336        screen_newline();
    337        
     337
    338338        printf(" q .. quit");
    339339        screen_newline();
    340        
     340
    341341        sysarg_t col;
    342342        sysarg_t row;
    343343        screen_get_pos(&col, &row);
    344        
     344
    345345        while (row < rows) {
    346346                screen_newline();
     
    379379        sysarg_t rows;
    380380        screen_get_size(&cols, &rows);
    381        
     381
    382382        sysarg_t col;
    383383        sysarg_t row;
    384384        screen_get_pos(&col, &row);
    385        
     385
    386386        size_t i;
    387387        for (i = 0; (i < table->num_fields) && (row < rows); i++) {
     
    440440                }
    441441        }
    442        
     442
    443443        while (row < rows) {
    444444                screen_newline();
     
    452452        sysarg_t rows;
    453453        screen_get_size(&cols, &rows);
    454        
     454
    455455        sysarg_t col;
    456456        sysarg_t row;
     
    463463                row++;
    464464        }
    465        
     465
    466466        while (row < rows) {
    467467                screen_newline();
     
    493493        print_physmem_info(data);
    494494        print_warning();
    495        
     495
    496496        switch (screen_mode) {
    497497        case SCREEN_TABLE:
     
    506506                print_help();
    507507        }
    508        
     508
    509509        console_flush(console);
    510510}
     
    526526        vsnprintf(warning_text, warning_text_size, fmt, args);
    527527        va_end(args);
    528        
     528
    529529        warning_timeleft = 2 * USEC_COUNT;
    530530
     
    542542         * Reset timeleft whenever it is not positive.
    543543         */
    544        
     544
    545545        if (timeleft <= 0)
    546546                timeleft = sec * USEC_COUNT;
    547        
     547
    548548        /*
    549549         * Wait to see if there is any input. If so, take it and
     
    552552         * make timeleft zero and return -1.
    553553         */
    554        
     554
    555555        wchar_t c = 0;
    556        
     556
    557557        while (c == 0) {
    558558                cons_event_t event;
    559                
     559
    560560                warning_timeleft -= timeleft;
    561561                if (!console_get_event_timeout(console, &event, &timeleft)) {
     
    564564                }
    565565                warning_timeleft += timeleft;
    566                
     566
    567567                if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS)
    568568                        c = event.ev.key.c;
    569569        }
    570        
     570
    571571        return (int) c;
    572572}
Note: See TracChangeset for help on using the changeset viewer.