Changeset e2ca44f in mainline
- Timestamp:
- 2021-09-23T22:25:46Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- db52892a
- Parents:
- be869b0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/edit/edit.c
rbe869b0 re2ca44f 40 40 #include <errno.h> 41 41 #include <gfx/color.h> 42 #include <gfx/cursor.h> 42 43 #include <gfx/font.h> 43 44 #include <gfx/render.h> … … 148 149 static bool done; 149 150 static pane_t pane; 150 static bool cursor_visible;151 151 152 152 static sysarg_t scr_rows; … … 160 160 #define INFNAME_MAX_LEN 128 161 161 162 static void cursor_show(void);163 static void cursor_hide(void);164 162 static void cursor_setvis(bool visible); 165 163 … … 185 183 static void pane_fini(pane_t *); 186 184 static ui_control_t *pane_ctl(pane_t *); 185 static errno_t pane_update(pane_t *); 187 186 static errno_t pane_text_display(pane_t *); 188 187 static void pane_row_display(void); 189 188 static errno_t pane_row_range_display(pane_t *, int r0, int r1); 190 189 static void pane_status_display(void); 191 static void pane_caret_display( void);190 static void pane_caret_display(pane_t *); 192 191 193 192 static void insert_char(char32_t c); … … 313 312 314 313 /* Initial display */ 315 cursor_visible = true;316 314 rc = ui_window_paint(edit.window); 317 315 if (rc != EOK) { … … 320 318 } 321 319 322 cursor_hide();323 // console_clear(con);324 pane_text_display(&pane);325 320 pane_status_display(); 326 321 if (new_file && doc.file_name != NULL) 327 322 status_display("File not found. Starting empty file."); 328 pane_caret_display(); 329 cursor_show(); 330 /* 331 done = false; 332 333 while (!done) { 334 rc = console_get_event(con, &ev); 335 if (rc != EOK) 336 break; 337 338 pane.rflags = 0; 339 340 switch (ev.type) { 341 case CEV_KEY: 342 pane.keymod = ev.ev.key.mods; 343 if (ev.ev.key.type == KEY_PRESS) 344 key_handle_press(&ev.ev.key); 345 break; 346 case CEV_POS: 347 pos_handle(&ev.ev.pos); 348 break; 349 } 350 351 / Redraw as necessary. / 352 353 cursor_hide(); 354 355 if (pane.rflags & REDRAW_TEXT) 356 pane_text_display(&pane); 357 if (pane.rflags & REDRAW_ROW) 358 pane_row_display(); 359 if (pane.rflags & REDRAW_STATUS) 360 pane_status_display(); 361 if (pane.rflags & REDRAW_CARET) 362 pane_caret_display(); 363 364 cursor_show(); 365 } 366 367 console_clear(con); 368 */ 323 pane_caret_display(&pane); 324 cursor_setvis(true); 369 325 370 326 ui_run(edit.ui); … … 529 485 } 530 486 531 static void cursor_show(void)532 {533 cursor_setvis(true);534 }535 536 static void cursor_hide(void)537 {538 cursor_setvis(false);539 }540 541 487 static void cursor_setvis(bool visible) 542 488 { 543 if (cursor_visible != visible) { 544 // console_cursor_visibility(con, visible); 545 cursor_visible = visible; 546 } 489 gfx_context_t *gc = ui_window_get_gc(edit.window); 490 491 (void) gfx_cursor_set_visible(gc, visible); 547 492 } 548 493 … … 1028 973 return pane->control; 1029 974 } 975 976 /** Repaint parts of pane that need updating. 977 * 978 * @param pane Pane 979 * @return EOK on succes or an error code 980 */ 981 static errno_t pane_update(pane_t *pane) 982 { 983 errno_t rc; 984 985 if (pane->rflags & REDRAW_TEXT) { 986 rc = pane_text_display(pane); 987 if (rc != EOK) 988 return rc; 989 } 990 991 if (pane->rflags & REDRAW_ROW) 992 pane_row_display(); 993 994 if (pane->rflags & REDRAW_STATUS) 995 pane_status_display(); 996 997 if (pane->rflags & REDRAW_CARET) 998 pane_caret_display(pane); 999 1000 return EOK; 1001 } 1002 1030 1003 1031 1004 /** Display pane text. … … 1332 1305 } 1333 1306 1334 /** Set cursor to reflect position of the caret. */ 1335 static void pane_caret_display(void) 1307 /** Set cursor to reflect position of the caret. 1308 * 1309 * @param pane Pane 1310 */ 1311 static void pane_caret_display(pane_t *pane) 1336 1312 { 1337 1313 spt_t caret_pt; 1338 1314 coord_t coord; 1339 1340 tag_get_pt(&pane.caret_pos, &caret_pt); 1315 gfx_coord2_t pos; 1316 gfx_context_t *gc; 1317 1318 tag_get_pt(&pane->caret_pos, &caret_pt); 1341 1319 1342 1320 spt_get_coord(&caret_pt, &coord); 1343 // console_set_pos(con, coord.column - pane.sh_column, 1344 // coord.row - pane.sh_row); 1321 1322 gc = ui_window_get_gc(edit.window); 1323 pos.x = pane->rect.p0.x + coord.column - pane->sh_column; 1324 pos.y = pane->rect.p0.y + coord.row - pane->sh_row; 1325 1326 (void) gfx_cursor_set_pos(gc, &pos); 1345 1327 } 1346 1328 … … 2081 2063 kbd_event_t *event) 2082 2064 { 2083 if (event->type == KEY_PRESS) 2065 if (event->type == KEY_PRESS) { 2084 2066 key_handle_press(event); 2067 (void) pane_update(&pane); 2068 (void) gfx_update(ui_window_get_gc(window)); 2069 } 2085 2070 } 2086 2071
Note:
See TracChangeset
for help on using the changeset viewer.