Changeset 9f1362d4 in mainline for uspace/app
- Timestamp:
- 2010-04-19T19:58:18Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 369a5f8
- Parents:
- caad59a
- Location:
- uspace/app
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/edit/edit.c
rcaad59a r9f1362d4 40 40 #include <vfs/vfs.h> 41 41 #include <io/console.h> 42 #include <io/ color.h>42 #include <io/style.h> 43 43 #include <io/keycode.h> 44 44 #include <errno.h> … … 100 100 static bool cursor_visible; 101 101 102 static int scr_rows, scr_columns; 102 static ipcarg_t scr_rows; 103 static ipcarg_t scr_columns; 103 104 104 105 #define ROW_BUF_SIZE 4096 … … 505 506 asprintf(&str, "%s: %s", prompt, init_value); 506 507 status_display(str); 507 console_ goto(con, 1 + str_length(str), scr_rows - 1);508 console_set_pos(con, 1 + str_length(str), scr_rows - 1); 508 509 free(str); 509 510 510 console_set_ color(con, COLOR_WHITE, COLOR_BLACK, 0);511 console_set_style(con, STYLE_INVERTED); 511 512 512 513 max_len = min(INFNAME_MAX_LEN, scr_columns - 4 - str_length(prompt)); … … 552 553 str = wstr_to_astr(buffer); 553 554 554 console_set_ color(con, COLOR_BLACK, COLOR_WHITE, 0);555 console_set_style(con, STYLE_NORMAL); 555 556 556 557 return str; … … 671 672 { 672 673 int sh_rows, rows; 673 int i, j;674 674 675 675 sheet_get_num_rows(&doc.sh, &sh_rows); … … 678 678 /* Draw rows from the sheet. */ 679 679 680 console_ goto(con, 0, 0);680 console_set_pos(con, 0, 0); 681 681 pane_row_range_display(0, rows); 682 682 683 683 /* Clear the remaining rows if file is short. */ 684 684 685 int i; 686 ipcarg_t j; 685 687 for (i = rows; i < pane.rows; ++i) { 686 console_ goto(con, 0, i);688 console_set_pos(con, 0, i); 687 689 for (j = 0; j < scr_columns; ++j) 688 690 putchar(' '); … … 736 738 /* Draw rows from the sheet. */ 737 739 738 console_ goto(con, 0, 0);740 console_set_pos(con, 0, 0); 739 741 for (i = r0; i < r1; ++i) { 740 742 /* Starting point for row display */ … … 756 758 coord_cmp(&rbc, &csel_end) < 0) { 757 759 fflush(stdout); 758 console_set_ color(con, COLOR_BLACK, COLOR_RED, 0);760 console_set_style(con, STYLE_SELECTED); 759 761 fflush(stdout); 760 762 } 761 763 762 console_ goto(con, 0, i);764 console_set_pos(con, 0, i); 763 765 size = str_size(row_buf); 764 766 pos = 0; … … 767 769 if ((csel_start.row == rbc.row) && (csel_start.column == s_column)) { 768 770 fflush(stdout); 769 console_set_ color(con, COLOR_BLACK, COLOR_RED, 0);771 console_set_style(con, STYLE_SELECTED); 770 772 fflush(stdout); 771 773 } … … 773 775 if ((csel_end.row == rbc.row) && (csel_end.column == s_column)) { 774 776 fflush(stdout); 775 console_set_ color(con, COLOR_BLACK, COLOR_WHITE, 0);777 console_set_style(con, STYLE_NORMAL); 776 778 fflush(stdout); 777 779 } … … 793 795 if ((csel_end.row == rbc.row) && (csel_end.column == s_column)) { 794 796 fflush(stdout); 795 console_set_ color(con, COLOR_BLACK, COLOR_WHITE, 0);797 console_set_style(con, STYLE_NORMAL); 796 798 fflush(stdout); 797 799 } … … 807 809 putchar(' '); 808 810 fflush(stdout); 809 console_set_ color(con, COLOR_BLACK, COLOR_WHITE, 0);811 console_set_style(con, STYLE_NORMAL); 810 812 } 811 813 … … 824 826 const char *fname = (doc.file_name != NULL) ? doc.file_name : "<unnamed>"; 825 827 826 console_ goto(con, 0, scr_rows - 1);827 console_set_ color(con, COLOR_WHITE, COLOR_BLACK, 0);828 console_set_pos(con, 0, scr_rows - 1); 829 console_set_style(con, STYLE_INVERTED); 828 830 int n = printf(" %d, %d: File '%s'. Ctrl-Q Quit Ctrl-S Save " 829 831 "Ctrl-E Save As", coord.row, coord.column, fname); 830 832 printf("%*s", scr_columns - 1 - n, ""); 831 833 fflush(stdout); 832 console_set_ color(con, COLOR_BLACK, COLOR_WHITE, 0);834 console_set_style(con, STYLE_NORMAL); 833 835 834 836 pane.rflags |= REDRAW_CARET; … … 844 846 845 847 spt_get_coord(&caret_pt, &coord); 846 console_ goto(con, coord.column - pane.sh_column,848 console_set_pos(con, coord.column - pane.sh_column, 847 849 coord.row - pane.sh_row); 848 850 } … … 1149 1151 static void status_display(char const *str) 1150 1152 { 1151 console_ goto(con, 0, scr_rows - 1);1152 console_set_ color(con, COLOR_WHITE, COLOR_BLACK, 0);1153 console_set_pos(con, 0, scr_rows - 1); 1154 console_set_style(con, STYLE_INVERTED); 1153 1155 printf(" %*s ", -(scr_columns - 3), str); 1154 1156 fflush(stdout); 1155 console_set_ color(con, COLOR_BLACK, COLOR_WHITE, 0);1157 console_set_style(con, STYLE_NORMAL); 1156 1158 1157 1159 pane.rflags |= REDRAW_CARET; -
uspace/app/tester/console/console1.c
rcaad59a r9f1362d4 53 53 fflush(stdout); 54 54 console_set_style(fphone(stdout), STYLE_NORMAL); 55 printf(" normal ");55 printf(" normal "); 56 56 fflush(stdout); 57 57 console_set_style(fphone(stdout), STYLE_EMPHASIS); 58 printf("emphasized"); 58 printf(" emphasized "); 59 fflush(stdout); 60 console_set_style(fphone(stdout), STYLE_INVERTED); 61 printf(" inverted "); 62 fflush(stdout); 63 console_set_style(fphone(stdout), STYLE_SELECTED); 64 printf(" selected "); 59 65 fflush(stdout); 60 66 console_set_style(fphone(stdout), STYLE_NORMAL); 61 printf(" .\n");67 printf("\n"); 62 68 63 69 unsigned int i; … … 73 79 } 74 80 fflush(stdout); 75 console_set_ color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0);81 console_set_style(fphone(stdout), STYLE_NORMAL); 76 82 putchar('\n'); 77 83 } … … 86 92 } 87 93 fflush(stdout); 88 console_set_ color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0);94 console_set_style(fphone(stdout), STYLE_NORMAL); 89 95 putchar('\n'); 90 96 } … … 94 100 for (i = 0; i < 255; i += 16) { 95 101 fflush(stdout); 96 console_set_rgb_color(fphone(stdout), 0xffffff, i << 16);102 console_set_rgb_color(fphone(stdout), (255 - i) << 16, i << 16); 97 103 putchar('X'); 98 104 } … … 103 109 for (i = 0; i < 255; i += 16) { 104 110 fflush(stdout); 105 console_set_rgb_color(fphone(stdout), 0xffffff, i << 8);111 console_set_rgb_color(fphone(stdout), (255 - i) << 8, i << 8); 106 112 putchar('X'); 107 113 } … … 112 118 for (i = 0; i < 255; i += 16) { 113 119 fflush(stdout); 114 console_set_rgb_color(fphone(stdout), 0xffffff, i);120 console_set_rgb_color(fphone(stdout), 255 - i, i); 115 121 putchar('X'); 116 122 } 117 123 fflush(stdout); 118 console_set_ color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0);124 console_set_style(fphone(stdout), STYLE_NORMAL); 119 125 putchar('\n'); 120 126 } -
uspace/app/tetris/screen.c
rcaad59a r9f1362d4 53 53 #include <vfs/vfs.h> 54 54 #include <async.h> 55 #include <bool.h> 56 #include <io/console.h> 57 #include <io/style.h> 55 58 #include "screen.h" 56 59 #include "tetris.h" 57 #include <io/console.h>58 60 59 61 #define STOP (B_COLS - 3) … … 63 65 static int isset; /* true => terminal is in game mode */ 64 66 65 static int use_color;/* true => use colors */67 static bool use_color; /* true => use colors */ 66 68 67 69 static const struct shape *lastshape; … … 81 83 { 82 84 fflush(stdout); 83 console_set_rgb_color(fphone(stdout), 0xf 0f0f0,85 console_set_rgb_color(fphone(stdout), 0xffffff, 84 86 use_color ? color : 0x000000); 85 87 } … … 88 90 { 89 91 fflush(stdout); 90 console_set_ rgb_color(fphone(stdout), 0, 0xf0f0f0);92 console_set_style(fphone(stdout), STYLE_NORMAL); 91 93 } 92 94 … … 118 120 } 119 121 120 void moveto(i nt r, int c)122 void moveto(ipcarg_t r, ipcarg_t c) 121 123 { 122 124 fflush(stdout); 123 console_ goto(fphone(stdout), c, r);125 console_set_pos(fphone(stdout), c, r); 124 126 } 125 127 … … 131 133 } 132 134 133 static int get_display_color_sup(void) 134 { 135 int rc; 136 int ccap; 137 138 rc = console_get_color_cap(fphone(stdout), &ccap); 135 static bool get_display_color_sup(void) 136 { 137 ipcarg_t ccap; 138 int rc = console_get_color_cap(fphone(stdout), &ccap); 139 139 140 if (rc != 0) 140 return 0;141 141 return false; 142 142 143 return (ccap >= CONSOLE_CCAP_RGB); 143 144 } … … 308 309 * (We need its length in case we have to overwrite with blanks.) 309 310 */ 310 void scr_msg(char *s, intset)311 void scr_msg(char *s, bool set) 311 312 { 312 313 int l = str_size(s); -
uspace/app/tetris/screen.h
rcaad59a r9f1362d4 48 48 49 49 #include <sys/types.h> 50 #include <ipc/ipc.h> 50 51 #include <async.h> 52 #include <bool.h> 51 53 52 54 typedef struct { 53 i nt ws_row;54 i nt ws_col;55 ipcarg_t ws_row; 56 ipcarg_t ws_col; 55 57 } winsize_t; 56 58 57 59 extern winsize_t winsize; 58 60 59 extern void moveto(i nt r, int c);61 extern void moveto(ipcarg_t r, ipcarg_t c); 60 62 extern void clear_screen(void); 61 63 … … 65 67 extern void scr_end(void); 66 68 extern void scr_init(void); 67 extern void scr_msg(char *, int);69 extern void scr_msg(char *, bool); 68 70 extern void scr_set(void); 69 71 extern void scr_update(void); -
uspace/app/top/screen.c
rcaad59a r9f1362d4 37 37 38 38 #include <stdio.h> 39 #include <ipc/ipc.h> 39 40 #include <io/console.h> 41 #include <io/style.h> 40 42 #include <vfs/vfs.h> 41 43 #include <stdarg.h> … … 45 47 #include "top.h" 46 48 47 #define WHITE 0xf0f0f0 48 #define BLACK 0x000000 49 50 static int rows; 51 static int colls; 52 static int up_rows; 49 static ipcarg_t warn_col = 0; 50 static ipcarg_t warn_row = 0; 51 52 static void screen_style_normal(void) 53 { 54 fflush(stdout); 55 console_set_style(fphone(stdout), STYLE_NORMAL); 56 } 57 58 static void screen_style_inverted(void) 59 { 60 fflush(stdout); 61 console_set_style(fphone(stdout), STYLE_INVERTED); 62 } 63 64 static void screen_moveto(ipcarg_t col, ipcarg_t row) 65 { 66 fflush(stdout); 67 console_set_pos(fphone(stdout), col, row); 68 } 69 70 static void screen_get_pos(ipcarg_t *col, ipcarg_t *row) 71 { 72 fflush(stdout); 73 console_get_pos(fphone(stdout), col, row); 74 } 75 76 static void screen_get_size(ipcarg_t *col, ipcarg_t *row) 77 { 78 fflush(stdout); 79 console_get_size(fphone(stdout), col, row); 80 } 81 82 static void screen_restart(bool clear) 83 { 84 screen_style_normal(); 85 86 if (clear) { 87 fflush(stdout); 88 console_clear(fphone(stdout)); 89 } 90 91 screen_moveto(0, 0); 92 } 93 94 static void screen_newline(void) 95 { 96 ipcarg_t cols; 97 ipcarg_t rows; 98 screen_get_size(&cols, &rows); 99 100 ipcarg_t c; 101 ipcarg_t r; 102 screen_get_pos(&c, &r); 103 104 ipcarg_t i; 105 for (i = c + 1; i < cols; i++) 106 puts(" "); 107 108 if (r + 1 < rows) 109 puts("\n"); 110 } 111 112 void screen_init(void) 113 { 114 fflush(stdout); 115 console_cursor_visibility(fphone(stdout), false); 116 117 screen_restart(true); 118 } 119 120 void screen_done(void) 121 { 122 screen_restart(true); 123 124 fflush(stdout); 125 console_cursor_visibility(fphone(stdout), true); 126 } 53 127 54 128 static void print_float(fixed_float ffloat, unsigned int precision) … … 64 138 } 65 139 66 static void screen_resume_normal(void) 67 { 68 fflush(stdout); 69 console_set_rgb_color(fphone(stdout), 0, WHITE); 70 } 71 72 static void screen_moveto(int r, int c) 73 { 74 fflush(stdout); 75 console_goto(fphone(stdout), c, r); 76 } 77 78 static void screen_clear(void) 79 { 80 console_clear(fphone(stdout)); 81 screen_moveto(0, 0); 82 up_rows = 0; 83 fflush(stdout); 84 } 85 86 void screen_init(void) 87 { 88 console_cursor_visibility(fphone(stdout), 0); 89 screen_resume_normal(); 90 screen_clear(); 91 92 console_get_size(fphone(stdout), &colls, &rows); 93 } 94 95 void screen_done(void) 96 { 97 screen_resume_normal(); 98 screen_clear(); 99 console_cursor_visibility(fphone(stdout), 1); 100 } 101 102 static inline void print_time(data_t *data) 103 { 104 printf("%02lu:%02lu:%02lu ", data->hours, data->minutes, data->seconds); 105 } 106 107 static inline void print_uptime(data_t *data) 108 { 109 printf("up %u days, %02u:%02u:%02u, ", data->udays, data->uhours, 110 data->uminutes, data->useconds); 111 } 112 113 static inline void print_load(data_t *data) 114 { 115 printf("load avarage: "); 140 static inline void print_global_head(data_t *data) 141 { 142 printf("top - %02lu:%02lu:%02lu up %u days, %02u:%02u:%02u, load avarage:", 143 data->hours, data->minutes, data->seconds, 144 data->udays, data->uhours, data->uminutes, data->useconds); 116 145 117 146 size_t i; 118 147 for (i = 0; i < data->load_count; i++) { 148 puts(" "); 119 149 stats_print_load_fragment(data->load[i], 2); 120 printf(" "); 121 } 150 } 151 152 screen_newline(); 122 153 } 123 154 … … 125 156 { 126 157 printf("tasks: %u total", data->tasks_count); 158 screen_newline(); 127 159 } 128 160 … … 137 169 size_t invalid = 0; 138 170 139 140 171 size_t i; 141 172 for (i = 0; i < data->threads_count; i++) { … … 167 198 "%u other, %u invalid", 168 199 total, running, ready, sleeping, lingering, other, invalid); 200 screen_newline(); 169 201 } 170 202 … … 178 210 data->cpus[i].id, data->cpus[i].frequency_mhz, 179 211 data->cpus[i].busy_ticks, data->cpus[i].idle_ticks); 180 p rintf(", idle: ");212 puts(", idle: "); 181 213 print_float(data->cpus_perc[i].idle, 2); 182 p rintf("%%, busy: ");214 puts("%, busy: "); 183 215 print_float(data->cpus_perc[i].busy, 2); 184 p rintf("%%\n");216 puts("%"); 185 217 } else 186 printf("cpu%u inactive \n", data->cpus[i].id);187 188 up_rows++;218 printf("cpu%u inactive", data->cpus[i].id); 219 220 screen_newline(); 189 221 } 190 222 } … … 209 241 PRIu64 "%c used, %" PRIu64 "%c free", total, total_suffix, 210 242 unavail, unavail_suffix, used, used_suffix, free, free_suffix); 211 } 212 213 static inline void print_tasks(data_t *data, int row) 214 { 215 size_t i; 216 for (i = 0; i < data->tasks_count; i++, row++) { 217 if (row > rows) 218 break; 219 243 screen_newline(); 244 } 245 246 static inline void print_task_head(void) 247 { 248 screen_style_inverted(); 249 printf(" ID Threads Mem %%Mem %%uCycles %%kCycles Name"); 250 screen_newline(); 251 screen_style_normal(); 252 } 253 254 static inline void print_tasks(data_t *data) 255 { 256 ipcarg_t cols; 257 ipcarg_t rows; 258 screen_get_size(&cols, &rows); 259 260 ipcarg_t col; 261 ipcarg_t row; 262 screen_get_pos(&col, &row); 263 264 size_t i; 265 for (i = 0; (i < data->tasks_count) && (row < rows); i++, row++) { 220 266 uint64_t virtmem; 221 267 char virtmem_suffix; … … 224 270 printf("%8" PRIu64 " %8u %8" PRIu64 "%c ", data->tasks[i].task_id, 225 271 data->tasks[i].threads, virtmem, virtmem_suffix); 226 p rintf(" ");272 puts(" "); 227 273 print_float(data->tasks_perc[i].virtmem, 2); 228 p rintf("%% ");274 puts("% "); 229 275 print_float(data->tasks_perc[i].ucycles, 2); 230 p rintf("%% ");276 puts("% "); 231 277 print_float(data->tasks_perc[i].kcycles, 2); 232 printf("%% %s\n", data->tasks[i].name); 233 } 234 } 235 236 static inline void print_task_head(void) 237 { 238 fflush(stdout); 239 console_set_rgb_color(fphone(stdout), WHITE, BLACK); 240 241 printf(" ID Threads Mem %%Mem %%uCycles %%kCycles Name"); 242 243 int i; 244 for (i = 61; i < colls; ++i) 245 printf(" "); 246 247 fflush(stdout); 248 console_set_rgb_color(fphone(stdout), BLACK, WHITE); 278 printf("%% %s", data->tasks[i].name); 279 280 screen_newline(); 281 } 249 282 } 250 283 251 284 static inline void print_ipc_head(void) 252 285 { 253 fflush(stdout); 254 console_set_rgb_color(fphone(stdout), WHITE, BLACK); 255 286 screen_style_inverted(); 256 287 printf(" ID Calls sent Calls recv Answs sent Answs recv IRQn recv Forw Name"); 257 258 int i;259 for (i = 80; i < colls; ++i) 260 printf(" "); 261 262 fflush(stdout); 263 console_set_rgb_color(fphone(stdout), BLACK, WHITE);264 } 265 266 static inline void print_ipc(data_t *data, int row) 267 { 268 size_t i;269 for (i = 0; i < data->tasks_count; i++, row++) {270 if (row > rows)271 break;272 288 screen_newline(); 289 screen_style_normal(); 290 } 291 292 static inline void print_ipc(data_t *data) 293 { 294 ipcarg_t cols; 295 ipcarg_t rows; 296 screen_get_size(&cols, &rows); 297 298 ipcarg_t col; 299 ipcarg_t row; 300 screen_get_pos(&col, &row); 301 302 size_t i; 303 for (i = 0; (i < data->tasks_count) && (row < rows); i++, row++) { 273 304 printf("%8" PRIu64 " %10" PRIu64 " %10" PRIu64 " %10" PRIu64 274 " %10" PRIu64 " %10" PRIu64 " %10" PRIu64 " %s \n",305 " %10" PRIu64 " %10" PRIu64 " %10" PRIu64 " %s", 275 306 data->tasks[i].task_id, data->tasks[i].ipc_info.call_sent, 276 307 data->tasks[i].ipc_info.call_recieved, … … 279 310 data->tasks[i].ipc_info.irq_notif_recieved, 280 311 data->tasks[i].ipc_info.forwarded, data->tasks[i].name); 312 313 screen_newline(); 281 314 } 282 315 } … … 284 317 void print_data(data_t *data) 285 318 { 286 screen_clear(); 287 fflush(stdout); 288 289 printf("top - "); 290 print_time(data); 291 print_uptime(data); 292 print_load(data); 293 294 printf("\n"); 295 up_rows++; 296 319 screen_restart(false); 320 print_global_head(data); 297 321 print_task_summary(data); 298 299 printf("\n");300 up_rows++;301 302 322 print_thread_summary(data); 303 304 printf("\n");305 up_rows++;306 307 323 print_cpu_info(data); 308 324 print_physmem_info(data); 309 325 310 printf("\n");311 up_rows++;312 313 326 /* Empty row for warnings */ 314 printf("\n"); 327 screen_get_pos(&warn_col, &warn_row); 328 screen_newline(); 315 329 316 330 if (operation_type == OP_IPC) { 317 331 print_ipc_head(); 318 printf("\n"); 319 print_ipc(data, up_rows); 332 print_ipc(data); 320 333 } else { 321 334 print_task_head(); 322 printf("\n"); 323 print_tasks(data, up_rows); 335 print_tasks(data); 324 336 } 325 337 … … 329 341 void print_warning(const char *fmt, ...) 330 342 { 331 screen_moveto( up_rows, 0);343 screen_moveto(warn_col, warn_row); 332 344 333 345 va_list args; … … 336 348 va_end(args); 337 349 350 screen_newline(); 338 351 fflush(stdout); 339 352 }
Note:
See TracChangeset
for help on using the changeset viewer.