aboutsummaryrefslogtreecommitdiffhomepage
path: root/parser.cpp
diff options
context:
space:
mode:
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,