From 90baf34034af9363ee4cfa1654a8cc72dfc8c62e Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 25 Mar 2017 06:47:10 +0100 Subject: 0,8ED: Automatic case-folding of commands * when enabled, it will automatically upper-case all one or two letter commands (which are case insensitive). * also affects the up-carret control commands, so they when inserted they look more like real control commands. * specifically does not affect case-insensitive Q-Register specifications * the result are command lines that are better readable and conform to the coding style used in SciTECO's standard library. This eases reusing command lines as well. * Consequently, string-building and pattern match characters should be case-folded as well, but they aren't currently since State::process_edit_cmd() does not have sufficient insight into the MicroStateMachines. Also, it could not be delegated to the MicroStateMachines. Perhaps they should be abandoned in favour of embeddedable regular state machines; or regular state machines with a stack of return states? --- src/cmdline.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/cmdline.cpp') diff --git a/src/cmdline.cpp b/src/cmdline.cpp index f10da33..daf1a9b 100644 --- a/src/cmdline.cpp +++ b/src/cmdline.cpp @@ -613,6 +613,17 @@ State::process_edit_cmd(gchar key) cmdline.insert(key); } +void +StateCaseInsensitive::process_edit_cmd(gchar key) +{ + if (Flags::ed & Flags::ED_AUTOCASEFOLD) + /* will not modify non-letter keys */ + key = g_ascii_islower(key) ? g_ascii_toupper(key) + : g_ascii_tolower(key); + + State::process_edit_cmd(key); +} + void StateExpectString::process_edit_cmd(gchar key) { -- cgit v1.2.3