commit fb1d8910f60af9f3a010a4bd6566a3b6f8a73a4a
parent a9d876ca6180454418dc257ff8e1a3556345a812
Author: Dimitris Zervas <dzervas@dzervas.gr>
Date: Wed, 9 Jul 2014 03:13:44 +0300
Removed some garbage...
Diffstat:
2 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/config.h b/config.h
@@ -3,6 +3,7 @@
#define HILIGHT_SYNTAX 1
#define SHOW_NONPRINT 0
#define HANDLE_MOUSE 1
+#define VIM_BINDINGS 1
/* Things unlikely to be changed, yet still in the config.h file */
static const bool isutf8 = TRUE;
@@ -92,7 +93,6 @@ static const Key curskeys[] = { /* Plain keys here, no CONTROL or META */
{ .keyv.i = KEY_RIGHT, { 0, 0, 0, 0 }, f_moveboth, { .m = m_nextchar } },
{ .keyv.i = KEY_SLEFT, { 0, 0, 0, 0 }, f_moveboth, { .m = m_prevword } },
{ .keyv.i = KEY_SRIGHT, { 0, 0, 0, 0 }, f_moveboth, { .m = m_nextword } },
-//{ .keyv.i = KEY_ESC, { t_nocomm,0, 0, 0 }, f_toggle, { .i = S_Command } },
};
static const Key stdkeys[] = {
@@ -147,9 +147,11 @@ static const Key stdkeys[] = {
{ .keyv.c = CONTROL('X'), { t_mod, t_rw, 0, 0 }, f_save, { 0 } },
{ .keyv.c = CONTROL('X'), { 0, 0, 0, 0 }, f_toggle, { .i = S_Running } },
{ .keyv.c = META('x'), { 0, 0, 0, 0 }, f_spawn, CMD_P },
-//{ .keyv.c = CONTROL('Y'), { t_rw, 0, 0, 0 }, f_pipenull, FROMCLIP },
+{ .keyv.c = CONTROL('Y'), { t_rw, 0, 0, 0 }, f_pipenull, FROMCLIP },
{ .keyv.c = CONTROL('Z'), { 0 ,0, 0, 0 }, f_suspend, { 0 } },
-{ .keyv.c = CONTROL('['), { 0, 0, 0, 0 }, f_spawn, CMD_P },
+#if VIM_BINDINGS
+{ .keyv.c = CONTROL('['), { t_nocomm,0, 0, 0 }, f_toggle, { .i = S_Command } },
+#endif
{ .keyv.c = CONTROL('\\'),{ t_rw, 0, 0, 0 }, f_spawn, PIPE },
{ .keyv.c = META('\\'), { t_rw, 0, 0, 0 }, f_spawn, SED },
{ .keyv.c = CONTROL(']'), { 0, 0, 0, 0 }, f_extsel, { .i = ExtDefault } },
@@ -161,14 +163,15 @@ static const Key stdkeys[] = {
{ .keyv.c = CONTROL('?'), { t_rw, 0, 0, 0 }, f_delete, { .m = m_prevchar } },
{ .keyv.c = META(','), { 0, 0, 0, 0 }, f_move, { .m = m_bof } },
{ .keyv.c = META('.'), { 0, 0, 0, 0 }, f_move, { .m = m_eof } },
-{ .keyv.c = CONTROL('Y'), { t_nocomm,0, 0, 0 }, f_toggle, { .i = S_Command } },
};
+#if VIM_BINDINGS
static const Key commkeys[] = { /* Command mode keys here */
/* keyv.c, tests, func, arg */
{ .keyv.c = { 'i' }, { 0, 0, 0, 0 }, f_toggle, { .i = S_Command } },
{ .keyv.c = { ':' }, { 0, 0, 0, 0 }, f_spawn, CMD_P },
};
+#endif
#if HANDLE_MOUSE
/*Mouse clicks */
diff --git a/sandy.c b/sandy.c
@@ -137,9 +137,7 @@ enum { /* To use in statusflags */
S_GroupUndo = 1<<9, /* Last action was an insert, so another insert should group with it, set automatically */
S_AutoIndent = 1<<10, /* Perform autoindenting on RET */
S_DumpStdout = 1<<11, /* Dump to stdout instead of writing to a file */
-//#if COMMAND_MODE
S_Command = 1<<12, /* Command mode */
-//#endif
};
enum { /* To use in Undo.flags */
@@ -246,7 +244,6 @@ static bool i_writefile(char*);
/* t_* functions to know whether to process an action or keybinding */
static bool t_ai(void);
static bool t_bol(void);
-//static bool t_comm(void);
static bool t_eol(void);
static bool t_mod(void);
static bool t_nocomm(void);
@@ -821,11 +818,11 @@ i_edit(void) {
continue;
}
statusflags&=~(S_InsEsc);
-//#if COMMAND_MODE
+#if VIM_BINDINGS
if(t_rw() && t_nocomm()) f_insert(&(const Arg){ .v = c });
-/*#else
+#else
if(t_rw()) f_insert(&(const Arg){ .v = c });
-#endif*/
+#endif
else if(!t_rw()) tmptitle="WARNING! File is read-only!!!";
else {
for(i=0; i<LENGTH(commkeys); i++) {
@@ -1456,8 +1453,12 @@ i_update(void) {
else {
statusflags&=~S_Warned; /* Reset warning */
snprintf(buf, 4, "%ld%%", (100*ncur)/nlst);
+#if VIM_BINDINGS
snprintf(title, BUFSIZ, "%s %s [%s]%s%s%s%s %ld,%d %s",
(t_nocomm()?"Insert":"Command"),
+#else
+ snprintf(title, BUFSIZ, "%s [%s]%s%s%s%s %ld,%d %s",
+#endif
(statusflags&S_DumpStdout?"<Stdout>":(filename == NULL?"<No file>":filename)),
(syntx>=0 ? syntaxes[syntx].name : "none"),
(t_mod()?"[+]":""),
@@ -1694,11 +1695,6 @@ t_bol(void) {
return (fcur.o == 0);
}
-//bool /* TRUE if we are in command mode */
-//t_comm(void) {
-// return (statusflags & S_Command);
-//}
-
bool /* TRUE at end of line */
t_eol(void) {
return (fcur.o == fcur.l->len);
@@ -1709,10 +1705,12 @@ t_mod(void) {
return (statusflags & S_Modified);
}
-bool /* TRUE if we are not in command mode FIXME: Find a way to use t_comm */
+#if VIM_BINDINGS
+bool /* TRUE if we are not in command mode */
t_nocomm(void) {
return !(statusflags & S_Command);
}
+#endif
bool /* TRUE if the file is writable */
t_rw(void) {
@@ -1747,6 +1745,7 @@ main(int argc, char **argv){
/* Use system locale, hopefully UTF-8 */
setlocale(LC_ALL,"");
+ statusflags|=S_Command;
for(i = 1; i < argc && argv[i][0] == '-' && argv[i][1] != '\0'; i++) {
if(!strcmp(argv[i], "-r")) {