Changeset c1c7c20 in mainline
- Timestamp:
- 2021-09-25T17:55:56Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 294fc3cc
- Parents:
- db52892a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/edit/edit.c
rdb52892a rc1c7c20 56 56 #include <ui/control.h> 57 57 #include <ui/fixed.h> 58 #include <ui/label.h> 58 59 #include <ui/menu.h> 59 60 #include <ui/menubar.h> … … 137 138 /** Menu bar */ 138 139 ui_menu_bar_t *menubar; 140 /** Status bar */ 141 ui_label_t *status; 139 142 } edit_t; 140 143 … … 190 193 static void pane_row_display(void); 191 194 static errno_t pane_row_range_display(pane_t *, int r0, int r1); 192 static void pane_status_display( void);195 static void pane_status_display(pane_t *); 193 196 static void pane_caret_display(pane_t *); 194 197 … … 321 324 } 322 325 323 pane_status_display( );326 pane_status_display(&pane); 324 327 if (new_file && doc.file_name != NULL) 325 328 status_display("File not found. Starting empty file."); … … 443 446 444 447 rc = ui_fixed_add(fixed, pane_ctl(&pane)); 448 if (rc != EOK) { 449 printf("Error adding control to layout.\n"); 450 return rc; 451 } 452 453 rc = ui_label_create(edit->ui_res, "", &edit->status); 454 if (rc != EOK) { 455 printf("Error creating menu bar.\n"); 456 return rc; 457 } 458 459 rect.p0.x = arect.p0.x; 460 rect.p0.y = arect.p1.y - 1; 461 rect.p1 = arect.p1; 462 ui_label_set_rect(edit->status, &rect); 463 464 rc = ui_fixed_add(fixed, ui_label_ctl(edit->status)); 445 465 if (rc != EOK) { 446 466 printf("Error adding control to layout.\n"); … … 1016 1036 1017 1037 if (pane->rflags & REDRAW_STATUS) 1018 pane_status_display( );1038 pane_status_display(pane); 1019 1039 1020 1040 if (pane->rflags & REDRAW_CARET) … … 1222 1242 } 1223 1243 1224 /** Display pane status in the status line. */ 1225 static void pane_status_display(void) 1244 /** Display pane status in the status line. 1245 * 1246 * @param pane Pane 1247 */ 1248 static void pane_status_display(pane_t *pane) 1226 1249 { 1227 1250 spt_t caret_pt; … … 1232 1255 char *text; 1233 1256 size_t n; 1234 int pos;1235 1257 size_t nextra; 1236 1258 size_t fnw; 1237 1259 1238 tag_get_pt(&pane .caret_pos, &caret_pt);1260 tag_get_pt(&pane->caret_pos, &caret_pt); 1239 1261 spt_get_coord(&caret_pt, &coord); 1240 1262 … … 1255 1277 return; 1256 1278 1257 // console_set_pos(con, 0, scr_rows - 1);1258 // console_set_style(con, STYLE_INVERTED);1259 1260 1279 /* 1261 1280 * Make sure the status fits on the screen. This loop should … … 1263 1282 */ 1264 1283 while (true) { 1265 int rc = asprintf(&text, " 1284 int rc = asprintf(&text, "%d, %d (%d): File '%s'. Ctrl-Q Quit Ctrl-S Save " 1266 1285 "Ctrl-E Save As", coord.row, coord.column, last_row, fname); 1267 1286 if (rc < 0) { … … 1284 1303 * just give up and print a blank status. 1285 1304 */ 1286 if (nextra > fnw - 2) 1305 if (nextra > fnw - 2) { 1306 text[0] = '\0'; 1287 1307 goto finish; 1308 } 1288 1309 1289 1310 /* Compute position where we overwrite with '..\0' */ … … 1302 1323 } 1303 1324 1304 printf("%s", text); 1325 finish: 1326 (void) ui_label_set_text(edit.status, text); 1327 (void) ui_label_paint(edit.status); 1305 1328 free(text); 1306 1329 free(fname); 1307 finish:1308 /* Fill the rest of the line */1309 pos = scr_columns - 1 - n;1310 printf("%*s", pos, "");1311 // console_flush(con);1312 // console_set_style(con, STYLE_NORMAL);1313 1314 pane.rflags |= REDRAW_CARET;1315 1330 } 1316 1331 … … 2041 2056 static void status_display(char const *str) 2042 2057 { 2043 // console_set_pos(con, 0, scr_rows - 1); 2044 // console_set_style(con, STYLE_INVERTED); 2045 2046 int pos = -(scr_columns - 3); 2047 printf(" %*s ", pos, str); 2048 // console_flush(con); 2049 // console_set_style(con, STYLE_NORMAL); 2050 2051 pane.rflags |= REDRAW_CARET; 2058 (void) ui_label_set_text(edit.status, str); 2059 (void) ui_label_paint(edit.status); 2052 2060 } 2053 2061
Note:
See TracChangeset
for help on using the changeset viewer.