summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandmarti1424 <scim.spreadsheet@gmail.com>2015-02-21 16:54:20 -0300
committerandmarti1424 <scim.spreadsheet@gmail.com>2015-02-21 16:54:20 -0300
commit679db233be0b4a22846400c4bb3fe089f8571d67 (patch)
tree24e077fcf3c8f4786f23df05f426ed6804d9058c
parente6e90f43c674e77ceb7ce5345ef03cefd6ccbc87 (diff)
Change in history
-rw-r--r--src/cmds_command.c16
-rw-r--r--src/history.c25
2 files changed, 29 insertions, 12 deletions
diff --git a/src/cmds_command.c b/src/cmds_command.c
index 2101e57..1e93eea 100644
--- a/src/cmds_command.c
+++ b/src/cmds_command.c
@@ -102,19 +102,26 @@ void do_commandmode(struct block * sb) {
if (sb->value == OKEY_BS) { // BS
if ( ! strlen(inputline) || ! inputline_pos) return;
del_char(inputline, --inputline_pos);
+
+#ifdef HISTORY_FILE
if (commandline_history->pos == 0)
del_char(get_line_from_history(commandline_history, commandline_history->pos), inputline_pos); // borro en el historial
+#endif
show_header(input_win);
return;
} else if (sb->value == OKEY_DEL) { // DEL
if (inputline_pos > strlen(inputline)) return;
del_char(inputline, inputline_pos);
+
+#ifdef HISTORY_FILE
if (commandline_history->pos == 0)
del_char(get_line_from_history(commandline_history, commandline_history->pos), inputline_pos); // borro en el historial
+#endif
show_header(input_win);
return;
+#ifdef HISTORY_FILE
} else if (sb->value == OKEY_UP || sb->value == ctl('p') || // UP
sb->value == OKEY_DOWN || sb->value == ctl('n')) { // DOWN
@@ -132,6 +139,7 @@ void do_commandmode(struct block * sb) {
inputline_pos = strlen(inputline);
show_header(input_win);
return;
+#endif
} else if (sb->value == OKEY_LEFT) { // LEFT
if (inputline_pos) inputline_pos--;
@@ -155,10 +163,12 @@ void do_commandmode(struct block * sb) {
}
for(i = 0; i < strlen(cline); i++) ins_in_line(cline[i]);
+#ifdef HISTORY_FILE
if (commandline_history->pos == 0) { // solo si edito el nuevo comando
char * sl = get_line_from_history(commandline_history, 0);
strcat(sl, cline); // Inserto en el historial
}
+#endif
show_header(input_win);
return;
@@ -173,10 +183,12 @@ void do_commandmode(struct block * sb) {
sprintf(cline, "%s", p1->format);
for (i = 0; i < strlen(cline); i++) ins_in_line(cline[i]);
+#ifdef HISTORY_FILE
if (commandline_history->pos == 0) { // solo si edito el nuevo comando
char * sl = get_line_from_history(commandline_history, 0);
strcat(sl, cline); // Inserto en el historial
}
+#endif
show_header(input_win);
return;
@@ -186,10 +198,12 @@ void do_commandmode(struct block * sb) {
wmove(input_win, 0, inputline_pos + 1 + rescol);
wrefresh(input_win);
+#ifdef HISTORY_FILE
if (commandline_history->pos == 0) { // solo si edito el nuevo comando
char * sl = get_line_from_history(commandline_history, 0);
add_char(sl, sb->value, inputline_pos-1); // Inserto en el historial
}
+#endif
return;
} else if ( sb->value == ctl('w') || sb->value == ctl('b') ||
@@ -550,12 +564,14 @@ void do_commandmode(struct block * sb) {
error("COMMAND NOT FOUND !");
}
+#ifdef HISTORY_FILE
del_item_from_history(commandline_history, 0);
// si hay en historial algun item con texto igual al del comando que se ejecuta
// a partir de la posicion 2, se lo coloca al comiendo de la lista (indica que es lo mas reciente ejecutado).
int moved = move_item_from_history_by_str(commandline_history, inputline, -1);
if (!moved) add(commandline_history, inputline);
commandline_history->pos = 0;
+#endif
chg_mode('.');
// clr_header(input_win); // COMENTADO el dia 22/06
diff --git a/src/history.c b/src/history.c
index ee1751b..dd081f3 100644
--- a/src/history.c
+++ b/src/history.c
@@ -1,16 +1,5 @@
-#if defined HISTORY_FILE
-
-#include <curses.h>
-#include <string.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
-
#include "macros.h"
-#include "history.h"
-#include "sc.h"
-#include "utils/string.h"
-
+#include <string.h>
// current command before tab completion
static char curcmd [BUFFERSIZE];
@@ -34,6 +23,18 @@ void set_comp(int i) {
comp = i;
}
+#if defined HISTORY_FILE
+
+#include <curses.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "history.h"
+#include "sc.h"
+#include "utils/string.h"
+
+
struct history * create_history(char mode) {
struct history * h = (struct history *) malloc (sizeof (struct history));
h->len = 0;