Changes in uspace/lib/ui/src/entry.c [d0dfbba:6df564c] in mainline
- File:
-
- 1 edited
-
uspace/lib/ui/src/entry.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/entry.c
rd0dfbba r6df564c 1 1 /* 2 * Copyright (c) 202 6Jiri Svoboda2 * Copyright (c) 2021 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 37 37 */ 38 38 39 #include <assert.h>40 39 #include <clipboard.h> 41 40 #include <errno.h> … … 45 44 #include <gfx/text.h> 46 45 #include <macros.h> 47 #include <stdio.h>48 46 #include <stdlib.h> 49 47 #include <str.h> … … 316 314 317 315 gfx_text_fmt_init(&fmt); 318 fmt.font = res->font;319 316 fmt.color = res->entry_fg_color; 320 317 fmt.halign = gfx_halign_left; … … 332 329 entry->text[off1] = '\0'; 333 330 334 rc = gfx_puttext( &pos, &fmt, entry->text);331 rc = gfx_puttext(res->font, &pos, &fmt, entry->text); 335 332 if (rc != EOK) { 336 333 (void) gfx_set_clip_rect(res->gc, NULL); … … 338 335 } 339 336 340 gfx_text_cont( &pos, &fmt, entry->text, &cpos, &cfmt);337 gfx_text_cont(res->font, &pos, &fmt, entry->text, &cpos, &cfmt); 341 338 entry->text[off1] = c; 342 339 … … 348 345 cfmt.color = res->entry_sel_text_fg_color; 349 346 350 gfx_text_rect( &cpos, &cfmt, entry->text + off1, &sel);347 gfx_text_rect(res->font, &cpos, &cfmt, entry->text + off1, &sel); 351 348 sel.p0.x -= ui_entry_sel_hpad; 352 349 sel.p0.y -= ui_entry_sel_vpad; … … 362 359 goto error; 363 360 364 rc = gfx_puttext( &cpos, &cfmt, entry->text + off1);361 rc = gfx_puttext(res->font, &cpos, &cfmt, entry->text + off1); 365 362 if (rc != EOK) { 366 363 (void) gfx_set_clip_rect(res->gc, NULL); … … 368 365 } 369 366 370 gfx_text_cont(&cpos, &cfmt, entry->text + off1, &cpos, &cfmt); 367 gfx_text_cont(res->font, &cpos, &cfmt, entry->text + off1, 368 &cpos, &cfmt); 371 369 372 370 entry->text[off2] = c; … … 376 374 cfmt.color = res->entry_fg_color; 377 375 378 rc = gfx_puttext( &cpos, &cfmt, entry->text + off2);376 rc = gfx_puttext(res->font, &cpos, &cfmt, entry->text + off2); 379 377 if (rc != EOK) { 380 378 (void) gfx_set_clip_rect(res->gc, NULL); … … 423 421 424 422 gfx_text_fmt_init(&fmt); 425 fmt.font = res->font;426 423 fmt.halign = gfx_halign_left; 427 424 fmt.valign = gfx_valign_top; 428 425 429 return gfx_text_find_pos(&geom.text_pos, &fmt, entry->text, fpos); 426 return gfx_text_find_pos(res->font, &geom.text_pos, &fmt, 427 entry->text, fpos); 430 428 } 431 429 … … 666 664 break; 667 665 } 666 668 667 return ui_claimed; 669 668 } … … 744 743 if (!entry->active) 745 744 return ui_unclaimed; 745 746 if (event->type == KEY_PRESS && event->c >= ' ') { 747 off = 0; 748 rc = chr_encode(event->c, buf, &off, sizeof(buf)); 749 if (rc == EOK) { 750 buf[off] = '\0'; 751 (void) ui_entry_insert_str(entry, buf); 752 } 753 } 746 754 747 755 /* … … 760 768 if (event->type == KEY_RELEASE && event->key == KC_RSHIFT) 761 769 entry->rshift_held = false; 762 763 if (event->type == KEY_PRESS &&764 (event->mods & (KM_CTRL | KM_ALT)) == 0 && event->c >= ' ') {765 off = 0;766 rc = chr_encode(event->c, buf, &off, sizeof(buf));767 if (rc == EOK) {768 buf[off] = '\0';769 (void) ui_entry_insert_str(entry, buf);770 }771 }772 770 773 771 if (event->type == KEY_PRESS && … … 1113 1111 anchor.y = 0; 1114 1112 gfx_text_fmt_init(&fmt); 1115 fmt.font = res->font;1116 1113 fmt.halign = entry->halign; 1117 gfx_text_start_pos(&anchor, &fmt, entry->text, &tpos); 1114 gfx_text_start_pos(res->font, &anchor, &fmt, entry->text, 1115 &tpos); 1118 1116 entry->scroll_pos = tpos.x - geom.text_rect.p0.x; 1119 1117 } else if (geom.text_pos.x + width < geom.text_rect.p1.x &&
Note:
See TracChangeset
for help on using the changeset viewer.
