Ignore:
File:
1 edited

Legend:

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

    r6df564c rd0dfbba  
    11/*
    2  * Copyright (c) 2021 Jiri Svoboda
     2 * Copyright (c) 2026 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3737 */
    3838
     39#include <assert.h>
    3940#include <clipboard.h>
    4041#include <errno.h>
     
    4445#include <gfx/text.h>
    4546#include <macros.h>
     47#include <stdio.h>
    4648#include <stdlib.h>
    4749#include <str.h>
     
    314316
    315317        gfx_text_fmt_init(&fmt);
     318        fmt.font = res->font;
    316319        fmt.color = res->entry_fg_color;
    317320        fmt.halign = gfx_halign_left;
     
    329332        entry->text[off1] = '\0';
    330333
    331         rc = gfx_puttext(res->font, &pos, &fmt, entry->text);
     334        rc = gfx_puttext(&pos, &fmt, entry->text);
    332335        if (rc != EOK) {
    333336                (void) gfx_set_clip_rect(res->gc, NULL);
     
    335338        }
    336339
    337         gfx_text_cont(res->font, &pos, &fmt, entry->text, &cpos, &cfmt);
     340        gfx_text_cont(&pos, &fmt, entry->text, &cpos, &cfmt);
    338341        entry->text[off1] = c;
    339342
     
    345348                cfmt.color = res->entry_sel_text_fg_color;
    346349
    347                 gfx_text_rect(res->font, &cpos, &cfmt, entry->text + off1, &sel);
     350                gfx_text_rect(&cpos, &cfmt, entry->text + off1, &sel);
    348351                sel.p0.x -= ui_entry_sel_hpad;
    349352                sel.p0.y -= ui_entry_sel_vpad;
     
    359362                        goto error;
    360363
    361                 rc = gfx_puttext(res->font, &cpos, &cfmt, entry->text + off1);
     364                rc = gfx_puttext(&cpos, &cfmt, entry->text + off1);
    362365                if (rc != EOK) {
    363366                        (void) gfx_set_clip_rect(res->gc, NULL);
     
    365368                }
    366369
    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);
    369371
    370372                entry->text[off2] = c;
     
    374376        cfmt.color = res->entry_fg_color;
    375377
    376         rc = gfx_puttext(res->font, &cpos, &cfmt, entry->text + off2);
     378        rc = gfx_puttext(&cpos, &cfmt, entry->text + off2);
    377379        if (rc != EOK) {
    378380                (void) gfx_set_clip_rect(res->gc, NULL);
     
    421423
    422424        gfx_text_fmt_init(&fmt);
     425        fmt.font = res->font;
    423426        fmt.halign = gfx_halign_left;
    424427        fmt.valign = gfx_valign_top;
    425428
    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);
    428430}
    429431
     
    664666                break;
    665667        }
    666 
    667668        return ui_claimed;
    668669}
     
    743744        if (!entry->active)
    744745                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         }
    754746
    755747        /*
     
    768760        if (event->type == KEY_RELEASE && event->key == KC_RSHIFT)
    769761                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        }
    770772
    771773        if (event->type == KEY_PRESS &&
     
    11111113                anchor.y = 0;
    11121114                gfx_text_fmt_init(&fmt);
     1115                fmt.font = res->font;
    11131116                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);
    11161118                entry->scroll_pos = tpos.x - geom.text_rect.p0.x;
    11171119        } else if (geom.text_pos.x + width < geom.text_rect.p1.x &&
Note: See TracChangeset for help on using the changeset viewer.