Changeset 7572eb6 in mainline
- Timestamp:
- 2021-09-21T09:05:23Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f2d6d44e
- Parents:
- 68632b4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/edit/edit.c
r68632b4 r7572eb6 49 49 #include <stdbool.h> 50 50 #include <types/common.h> 51 #include <ui/fixed.h> 52 #include <ui/menu.h> 53 #include <ui/menubar.h> 54 #include <ui/menuentry.h> 51 55 #include <ui/ui.h> 52 56 #include <ui/window.h> … … 103 107 /** Editor window */ 104 108 ui_window_t *window; 109 /** UI resource */ 110 ui_resource_t *ui_res; 111 /** Menu bar */ 112 ui_menu_bar_t *menubar; 105 113 } edit_t; 106 114 … … 199 207 static void edit_ui_destroy(edit_t *); 200 208 209 static void edit_wnd_close(ui_window_t *, void *); 210 static void edit_wnd_kbd_event(ui_window_t *, void *, kbd_event_t *); 211 212 static ui_window_cb_t edit_window_cb = { 213 .close = edit_wnd_close, 214 .kbd = edit_wnd_kbd_event 215 }; 216 217 static void edit_file_exit(ui_menu_entry_t *, void *); 218 static void edit_edit_copy(ui_menu_entry_t *, void *); 219 static void edit_edit_paste(ui_menu_entry_t *, void *); 220 201 221 int main(int argc, char *argv[]) 202 222 { 203 // cons_event_t ev;204 223 bool new_file; 205 224 errno_t rc; 206 225 207 226 (void) pos_handle; 208 (void) key_handle_press;209 227 (void) pane_row_display; 210 211 // con = console_init(stdin, stdout);212 // console_clear(con);213 228 214 229 // console_get_size(con, &scr_columns, &scr_rows); … … 331 346 errno_t rc; 332 347 ui_wnd_params_t params; 348 ui_fixed_t *fixed = NULL; 349 ui_menu_t *mfile = NULL; 350 ui_menu_t *medit = NULL; 351 ui_menu_entry_t *mexit = NULL; 352 ui_menu_entry_t *mcopy = NULL; 353 ui_menu_entry_t *mpaste = NULL; 354 gfx_rect_t arect; 355 gfx_rect_t rect; 333 356 334 357 rc = ui_create(UI_CONSOLE_DEFAULT, &edit->ui); … … 343 366 params.rect.p0.x = 0; 344 367 params.rect.p0.y = 0; 345 params.rect.p1.x = 38;346 params.rect.p1.y = 18;368 params.rect.p1.x = 80; 369 params.rect.p1.y = 25; 347 370 348 371 rc = ui_window_create(edit->ui, ¶ms, &edit->window); … … 351 374 goto error; 352 375 } 353 /* 354 ui_window_set_cb(window, &window_cb, (void *) &calc); 355 calc.ui = ui; 356 357 ui_res = ui_window_get_res(window); 358 calc.ui_res = ui_res; 376 377 ui_window_set_cb(edit->window, &edit_window_cb, (void *) edit); 378 379 edit->ui_res = ui_window_get_res(edit->window); 359 380 360 381 rc = ui_fixed_create(&fixed); … … 364 385 } 365 386 366 rc = ui_menu_bar_create( ui, window, &calc.menubar);387 rc = ui_menu_bar_create(edit->ui, edit->window, &edit->menubar); 367 388 if (rc != EOK) { 368 389 printf("Error creating menu bar.\n"); … … 370 391 } 371 392 372 rc = ui_menu_create( calc.menubar, "File", &mfile);393 rc = ui_menu_create(edit->menubar, "File", &mfile); 373 394 if (rc != EOK) { 374 395 printf("Error creating menu.\n"); … … 382 403 } 383 404 384 ui_menu_entry_set_cb(mexit, calc_file_exit, (void *) &calc);385 386 rc = ui_menu_create( calc.menubar, "Edit", &medit);405 ui_menu_entry_set_cb(mexit, edit_file_exit, (void *) edit); 406 407 rc = ui_menu_create(edit->menubar, "Edit", &medit); 387 408 if (rc != EOK) { 388 409 printf("Error creating menu.\n"); … … 396 417 } 397 418 398 ui_menu_entry_set_cb(mcopy, calc_edit_copy, (void *) &calc);419 ui_menu_entry_set_cb(mcopy, edit_edit_copy, (void *) edit); 399 420 400 421 rc = ui_menu_entry_create(medit, "Paste", "Ctrl-V", &mpaste); … … 404 425 } 405 426 406 ui_menu_entry_set_cb(mpaste, calc_edit_paste, (void *) &calc); 407 408 ui_menu_bar_set_rect(calc.menubar, &calc.geom.menubar_rect); 409 410 rc = ui_fixed_add(fixed, ui_menu_bar_ctl(calc.menubar)); 427 ui_menu_entry_set_cb(mpaste, edit_edit_paste, (void *) edit); 428 429 ui_window_get_app_rect(edit->window, &arect); 430 431 rect.p0 = arect.p0; 432 rect.p1.x = arect.p1.x; 433 rect.p1.y = arect.p0.y + 1; 434 ui_menu_bar_set_rect(edit->menubar, &rect); 435 436 rc = ui_fixed_add(fixed, ui_menu_bar_ctl(edit->menubar)); 411 437 if (rc != EOK) { 412 438 printf("Error adding control to layout.\n"); 413 439 return rc; 414 440 } 415 */ 441 442 ui_window_add(edit->window, ui_fixed_ctl(fixed)); 416 443 return EOK; 417 444 error: … … 1813 1840 } 1814 1841 1842 /** Window close request 1843 * 1844 * @param window Window 1845 * @param arg Argument (edit_t *) 1846 */ 1847 static void edit_wnd_close(ui_window_t *window, void *arg) 1848 { 1849 edit_t *edit = (edit_t *) arg; 1850 1851 ui_quit(edit->ui); 1852 } 1853 1854 /** Window keyboard event 1855 * 1856 * @param window Window 1857 * @param arg Argument (edit_t *) 1858 * @param event Keyboard event 1859 */ 1860 static void edit_wnd_kbd_event(ui_window_t *window, void *arg, 1861 kbd_event_t *event) 1862 { 1863 if (event->type == KEY_PRESS) 1864 key_handle_press(event); 1865 } 1866 1867 /** File / Exit menu entry selected. 1868 * 1869 * @param mentry Menu entry 1870 * @param arg Argument (edit_t *) 1871 */ 1872 static void edit_file_exit(ui_menu_entry_t *mentry, void *arg) 1873 { 1874 edit_t *edit = (edit_t *) arg; 1875 1876 ui_quit(edit->ui); 1877 } 1878 1879 /** Edit / Copy menu entry selected. 1880 * 1881 * @param mentry Menu entry 1882 * @param arg Argument (edit_t *) 1883 */ 1884 static void edit_edit_copy(ui_menu_entry_t *mentry, void *arg) 1885 { 1886 (void) arg; 1887 } 1888 1889 /** Edit / Paste menu entry selected. 1890 * 1891 * @param mentry Menu entry 1892 * @param arg Argument (edit_t *) 1893 */ 1894 static void edit_edit_paste(ui_menu_entry_t *mentry, void *arg) 1895 { 1896 (void) arg; 1897 } 1898 1815 1899 /** @} 1816 1900 */
Note:
See TracChangeset
for help on using the changeset viewer.