diff options
-rw-r--r-- | main.cpp | 8 | ||||
-rw-r--r-- | parser.cpp | 16 | ||||
-rw-r--r-- | qbuffers.cpp | 63 | ||||
-rw-r--r-- | qbuffers.h | 2 |
4 files changed, 57 insertions, 32 deletions
@@ -102,19 +102,13 @@ main(int argc, char **argv) interface.ssm(SCI_SETCARETFORE, 0xFFFFFF); /* - * FIXME: Styles should probably be set interface-based + * FIXME: Default styles should probably be set interface-based * (system defaults) and be changeable by TECO macros */ interface.ssm(SCI_STYLESETFORE, STYLE_DEFAULT, 0xFFFFFF); interface.ssm(SCI_STYLESETBACK, STYLE_DEFAULT, 0x000000); interface.ssm(SCI_STYLESETFONT, STYLE_DEFAULT, (sptr_t)"Courier"); interface.ssm(SCI_STYLECLEARALL); - interface.ssm(SCI_STYLESETFORE, SCE_C_COMMENT, 0x00FF00); - interface.ssm(SCI_STYLESETFORE, SCE_C_COMMENTLINE, 0x00FF00); - interface.ssm(SCI_STYLESETFORE, SCE_C_NUMBER, 0xFFFF00); - interface.ssm(SCI_STYLESETFORE, SCE_C_WORD, 0xFF0000); - interface.ssm(SCI_STYLESETFORE, SCE_C_STRING, 0xFF00FF); - interface.ssm(SCI_STYLESETBOLD, SCE_C_OPERATOR, TRUE); qregisters.initialize(); ring.edit(NULL); @@ -13,7 +13,7 @@ #include "qbuffers.h" #include "parser.h" -//#define DEBUG +#define DEBUG gint macro_pc = 0; @@ -1071,6 +1071,20 @@ StateECommand::custom(gchar chr) throw (Error) ring.close(); break; + case 'S': { + BEGIN_EXEC(&States::start); + expressions.eval(); + if (!expressions.args()) + throw Error("<ES> command requires at least a message code"); + + unsigned int iMessage = expressions.pop_num_calc(1, 0); + uptr_t wParam = expressions.pop_num_calc(1, 0); + sptr_t lParam = expressions.pop_num_calc(1, 0); + + expressions.push(interface.ssm(iMessage, wParam, lParam)); + break; + } + case 'X': BEGIN_EXEC(&States::start); diff --git a/qbuffers.cpp b/qbuffers.cpp index c8a43ba..356823b 100644 --- a/qbuffers.cpp +++ b/qbuffers.cpp @@ -123,6 +123,38 @@ QRegister::undo_edit(void) undo.push_msg(SCI_SETDOCPOINTER, 0, (sptr_t)get_document()); } +void +QRegister::execute(void) throw (State::Error) +{ + State *parent_state = States::current; + gint parent_pc = macro_pc; + gchar *str; + + /* + * need this to fixup state on rubout: state machine emits undo token + * resetting state to parent's one, but the macro executed also emitted + * undo tokens resetting the state to StateStart + */ + undo.push_var(States::current); + States::current = &States::start; + + macro_pc = 0; + str = get_string(); + + try { + macro_execute(str); + } catch (...) { + g_free(str); + macro_pc = parent_pc; + States::current = parent_state; + throw; /* forward */ + } + + g_free(str); + macro_pc = parent_pc; + States::current = parent_state; +} + bool QRegister::load(const gchar *filename) { @@ -333,6 +365,12 @@ Ring::edit(const gchar *filename) } } + /* + * Execute file load hook + * FIXME: should be configurable whether it is executed or not + */ + //qregisters["0"]->execute(); + return new_in_ring; } @@ -704,32 +742,9 @@ StateIncreaseQReg::got_register(QRegister *reg) throw (Error) State * StateMacro::got_register(QRegister *reg) throw (Error) { - gint pc = macro_pc; - gchar *str; - BEGIN_EXEC(&States::start); - /* - * need this to fixup state on rubout: state machine emits undo token - * resetting state to StateMacro, but the macro executed also emitted - * undo tokens resetting the state to StateStart - */ - undo.push_var<State*>(States::current); - States::current = &States::start; - - macro_pc = 0; - str = reg->get_string(); - try { - macro_execute(str); - } catch (...) { - g_free(str); - macro_pc = pc; - States::current = this; - throw; /* forward */ - } - g_free(str); - macro_pc = pc; - States::current = this; + reg->execute(); return &States::start; } @@ -70,6 +70,8 @@ public: virtual void edit(void); virtual void undo_edit(void); + void execute(void) throw (State::Error); + bool load(const gchar *filename); inline void undo_load(void) |