diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-13 21:20:14 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-13 21:20:14 +0100 |
commit | 074c64232f8be3bc34b40a9d5e92f28e6aa922fb (patch) | |
tree | f0948519ada216f2a06b37c2db60896d8b7161de | |
parent | 20a7660a43c03578fb65f898471a6b479d04f57e (diff) | |
download | sciteco-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
-rw-r--r-- | parser.cpp | 56 | ||||
-rw-r--r-- | parser.h | 1 |
2 files changed, 57 insertions, 0 deletions
@@ -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, @@ -108,6 +108,7 @@ public: private: void move(gint64 n); void move_lines(gint64 n); + void delete_words(gint64 n); State *custom(gchar chr); }; |