Skip to content
Myr

Merge branch 'old_textedit' into working

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Conflicts: stb_textedit.h

authored by Sean Barrett · committed by Sean Barrett · parents b1a0089, d052909 · Browse files · 1 file+22 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+22 added−1 removed

  • other:+22 added−1 removed

1 file+22 added−1 removed

modified:stb_textedit.h+22 added-1 removed
441 unmodified lines
442443// API click: on mouse down, move the cursor to the clicked location, and reset the selection444static void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)445{446 // In single-line mode, just always make y = 0. This lets the drag keep working if the mouse447 // goes off the top or bottom of the text448 if( state->single_line )449 {450 StbTexteditRow r;451 STB_TEXTEDIT_LAYOUTROW(&r, str, 0);452 y = r.ymin;453 }454455 state->cursor = stb_text_locate_coord(str, x, y);456 state->select_start = state->cursor;457 state->select_end = state->cursor;458 state->has_preferred_x = 0;
1 unmodified line
460461// API drag: on mouse drag, move the cursor and selection endpoint to the clicked location462static void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y)463{455 int p = stb_text_locate_coord(str, x, y);464 int p = 0;465466 // In single-line mode, just always make y = 0. This lets the drag keep working if the mouse467 // goes off the top or bottom of the text468 if( state->single_line )469 {470 StbTexteditRow r;471 STB_TEXTEDIT_LAYOUTROW(&r, str, 0);472 y = r.ymin;473 }474475 if (state->select_start == state->select_end)476 state->select_start = state->cursor;477478 p = stb_text_locate_coord(str, x, y);479 state->cursor = state->select_end = p;480}481482/////////////////////////////////////////////////////////////////////////////
909 unmodified lines