Changeset b8d6783 in mainline for uspace/app/top/screen.c


Ignore:
Timestamp:
2012-04-15T08:21:20Z (13 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f76696f
Parents:
f682f5a
Message:

top: allow choosing column to sort by

File:
1 edited

Legend:

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

    rf682f5a rb8d6783  
    4444#include <stats.h>
    4545#include <inttypes.h>
     46#include <macros.h>
    4647#include "screen.h"
    4748#include "top.h"
     
    327328
    328329        printf("Other keys:");
     330        screen_newline();
     331       
     332        printf(" s .. choose column to sort by");
     333        screen_newline();
     334       
     335        printf(" r .. toggle reversed sorting");
    329336        screen_newline();
    330337       
     
    440447}
    441448
     449static inline void print_sort(table_t *table)
     450{
     451        sysarg_t cols;
     452        sysarg_t rows;
     453        screen_get_size(&cols, &rows);
     454       
     455        sysarg_t col;
     456        sysarg_t row;
     457        screen_get_pos(&col, &row);
     458
     459        size_t num = min(table->num_columns, rows - row);
     460        for (size_t i = 0; i < num; i++) {
     461                printf("%c - %s", table->columns[i].key, table->columns[i].name);
     462                screen_newline();
     463                row++;
     464        }
     465       
     466        while (row < rows) {
     467                screen_newline();
     468                row++;
     469        }
     470}
     471
    442472static inline void print_warning(void)
    443473{
     
    469499                print_table(&data->table);
    470500                break;
     501        case SCREEN_SORT:
     502                print_sort(&data->table);
     503                break;
    471504        case SCREEN_HELP:
    472505                print_help_head();
Note: See TracChangeset for help on using the changeset viewer.