Compare commits
3 Commits
7c0e8257f7
...
67219834be
Author | SHA1 | Date |
---|---|---|
Lephenixnoir | 67219834be | |
Lephenixnoir | 2e15bb8c96 | |
Lephenixnoir | 5b591a6fb4 |
|
@ -18,7 +18,7 @@
|
|||
an indicator displays the status of modifier keys.
|
||||
|
||||
The edition rules support both the OS' native one-key-at-time input system,
|
||||
and the usual computer modifer-keys-held method.
|
||||
and the usual computer modifier-keys-held method.
|
||||
|
||||
* The normal insertion mode is used by default.
|
||||
* When pressing SHIFT or ALPHA in combination with a key (without releasing
|
||||
|
|
|
@ -85,9 +85,9 @@ void jinput_set_prompt(jinput *i, char const *prompt)
|
|||
|
||||
static void insert_str(jinput *i, char const *str, size_t n)
|
||||
{
|
||||
if(i->size + n > i->max) return;
|
||||
if(i->size + n > i->max || i->cursor < 0) return;
|
||||
|
||||
/* Insert at cursor_pos, shift everything else right n places */
|
||||
/* Insert at i->cursor, shift everything else right n places */
|
||||
for(int k = i->size - 1; k >= i->cursor; k--)
|
||||
i->text[k + n] = i->text[k];
|
||||
|
||||
|
@ -131,7 +131,7 @@ static void insert_code_point(jinput *i, uint32_t p)
|
|||
|
||||
static int previous(char const *str, int position)
|
||||
{
|
||||
if(position == 0)
|
||||
if(position <= 0)
|
||||
return position;
|
||||
|
||||
while((str[--position] & 0xc0) == 0x80) {}
|
||||
|
@ -148,6 +148,7 @@ static int next(char const *str, int position)
|
|||
|
||||
static void delete(jinput *i)
|
||||
{
|
||||
if(i->cursor < 0) return;
|
||||
int prev = previous(i->text, i->cursor);
|
||||
int diff = i->cursor - prev;
|
||||
if(!diff) return;
|
||||
|
|
10
src/jscene.c
10
src/jscene.c
|
@ -128,13 +128,13 @@ void jscene_set_focused_widget(jscene *s, void *w0)
|
|||
}
|
||||
|
||||
/* Focus out old focused widget */
|
||||
if(s->focus) jscene_queue_event(s,
|
||||
if(s->focus) jwidget_event(s->focus,
|
||||
(jevent){ .type = JWIDGET_FOCUS_OUT, .source = s->focus });
|
||||
|
||||
s->focus = w;
|
||||
|
||||
/* Focus in newly-selected widget */
|
||||
if(w) jscene_queue_event(s,
|
||||
if(w) jwidget_event(w,
|
||||
(jevent){ .type = JWIDGET_FOCUS_IN, .source = w });
|
||||
}
|
||||
|
||||
|
@ -231,12 +231,18 @@ jevent jscene_run(jscene *s)
|
|||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
getkey_feature_t feat = getkey_feature_function();
|
||||
if((k.type == KEYEV_DOWN || k.type == KEYEV_HOLD) && feat && feat(k))
|
||||
continue;
|
||||
|
||||
if(k.type != KEYEV_NONE && !jscene_process_key_event(s, k)) {
|
||||
e.type = JWIDGET_KEY;
|
||||
e.key = k;
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: Should only sleep when out of events!
|
||||
sleep();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue