From a4258d3884f1a2de4d2993a7184bba1738133e1e Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 16 Nov 2015 01:20:59 +0800 Subject: [PATCH] fix a selection text issue of text_editor with pressing shift --- include/nana/gui/basis.hpp | 4 +++- source/gui/detail/linux_X11/bedrock.cpp | 6 +++--- source/gui/widgets/skeletons/text_editor.cpp | 10 +++------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/include/nana/gui/basis.hpp b/include/nana/gui/basis.hpp index 789ab5c3..26ca8885 100644 --- a/include/nana/gui/basis.hpp +++ b/include/nana/gui/basis.hpp @@ -77,8 +77,8 @@ namespace nana start_of_headline = 0x1, //Ctrl+A end_of_text = 0x3, //Ctrl+C backspace = 0x8, tab = 0x9, - enter_n = 0xA, enter = 0xD, enter_r = 0xD, alt = 0x12, + enter_n = 0xA, enter = 0xD, enter_r = 0xD, sync_idel = 0x16, //Ctrl+V cancel = 0x18, //Ctrl+X end_of_medium = 0x19, //Ctrl+Y @@ -95,6 +95,8 @@ namespace nana undo = substitute, //System Code for OS + os_shift = 0x10, + os_ctrl = 0x11, os_pageup = 0x21, os_pagedown, os_arrow_left = 0x25, os_arrow_up, os_arrow_right, os_arrow_down, os_insert = 0x2D, os_del , diff --git a/source/gui/detail/linux_X11/bedrock.cpp b/source/gui/detail/linux_X11/bedrock.cpp index dd595282..2bcf5715 100644 --- a/source/gui/detail/linux_X11/bedrock.cpp +++ b/source/gui/detail/linux_X11/bedrock.cpp @@ -596,9 +596,9 @@ namespace detail case XK_Delete: keysym = keyboard::os_del; break; case XK_Shift_L: case XK_Shift_R: //shift - keysym = 0x10; break; + keysym = keyboard::os_shift; break; case XK_Control_L: case XK_Control_R: //ctrl - keysym = 0x11; break; + keysym = keyboard::os_ctrl; break; default: do { @@ -1064,7 +1064,7 @@ namespace detail } else { - if(0x11 == os_code) + if(keyboard::os_ctrl == os_code) context.is_ctrl_pressed = true; arg_keyboard arg; diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index ff044b4d..6a0ab074 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -1421,12 +1421,6 @@ namespace nana{ namespace widgets char_type key = arg.key; switch (key) { -#if 0 - case keyboard::os_arrow_left: move_left(); break; - case keyboard::os_arrow_right: move_right(); break; - case keyboard::os_arrow_up: move_ns(true); break; - case keyboard::os_arrow_down: move_ns(false); break; -#else case keyboard::os_arrow_left: case keyboard::os_arrow_right: case keyboard::os_arrow_up: @@ -1437,7 +1431,6 @@ namespace nana{ namespace widgets case keyboard::os_pagedown: _handle_move_key(arg); break; -#endif case keyboard::os_del: if (this->attr().editable) del(); @@ -2328,6 +2321,9 @@ namespace nana{ namespace widgets void text_editor::_handle_move_key(const arg_keyboard& arg) { + if (arg.shift && (select_.a == select_.b)) + select_.a = select_.b = points_.caret; + bool changed = false; nana::upoint caret = points_.caret; char_t key = arg.key;