diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2026-01-24 16:15:47 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2026-01-24 16:15:47 +0100 |
| commit | bd4ad3e4a0c8e3153d9d3b532d9c572f5aaad897 (patch) | |
| tree | 96b18a5bc07c0ee93080676038aaf0d16f7705d9 /src/Fl_Input.cxx | |
| parent | 84b562313216842764dd5b3f9825b3f232c45970 (diff) | |
Let Fl_Text_Editor and Fl_Input handle gracefully composed unicode characters.
Diffstat (limited to 'src/Fl_Input.cxx')
| -rw-r--r-- | src/Fl_Input.cxx | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/Fl_Input.cxx b/src/Fl_Input.cxx index fd66d8f24..bd317ad09 100644 --- a/src/Fl_Input.cxx +++ b/src/Fl_Input.cxx @@ -1,7 +1,7 @@ // // Input widget for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2024 by Bill Spitzak and others. +// Copyright 1998-2026 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -190,14 +190,20 @@ int Fl_Input::kf_delete_eol() { int Fl_Input::kf_delete_char_right() { if (readonly()) { fl_beep(); return 1; } if (mark() != insert_position()) cut(); - else cut(1); + else { + const char *next = fl_utf8_next_composed_char(value() + insert_position(), value() + size()); + replace(insert_position(), next - value(), 0); + } return 1; } int Fl_Input::kf_delete_char_left() { if (readonly()) { fl_beep(); return 1; } if (mark() != insert_position()) cut(); - else cut(-1); + else { + const char *before = fl_utf8_previous_composed_char(value() + insert_position(), value()); + replace(insert_position(), before - value(), 0); + } return 1; } @@ -225,7 +231,8 @@ int Fl_Input::kf_clear_eol() { // If OPTION_ARROW_FOCUS is disabled, return 1 to prevent focus navigation. // int Fl_Input::kf_move_char_left() { - int i = shift_position(insert_position()-1) + NORMAL_INPUT_MOVE; + const char *before = fl_utf8_previous_composed_char(value() + insert_position(), value()); + int i = shift_position(before - value()) + NORMAL_INPUT_MOVE; return Fl::option(Fl::OPTION_ARROW_FOCUS) ? i : 1; } @@ -233,7 +240,8 @@ int Fl_Input::kf_move_char_left() { // If OPTION_ARROW_FOCUS is disabled, return 1 to prevent focus navigation. // int Fl_Input::kf_move_char_right() { - int i = shift_position(insert_position()+1) + NORMAL_INPUT_MOVE; + const char *next = fl_utf8_next_composed_char(value() + insert_position(), value() + size()); + int i = shift_position(next - value()) + NORMAL_INPUT_MOVE; return Fl::option(Fl::OPTION_ARROW_FOCUS) ? i : 1; } |
