Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/src/entry.c

    rd0dfbba r6df564c  
    11/*
    2  * Copyright (c) 2026 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3737 */
    3838
    39 #include <assert.h>
    4039#include <clipboard.h>
    4140#include <errno.h>
     
    4544#include <gfx/text.h>
    4645#include <macros.h>
    47 #include <stdio.h>
    4846#include <stdlib.h>
    4947#include <str.h>
     
    316314
    317315        gfx_text_fmt_init(&fmt);
    318         fmt.font = res->font;
    319316        fmt.color = res->entry_fg_color;
    320317        fmt.halign = gfx_halign_left;
     
    332329        entry->text[off1] = '\0';
    333330
    334         rc = gfx_puttext(&pos, &fmt, entry->text);
     331        rc = gfx_puttext(res->font, &pos, &fmt, entry->text);
    335332        if (rc != EOK) {
    336333                (void) gfx_set_clip_rect(res->gc, NULL);
     
    338335        }
    339336
    340         gfx_text_cont(&pos, &fmt, entry->text, &cpos, &cfmt);
     337        gfx_text_cont(res->font, &pos, &fmt, entry->text, &cpos, &cfmt);
    341338        entry->text[off1] = c;
    342339
     
    348345                cfmt.color = res->entry_sel_text_fg_color;
    349346
    350                 gfx_text_rect(&cpos, &cfmt, entry->text + off1, &sel);
     347                gfx_text_rect(res->font, &cpos, &cfmt, entry->text + off1, &sel);
    351348                sel.p0.x -= ui_entry_sel_hpad;
    352349                sel.p0.y -= ui_entry_sel_vpad;
     
    362359                        goto error;
    363360
    364                 rc = gfx_puttext(&cpos, &cfmt, entry->text + off1);
     361                rc = gfx_puttext(res->font, &cpos, &cfmt, entry->text + off1);
    365362                if (rc != EOK) {
    366363                        (void) gfx_set_clip_rect(res->gc, NULL);
     
    368365                }
    369366
    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);
    371369
    372370                entry->text[off2] = c;
     
    376374        cfmt.color = res->entry_fg_color;
    377375
    378         rc = gfx_puttext(&cpos, &cfmt, entry->text + off2);
     376        rc = gfx_puttext(res->font, &cpos, &cfmt, entry->text + off2);
    379377        if (rc != EOK) {
    380378                (void) gfx_set_clip_rect(res->gc, NULL);
     
    423421
    424422        gfx_text_fmt_init(&fmt);
    425         fmt.font = res->font;
    426423        fmt.halign = gfx_halign_left;
    427424        fmt.valign = gfx_valign_top;
    428425
    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);
    430428}
    431429
     
    666664                break;
    667665        }
     666
    668667        return ui_claimed;
    669668}
     
    744743        if (!entry->active)
    745744                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        }
    746754
    747755        /*
     
    760768        if (event->type == KEY_RELEASE && event->key == KC_RSHIFT)
    761769                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         }
    772770
    773771        if (event->type == KEY_PRESS &&
     
    11131111                anchor.y = 0;
    11141112                gfx_text_fmt_init(&fmt);
    1115                 fmt.font = res->font;
    11161113                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);
    11181116                entry->scroll_pos = tpos.x - geom.text_rect.p0.x;
    11191117        } else if (geom.text_pos.x + width < geom.text_rect.p1.x &&
Note: See TracChangeset for help on using the changeset viewer.