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