aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/sciteco.7.template17
-rw-r--r--sample.teco_ini3
-rw-r--r--src/cmdline.cpp11
-rw-r--r--src/parser.cpp19
-rw-r--r--src/parser.h24
-rw-r--r--src/sciteco.h1
6 files changed, 64 insertions, 11 deletions
diff --git a/doc/sciteco.7.template b/doc/sciteco.7.template
index 2fdcd43..47100e9 100644
--- a/doc/sciteco.7.template
+++ b/doc/sciteco.7.template
@@ -375,6 +375,23 @@ effectively switches between undo and redo modes.
The modifier also influences the behaviour of the TAB key.
T}
T{
+Case insensitive command character
+T};\(em;Any letter;T{
+Beginning of case-insensitive commands
+.br
+(automatic case folding enabled)
+T};T{
+At the beginning of case-insensitive commands,
+the case of letters is inverted.
+One or two letter commands will thus typically
+be inserted in upper case.
+This only happens if bit 3 of the \fBED\fP flags
+is set, e.g. by executing:
+.EX
+0,8ED
+.EE
+T}
+T{
.SCITECO_TOPIC ^J enter LF CR
Insert end of line sequence
T};10;^J, Return, Enter;T{
diff --git a/sample.teco_ini b/sample.teco_ini
index a3ee9c2..9bbefed 100644
--- a/sample.teco_ini
+++ b/sample.teco_ini
@@ -41,6 +41,9 @@ EMQ[$SCITECOPATH]/session.tes
}
0,32ED
+! Uncomment to enable automatic case folding !
+! 0,8ED !
+
! Tweak the default font name and size.
The size unit is 1pt/100 !
! [lexer.font]Monospace 1300U[lexer.font] !
diff --git a/src/cmdline.cpp b/src/cmdline.cpp
index f10da33..daf1a9b 100644
--- a/src/cmdline.cpp
+++ b/src/cmdline.cpp
@@ -614,6 +614,17 @@ State::process_edit_cmd(gchar 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)
{
switch (key) {
diff --git a/src/parser.cpp b/src/parser.cpp
index 42c4c33..fe22560 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -672,7 +672,7 @@ StateExpectFile::done(const gchar *str)
return next;
}
-StateStart::StateStart() : State()
+StateStart::StateStart()
{
transitions['\0'] = this;
init(" \f\r\n\v");
@@ -1648,7 +1648,7 @@ StateStart::custom(gchar chr)
return this;
}
-StateFCommand::StateFCommand() : State()
+StateFCommand::StateFCommand()
{
transitions['\0'] = this;
transitions['K'] = &States::searchkill;
@@ -1842,7 +1842,7 @@ StateChangeDir::got_file(const gchar *filename)
return &States::start;
}
-StateCondCommand::StateCondCommand() : State()
+StateCondCommand::StateCondCommand()
{
transitions['\0'] = this;
}
@@ -1948,7 +1948,7 @@ StateCondCommand::custom(gchar chr)
return &States::start;
}
-StateControl::StateControl() : State()
+StateControl::StateControl()
{
transitions['\0'] = this;
transitions['I'] = &States::insert_indent;
@@ -2183,7 +2183,7 @@ StateEscape::end_of_macro(void)
expressions.discard_args();
}
-StateECommand::StateECommand() : State()
+StateECommand::StateECommand()
{
transitions['\0'] = this;
transitions['%'] = &States::epctcommand;
@@ -2256,6 +2256,15 @@ StateECommand::custom(gchar chr)
* Without any argument ED returns the current flags.
*
* Currently, the following flags are used by \*(ST:
+ * - 8: Enable/disable automatic folding of case-insensitive
+ * command characters during interactive key translation.
+ * The case of letter keys is inverted, so one or two
+ * character commands will typically be inserted upper-case,
+ * but you can still press Shift to insert lower-case letters.
+ * Case-insensitive Q-Register specifications are not
+ * case folded.
+ * This is thought to improve the readability of the command
+ * line macro.
* - 16: Enable/disable automatic translation of end of
* line sequences to and from line feed.
* - 32: Enable/Disable buffer editing hooks
diff --git a/src/parser.h b/src/parser.h
index 56e58c4..f61d335 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -124,6 +124,18 @@ public:
}
};
+/**
+ * Base class of states with case-insenstive input.
+ *
+ * This is meant for states accepting command characters
+ * that can possibly be case-folded.
+ */
+class StateCaseInsensitive : public State {
+protected:
+ /* in cmdline.cpp */
+ void process_edit_cmd(gchar key);
+};
+
template <typename Type>
class MicroStateMachine : public Object {
protected:
@@ -252,7 +264,7 @@ protected:
void process_edit_cmd(gchar key);
};
-class StateStart : public State {
+class StateStart : public StateCaseInsensitive {
public:
StateStart();
@@ -276,7 +288,7 @@ private:
}
};
-class StateControl : public State {
+class StateControl : public StateCaseInsensitive {
public:
StateControl();
@@ -292,7 +304,7 @@ private:
State *custom(gchar chr);
};
-class StateEscape : public State {
+class StateEscape : public StateCaseInsensitive {
public:
StateEscape();
@@ -312,7 +324,7 @@ private:
}
};
-class StateFCommand : public State {
+class StateFCommand : public StateCaseInsensitive {
public:
StateFCommand();
@@ -344,7 +356,7 @@ private:
State *got_file(const gchar *filename);
};
-class StateCondCommand : public State {
+class StateCondCommand : public StateCaseInsensitive {
public:
StateCondCommand();
@@ -352,7 +364,7 @@ private:
State *custom(gchar chr);
};
-class StateECommand : public State {
+class StateECommand : public StateCaseInsensitive {
public:
StateECommand();
diff --git a/src/sciteco.h b/src/sciteco.h
index bc2e58c..b856210 100644
--- a/src/sciteco.h
+++ b/src/sciteco.h
@@ -39,6 +39,7 @@ typedef tecoInt tecoBool;
namespace Flags {
enum {
+ ED_AUTOCASEFOLD = (1 << 3),
ED_AUTOEOL = (1 << 4),
ED_HOOKS = (1 << 5),
ED_FNKEYS = (1 << 6),