aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-19 21:02:23 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-20 06:07:33 +0100
commit3db5b1a40bf6b503b26827355f40033b1047a123 (patch)
treeb0689d9f880b85c79485a2632b5a2e0c19284cbe
parent6403c951636a24f31368e91da2439c4fb47ff4c3 (diff)
downloadsciteco-3db5b1a40bf6b503b26827355f40033b1047a123.tar.gz
disable ^U string building characters (by default)
some method to reenable it will be developed in the future (perhaps using a separate command, or a special modifier which reverses a string commands default handling of building character)
-rw-r--r--parser.cpp30
-rw-r--r--parser.h5
-rw-r--r--qbuffers.h2
-rwxr-xr-xteco.ini10
4 files changed, 28 insertions, 19 deletions
diff --git a/parser.cpp b/parser.cpp
index 4ba029b..b75e3bf 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -247,7 +247,7 @@ original:
State *
StateExpectString::custom(gchar chr) throw (Error)
{
- gchar *insert, *new_str;
+ gchar *insert;
if (chr == '\0') {
BEGIN_EXEC(this);
@@ -275,13 +275,15 @@ StateExpectString::custom(gchar chr) throw (Error)
State *next = done(string ? : "");
g_free(string);
- undo.push_var<gchar>(escape_char);
+ undo.push_var(escape_char);
escape_char = '\x1B';
- undo.push_var<Machine>(machine);
- machine.state = Machine::STATE_START;
- machine.mode = Machine::MODE_NORMAL;
- machine.toctl = false;
+ if (string_building) {
+ undo.push_var(machine);
+ machine.state = Machine::STATE_START;
+ machine.mode = Machine::MODE_NORMAL;
+ machine.toctl = false;
+ }
return next;
}
@@ -291,18 +293,20 @@ StateExpectString::custom(gchar chr) throw (Error)
/*
* String building characters
*/
- undo.push_var<Machine>(machine);
- insert = machine_input(chr);
- if (!insert)
- return this;
+ if (string_building) {
+ undo.push_var(machine);
+ insert = machine_input(chr);
+ if (!insert)
+ return this;
+ } else {
+ insert = g_strdup((gchar []){chr, '\0'});
+ }
/*
* String accumulation
*/
undo.push_str(strings[0]);
- new_str = g_strconcat(strings[0] ? : "", insert, NULL);
- g_free(strings[0]);
- strings[0] = new_str;
+ String::append(strings[0], insert);
process(strings[0], strlen(insert));
g_free(insert);
diff --git a/parser.h b/parser.h
index 3047c50..ba3a632 100644
--- a/parser.h
+++ b/parser.h
@@ -110,8 +110,11 @@ class StateExpectString : public State {
mode(MODE_NORMAL), toctl(false) {}
} machine;
+ bool string_building;
+
public:
- StateExpectString() : State() {}
+ StateExpectString(bool _building = true)
+ : State(), string_building(_building) {}
private:
gchar *machine_input(gchar key) throw (Error);
diff --git a/qbuffers.h b/qbuffers.h
index a6d016c..ce2645c 100644
--- a/qbuffers.h
+++ b/qbuffers.h
@@ -411,6 +411,8 @@ private:
};
class StateSetQRegString : public StateExpectString {
+public:
+ StateSetQRegString() : StateExpectString(false) {}
private:
State *done(const gchar *str) throw (Error);
};
diff --git a/teco.ini b/teco.ini
index a64bf6b..e7c1a42 100755
--- a/teco.ini
+++ b/teco.ini
@@ -6,13 +6,13 @@
Oadd,edit,close,quit
!add! [f[r[0[1[2
- f^QQ* EQf
+ EQ* HXf EQf
r
U2U1U0 (Q0*256 + Q1)*256 + Q2
- ZJ -:S.^Q[cpp,c,h]"S Z-."=
- EB^QQf
+ ZJ -:S.[cpp,c,h]"S Z-."=
+ EBQf
3,4001ES
0,4005ESbreak case continue default do else for goto if return switch while
0,255,0Mr,0,2051ES
@@ -23,13 +23,13 @@
''
ZJ -:Smakefile"S Z-."=
- EB^QQf
+ EBQf
11,4001ES
0,255,0Mr,1,2051ES
Oadd.end
''
- EB^QQf
+ EBQf
!add.end!
]2]1]0]r]f Oend