Changeset c88d7f99 in mainline
- Timestamp:
- 2022-03-10T17:44:35Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c38ab6c
- Parents:
- 96c6a00
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/calculator/calculator.c
r96c6a00 rc88d7f99 902 902 } 903 903 904 rc = ui_menu_entry_create(mfile, "E xit", "Alt-F4", &mexit);904 rc = ui_menu_entry_create(mfile, "E~x~it", "Alt-F4", &mexit); 905 905 if (rc != EOK) { 906 906 printf("Error creating menu.\n"); … … 916 916 } 917 917 918 rc = ui_menu_entry_create(medit, " Copy", "Ctrl-C", &mcopy);918 rc = ui_menu_entry_create(medit, "~C~opy", "Ctrl-C", &mcopy); 919 919 if (rc != EOK) { 920 920 printf("Error creating menu.\n"); … … 924 924 ui_menu_entry_set_cb(mcopy, calc_edit_copy, (void *) &calc); 925 925 926 rc = ui_menu_entry_create(medit, " Paste", "Ctrl-V", &mpaste);926 rc = ui_menu_entry_create(medit, "~P~aste", "Ctrl-V", &mpaste); 927 927 if (rc != EOK) { 928 928 printf("Error creating menu.\n"); -
uspace/app/edit/edit.c
r96c6a00 rc88d7f99 436 436 } 437 437 438 rc = ui_menu_entry_create(mfile, " Save", "Ctrl-S", &msave);438 rc = ui_menu_entry_create(mfile, "~S~ave", "Ctrl-S", &msave); 439 439 if (rc != EOK) { 440 440 printf("Error creating menu.\n"); … … 444 444 ui_menu_entry_set_cb(msave, edit_file_save, (void *) edit); 445 445 446 rc = ui_menu_entry_create(mfile, "Save As", "Ctrl-E", &msaveas);446 rc = ui_menu_entry_create(mfile, "Save ~A~s", "Ctrl-E", &msaveas); 447 447 if (rc != EOK) { 448 448 printf("Error creating menu.\n"); … … 458 458 } 459 459 460 rc = ui_menu_entry_create(mfile, "E xit", "Ctrl-Q", &mexit);460 rc = ui_menu_entry_create(mfile, "E~x~it", "Ctrl-Q", &mexit); 461 461 if (rc != EOK) { 462 462 printf("Error creating menu.\n"); … … 472 472 } 473 473 474 rc = ui_menu_entry_create(medit, "Cu t", "Ctrl-X", &mcut);474 rc = ui_menu_entry_create(medit, "Cu~t~", "Ctrl-X", &mcut); 475 475 if (rc != EOK) { 476 476 printf("Error creating menu.\n"); … … 480 480 ui_menu_entry_set_cb(mcut, edit_edit_cut, (void *) edit); 481 481 482 rc = ui_menu_entry_create(medit, " Copy", "Ctrl-C", &mcopy);482 rc = ui_menu_entry_create(medit, "~C~opy", "Ctrl-C", &mcopy); 483 483 if (rc != EOK) { 484 484 printf("Error creating menu.\n"); … … 488 488 ui_menu_entry_set_cb(mcopy, edit_edit_copy, (void *) edit); 489 489 490 rc = ui_menu_entry_create(medit, " Paste", "Ctrl-V", &mpaste);490 rc = ui_menu_entry_create(medit, "~P~aste", "Ctrl-V", &mpaste); 491 491 if (rc != EOK) { 492 492 printf("Error creating menu.\n"); … … 496 496 ui_menu_entry_set_cb(mpaste, edit_edit_paste, (void *) edit); 497 497 498 rc = ui_menu_entry_create(medit, " Delete", "Del", &mdelete);498 rc = ui_menu_entry_create(medit, "~D~elete", "Del", &mdelete); 499 499 if (rc != EOK) { 500 500 printf("Error creating menu.\n"); … … 510 510 } 511 511 512 rc = ui_menu_entry_create(medit, "Select All", "Ctrl-A", &mselall);512 rc = ui_menu_entry_create(medit, "Select ~A~ll", "Ctrl-A", &mselall); 513 513 if (rc != EOK) { 514 514 printf("Error creating menu.\n"); … … 524 524 } 525 525 526 rc = ui_menu_entry_create(msearch, " Find", "Ctrl-F", &mfind);526 rc = ui_menu_entry_create(msearch, "~F~ind", "Ctrl-F", &mfind); 527 527 if (rc != EOK) { 528 528 printf("Error creating menu.\n"); … … 532 532 ui_menu_entry_set_cb(mfind, edit_search_find, (void *) edit); 533 533 534 rc = ui_menu_entry_create(msearch, " Reverse Find", "Ctrl-Shift-F", &mfindr);534 rc = ui_menu_entry_create(msearch, "~R~everse Find", "Ctrl-Shift-F", &mfindr); 535 535 if (rc != EOK) { 536 536 printf("Error creating menu.\n"); … … 540 540 ui_menu_entry_set_cb(mfindr, edit_search_reverse_find, (void *) edit); 541 541 542 rc = ui_menu_entry_create(msearch, "Find Next", "Ctrl-N", &mfindn);542 rc = ui_menu_entry_create(msearch, "Find ~N~ext", "Ctrl-N", &mfindn); 543 543 if (rc != EOK) { 544 544 printf("Error creating menu.\n"); … … 554 554 } 555 555 556 rc = ui_menu_entry_create(msearch, "Go To Line", "Ctrl-L", &mgoto);556 rc = ui_menu_entry_create(msearch, "Go To ~L~ine", "Ctrl-L", &mgoto); 557 557 if (rc != EOK) { 558 558 printf("Error creating menu.\n"); -
uspace/app/uidemo/uidemo.c
r96c6a00 rc88d7f99 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 545 545 } 546 546 547 rc = ui_menu_entry_create(demo.mfile, " Message", "", &mmsg);547 rc = ui_menu_entry_create(demo.mfile, "~M~essage", "", &mmsg); 548 548 if (rc != EOK) { 549 549 printf("Error creating menu.\n"); … … 553 553 ui_menu_entry_set_cb(mmsg, uidemo_file_message, (void *) &demo); 554 554 555 rc = ui_menu_entry_create(demo.mfile, " Load", "", &mload);555 rc = ui_menu_entry_create(demo.mfile, "~L~oad", "", &mload); 556 556 if (rc != EOK) { 557 557 printf("Error creating menu.\n"); … … 561 561 ui_menu_entry_set_cb(mload, uidemo_file_load, (void *) &demo); 562 562 563 rc = ui_menu_entry_create(demo.mfile, " Foo", "Ctrl-Alt-Del", &mfoo);564 if (rc != EOK) { 565 printf("Error creating menu.\n"); 566 return rc; 567 } 568 569 rc = ui_menu_entry_create(demo.mfile, " Bar", "", &mbar);570 if (rc != EOK) { 571 printf("Error creating menu.\n"); 572 return rc; 573 } 574 575 rc = ui_menu_entry_create(demo.mfile, "F oobar", "", &mfoobar);563 rc = ui_menu_entry_create(demo.mfile, "~F~oo", "Ctrl-Alt-Del", &mfoo); 564 if (rc != EOK) { 565 printf("Error creating menu.\n"); 566 return rc; 567 } 568 569 rc = ui_menu_entry_create(demo.mfile, "~B~ar", "", &mbar); 570 if (rc != EOK) { 571 printf("Error creating menu.\n"); 572 return rc; 573 } 574 575 rc = ui_menu_entry_create(demo.mfile, "F~o~obar", "", &mfoobar); 576 576 if (rc != EOK) { 577 577 printf("Error creating menu.\n"); … … 585 585 } 586 586 587 rc = ui_menu_entry_create(demo.mfile, "E xit", "Alt-F4", &mexit);587 rc = ui_menu_entry_create(demo.mfile, "E~x~it", "Alt-F4", &mexit); 588 588 if (rc != EOK) { 589 589 printf("Error creating menu.\n"); … … 599 599 } 600 600 601 rc = ui_menu_entry_create(demo.medit, " Modify", "", &mmodify);601 rc = ui_menu_entry_create(demo.medit, "~M~odify", "", &mmodify); 602 602 if (rc != EOK) { 603 603 printf("Error creating menu.\n"); … … 619 619 } 620 620 621 rc = ui_menu_entry_create(demo.mhelp, " About", "Ctrl-H, F1", &mabout);621 rc = ui_menu_entry_create(demo.mhelp, "~A~bout", "Ctrl-H, F1", &mabout); 622 622 if (rc != EOK) { 623 623 printf("Error creating menu.\n"); -
uspace/lib/ui/include/ui/menuentry.h
r96c6a00 rc88d7f99 60 60 gfx_coord_t *, gfx_coord_t *); 61 61 extern gfx_coord_t ui_menu_entry_height(ui_menu_entry_t *); 62 extern char32_t ui_menu_entry_get_accel(ui_menu_entry_t *); 62 63 extern errno_t ui_menu_entry_paint(ui_menu_entry_t *, gfx_coord2_t *); 63 64 extern bool ui_menu_entry_selectable(ui_menu_entry_t *); -
uspace/lib/ui/src/menu.c
r96c6a00 rc88d7f99 604 604 static void ui_menu_key_press_unmod(ui_menu_t *menu, kbd_event_t *event) 605 605 { 606 ui_menu_entry_t *mentry; 607 char32_t c; 608 606 609 switch (event->key) { 607 610 case KC_ESCAPE: … … 625 628 break; 626 629 default: 630 if (event->c != '\0') { 631 mentry = ui_menu_entry_first(menu); 632 while (mentry != NULL) { 633 c = ui_menu_entry_get_accel(mentry); 634 if (c == event->c && menu->selected != NULL) { 635 ui_menu_entry_activate(mentry); 636 break; 637 } 638 mentry = ui_menu_entry_next(mentry); 639 } 640 } 627 641 break; 628 642 } -
uspace/lib/ui/src/menuentry.c
r96c6a00 rc88d7f99 43 43 #include <stdlib.h> 44 44 #include <str.h> 45 #include <ui/accel.h> 45 46 #include <ui/control.h> 46 47 #include <ui/paint.h> … … 245 246 res = ui_window_get_res(mentry->menu->mbar->window); 246 247 247 *caption_w = gfx_text_width(res->font, mentry->caption);248 *shortcut_w = gfx_text_width(res->font, mentry->shortcut);248 *caption_w = ui_text_width(res->font, mentry->caption); 249 *shortcut_w = ui_text_width(res->font, mentry->shortcut); 249 250 } 250 251 … … 331 332 } 332 333 334 /** Get menu entry accelerator character. 335 * 336 * @param mentry Menu entry 337 * @return Accelerator character (lowercase) or the null character if 338 * the menu entry has no accelerator. 339 */ 340 char32_t ui_menu_entry_get_accel(ui_menu_entry_t *mentry) 341 { 342 return ui_accel_get(mentry->caption); 343 } 344 333 345 /** Paint menu entry. 334 346 * … … 340 352 { 341 353 ui_resource_t *res; 342 gfx_text_fmt_t fmt;354 ui_text_fmt_t fmt; 343 355 gfx_color_t *bg_color; 344 356 ui_menu_entry_geom_t geom; … … 350 362 ui_menu_entry_get_geom(mentry, pos, &geom); 351 363 352 gfx_text_fmt_init(&fmt);364 ui_text_fmt_init(&fmt); 353 365 fmt.font = res->font; 354 366 fmt.halign = gfx_halign_left; … … 358 370 mentry == mentry->menu->selected) { 359 371 fmt.color = res->wnd_sel_text_color; 372 fmt.hgl_color = res->wnd_sel_text_hgl_color; 360 373 bg_color = res->wnd_sel_text_bg_color; 361 374 } else { 362 375 fmt.color = res->wnd_text_color; 376 fmt.hgl_color = res->wnd_text_hgl_color; 363 377 bg_color = res->wnd_face_color; 364 378 } … … 372 386 goto error; 373 387 374 rc = gfx_puttext(&geom.caption_pos, &fmt, mentry->caption);388 rc = ui_paint_text(&geom.caption_pos, &fmt, mentry->caption); 375 389 if (rc != EOK) 376 390 goto error; … … 378 392 fmt.halign = gfx_halign_right; 379 393 380 rc = gfx_puttext(&geom.shortcut_pos, &fmt, mentry->shortcut);394 rc = ui_paint_text(&geom.shortcut_pos, &fmt, mentry->shortcut); 381 395 if (rc != EOK) 382 396 goto error;
Note:
See TracChangeset
for help on using the changeset viewer.