aboutsummaryrefslogtreecommitdiffhomepage
path: root/parser.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-13 21:20:14 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-13 21:20:14 +0100
commit074c64232f8be3bc34b40a9d5e92f28e6aa922fb (patch)
treef0948519ada216f2a06b37c2db60896d8b7161de /parser.cpp
parent20a7660a43c03578fb65f898471a6b479d04f57e (diff)
downloadsciteco-074c64232f8be3bc34b40a9d5e92f28e6aa922fb.tar.gz
<n>W, <n>V, <n>Y commands
based on Scintilla editor key commands, so they will automatically adopt to Scintilla setting changes
Diffstat (limited to 'parser.cpp')
-rw-r--r--parser.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/parser.cpp b/parser.cpp
index d6bee1c..296763c 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -358,6 +358,32 @@ StateStart::move_lines(gint64 n)
undo.push_msg(SCI_GOTOPOS, pos);
}
+void
+StateStart::delete_words(gint64 n)
+{
+ if (!n)
+ return;
+
+ undo.push_msg(SCI_UNDO);
+ editor_msg(SCI_BEGINUNDOACTION);
+ /*
+ * FIXME: would be nice to do this with constant amount of
+ * editor messages. E.g. by using custom algorithm accessing
+ * the internal document buffer.
+ */
+ if (n > 0) {
+ while (n--)
+ editor_msg(SCI_DELWORDRIGHTEND);
+ } else {
+ while (n++) {
+ //editor_msg(SCI_DELWORDLEFTEND);
+ editor_msg(SCI_WORDLEFTEND);
+ editor_msg(SCI_DELWORDRIGHTEND);
+ }
+ }
+ editor_msg(SCI_ENDUNDOACTION);
+}
+
State *
StateStart::custom(gchar chr)
{
@@ -609,6 +635,36 @@ StateStart::custom(gchar chr)
move_lines(-expressions.pop_num_calc());
break;
+ case 'W': {
+ BEGIN_EXEC(this);
+ gint64 words = expressions.pop_num_calc();
+
+ undo.push_msg(SCI_GOTOPOS, editor_msg(SCI_GETCURRENTPOS));
+ /*
+ * FIXME: would be nice to do this with constant amount of
+ * editor messages. E.g. by using custom algorithm accessing
+ * the internal document buffer.
+ */
+ if (words >= 0) {
+ while (words--)
+ editor_msg(SCI_WORDRIGHTEND);
+ } else {
+ while (words++)
+ editor_msg(SCI_WORDLEFTEND);
+ }
+ break;
+ }
+
+ case 'V':
+ BEGIN_EXEC(this);
+ delete_words(expressions.pop_num_calc());
+ break;
+
+ case 'Y':
+ BEGIN_EXEC(this);
+ delete_words(-expressions.pop_num_calc());
+ break;
+
case '=':
BEGIN_EXEC(this);
message_display(GTK_MESSAGE_OTHER, "%" G_GINT64_FORMAT,