aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-19 15:42:33 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-20 06:07:32 +0100
commit39cb3b36cbac59c938acf6b71cbb3087f0fca5b4 (patch)
treebd362fd25dcf3ce954c4af877a05fcb5d8ef1d73
parent9d8b90f654b5777f5c9d402fda445088f9fe374f (diff)
downloadsciteco-39cb3b36cbac59c938acf6b71cbb3087f0fca5b4.tar.gz
ED flags making 0-Register hook execution configurable
* teco.ini updated as well
-rw-r--r--main.cpp4
-rw-r--r--parser.cpp14
-rw-r--r--qbuffers.cpp22
-rw-r--r--qbuffers.h8
-rw-r--r--sciteco.h8
-rwxr-xr-x[-rw-r--r--]teco.ini48
6 files changed, 95 insertions, 9 deletions
diff --git a/main.cpp b/main.cpp
index f002a03..e186171 100644
--- a/main.cpp
+++ b/main.cpp
@@ -19,6 +19,10 @@
#define INI_FILE ".teco_ini"
+namespace Flags {
+ gint64 ed = 0;
+}
+
static gchar *mung_file = NULL;
void
diff --git a/parser.cpp b/parser.cpp
index cfeebd0..6c73d3e 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -1075,6 +1075,20 @@ StateECommand::custom(gchar chr) throw (Error)
ring.close();
break;
+ case 'D':
+ BEGIN_EXEC(&States::start);
+ expressions.eval();
+ if (!expressions.args()) {
+ expressions.push(Flags::ed);
+ } else {
+ gint64 on = expressions.pop_num_calc();
+ gint64 off = expressions.pop_num_calc(1, ~(gint64)0);
+
+ undo.push_var(Flags::ed);
+ Flags::ed = (Flags::ed & ~off) | on;
+ }
+ break;
+
case 'X':
BEGIN_EXEC(&States::start);
diff --git a/qbuffers.cpp b/qbuffers.cpp
index 61eacd3..0711438 100644
--- a/qbuffers.cpp
+++ b/qbuffers.cpp
@@ -227,6 +227,16 @@ QRegisterTable::edit(QRegister *reg)
current = reg;
}
+void
+execute_hook(Hook type)
+{
+ if (!(Flags::ed & Flags::ED_HOOKS))
+ return;
+
+ expressions.push(type);
+ qregisters["0"]->execute();
+}
+
bool
Buffer::load(const gchar *filename)
{
@@ -338,6 +348,8 @@ Ring::edit(const gchar *filename)
if (buffer) {
current = buffer;
buffer->edit();
+
+ execute_hook(HOOK_EDIT);
} else {
new_in_ring = true;
@@ -363,13 +375,9 @@ Ring::edit(const gchar *filename)
interface.msg(Interface::MSG_INFO,
"Added new unnamed file to ring.");
}
- }
- /*
- * Execute file load hook
- * FIXME: should be configurable whether it is executed or not
- */
- qregisters["0"]->execute();
+ execute_hook(HOOK_ADD);
+ }
return new_in_ring;
}
@@ -519,7 +527,7 @@ Ring::close(void)
if (current) {
current->edit();
- qregisters["0"]->execute();
+ execute_hook(HOOK_EDIT);
} else {
edit(NULL);
undo_close();
diff --git a/qbuffers.h b/qbuffers.h
index 7f3751b..c2bb8ab 100644
--- a/qbuffers.h
+++ b/qbuffers.h
@@ -383,4 +383,12 @@ namespace States {
extern StateCopyToQReg copytoqreg;
}
+enum Hook {
+ HOOK_ADD = 1,
+ HOOK_EDIT,
+ HOOK_CLOSE,
+ HOOL_QUIT
+};
+void execute_hook(Hook type);
+
#endif
diff --git a/sciteco.h b/sciteco.h
index 078e8d9..fca4434 100644
--- a/sciteco.h
+++ b/sciteco.h
@@ -10,6 +10,14 @@
#define PACKAGE_NAME "SciTECO"
#define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION
+namespace Flags {
+ enum {
+ ED_HOOKS = (1 << 5)
+ };
+
+ extern gint64 ed;
+}
+
extern gchar *cmdline;
extern bool quit_requested;
diff --git a/teco.ini b/teco.ini
index 5a1a43a..a104968 100644..100755
--- a/teco.ini
+++ b/teco.ini
@@ -1,5 +1,49 @@
+#!./sciteco -m
+
! TECO.INI !
+@R/
+ U3U2U1
+ (Q1*256 + Q2)*256 + Q3
+/
+
+@0/
+ @O"add,edit,close,quit"
+
+!add!
+ f^QQ* EQf
+
+ ZJ -:@S".^Q^E[cpp,c,h]""S Z-."= @EB"^Q^EQf"
+ 3,4001ES^[
+ 0,4005@ES"break case continue default do else for goto if return switch while"^[
+ 0,255,0MR,0,2051@ES""^[
+ 0,255,0MR,1,2051ES^[ 0,255,0MR,2,2051ES^[
+ 255,255,0MR,4,2051ES^[ 255,0,0MR,5,2051ES^[
+ 255,0,255MR,6,2051ES^[
+ Oend
+ ''
+
+ ZJ -:Smakefile"S Z-."= @EB"^Q^EQf"
+ 11,4001ES^[
+ 0,255,0MR,1,2051ES^[
+ Oend
+ ''
+
+ @EB"^Q^EQf"
+ @O"end"
+
+!edit!
+ @O"end"
+
+!close!
+ @O"end"
+
+!quit!
+ ! fall through !
+
+!end!/
+ED#32ED
+
! open all files specified on the commandline !
-<:l;r 0x0 ebQ0 eb l>
--ef \ No newline at end of file
+<:L;R 0Xf EBQf EB L>
+-EF