From ba22b1a307988fd493fc682daff20eee4c325451 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 16 Feb 2014 13:35:40 +0100 Subject: updated minimum required Scintilla version to v3.3.7 / Scinterm v1.2 * allows us to remove most patches. One however is still necessary (Scinterm Makefile bug!) * TECO-style control code echoing is now set up using the SCI_SETREPRESENTATION message * updated copyrights * updated TODO --- src/document.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index a7276f0..c01bd4c 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -28,6 +28,32 @@ #include "undo.h" #include "document.h" +static inline void +set_representations(void) +{ + static const char *reps[] = { + "^@", "^A", "^B", "^C", "^D", "^E", "^F", "^G", + "^H", "TAB" /* ^I */, "LF" /* ^J */, "^K", "^L", "CR" /* ^M */, "^N", "^O", + "^P", "^Q", "^R", "^S", "^T", "^U", "^V", "^W", + "^X", "^Y", "^Z", "$" /* ^[ */, "^\\", "^]", "^^", "^_" + }; + + for (guint cc = 0; cc < G_N_ELEMENTS(reps); cc++) { + gchar buf[] = {(gchar)cc, '\0'}; + interface.ssm(SCI_SETREPRESENTATION, + (uptr_t)buf, (sptr_t)reps[cc]); + } +} + +class UndoSetRepresentations : public UndoToken { +public: + void + run(void) + { + set_representations(); + } +}; + void TECODocument::edit(void) { @@ -38,11 +64,24 @@ TECODocument::edit(void) interface.ssm(SCI_SETFIRSTVISIBLELINE, first_line); interface.ssm(SCI_SETXOFFSET, xoffset); interface.ssm(SCI_SETSEL, anchor, (sptr_t)dot); + + /* + * Default TECO-style character representations. + * They are reset on EVERY SETDOCPOINTER call by Scintilla. + */ + set_representations(); } void TECODocument::undo_edit(void) { + /* + * see above: set TECO-style character representations + * NOTE: could be done with push_msg() but that requires + * making the entire mapping static constant + */ + undo.push(new UndoSetRepresentations()); + undo.push_msg(SCI_SETSEL, anchor, (sptr_t)dot); undo.push_msg(SCI_SETXOFFSET, xoffset); undo.push_msg(SCI_SETFIRSTVISIBLELINE, first_line); -- cgit v1.2.3