diff --git a/src/common.h b/src/common.h index 7551e41..63d2390 100644 --- a/src/common.h +++ b/src/common.h @@ -200,6 +200,7 @@ wchar_t *commandline_get_buffer(); void commandline_draw(); void commandline_move_cursor(gint); void commandline_delete(); +void commandline_set_cmd(gchar *line); /* Keyfile.c */ gboolean keyfile_read(); @@ -210,6 +211,7 @@ GKeyFile *keyfile_get(); #define FAMA_LOGFILE_DIR "logs" #define FAMA_CONFIG_FILE "config" #define FAMA_ACCOUNTS "accounts" +#define FAMA_HISTORY_FILE "history" /* Window.c */ FamaWindow *window_new(FamaWindowType); @@ -236,6 +238,13 @@ void log_get_time(gchar *, gsize); void command_init(); void command_add(gchar *, CommandFunc); gboolean command_execute(gint, gchar **); +gboolean command_hist_init(); +gboolean commandline_hist_loadpre(); +gboolean commandline_hist_loadnext(); + +/* history*/ +/** default list number of history*/ +#define DEFAULTLISTNUMBER 10 /* Color.c */ void color_init(); diff --git a/src/main.c b/src/main.c index 56d7286..edb410a 100644 --- a/src/main.c +++ b/src/main.c @@ -6,6 +6,7 @@ #ifdef HAVE_CONFIG_H #include #endif +#include "ui-history.h" GMainLoop *loop; @@ -179,6 +180,12 @@ init_all() command_init(); + /* + * Initialize history interface + */ + + famahistory_command_init(); + /* * Call stdin_handle_input when there's input from stdin */ @@ -199,3 +206,4 @@ init_all() return TRUE; } + diff --git a/src/ui-command-account.c b/src/ui-command-account.c index 4ed3c0e..6e2fd91 100644 --- a/src/ui-command-account.c +++ b/src/ui-command-account.c @@ -77,6 +77,7 @@ command_func_account(gint argc, gchar ** argv) window_add_message(window_get_current(), title, A_BOLD, outbuf); g_ptr_array_free(items, TRUE); + g_free(outbuf); } return TRUE; } diff --git a/src/ui-command-line.c b/src/ui-command-line.c index 20cb236..be5faef 100644 --- a/src/ui-command-line.c +++ b/src/ui-command-line.c @@ -1,4 +1,5 @@ #include "common.h" +#include #define COMMAND_LINE_MAX_LENGHT 512 @@ -114,3 +115,21 @@ commandline_add_wch(wchar_t c) commandline_draw(); } + +void +commandline_set_cmd(gchar *line) +{ + gint strlength; + if (!line) { + cmdbuf[0] = L'\0'; + len = ptr = 0; + return; + } + cmdbuf[0] = L'/'; + strlength = strlen(line); + utf8_to_wchar(line, cmdbuf + 1, strlength); + cmdbuf[strlength + 1] = L'\0'; + len = strlength; + ptr = len; +} + diff --git a/src/ui-command.c b/src/ui-command.c index f89e0e2..35bbb51 100644 --- a/src/ui-command.c +++ b/src/ui-command.c @@ -1,10 +1,11 @@ #include "common.h" #include #include +#include +#include "ui-history.h" GHashTable *table = NULL; - gboolean command_func_window(gint argc, gchar ** argv); gboolean command_func_help(gint argc, gchar ** argv); gboolean command_func_connect(gint argc, gchar ** argv); @@ -13,7 +14,13 @@ gboolean command_func_account(gint argc, gchar ** argv); gboolean command_func_contact(gint argc, gchar ** argv); gboolean command_func_status(gint argc, gchar ** argv); gboolean command_func_log(gint argc, gchar ** argv); +gboolean command_func_history(gint argc, gchar ** argv); +/** argc is number of arguments in a command line, + * argv is array of the arguments*/ +void command_hist_add(gint argc, gchar ** argv); +/** load history setting in profile(keyfile)*/ +gboolean command_hist_loadprofile(); /* * This function is for command_func_help()'s private use */ @@ -67,6 +74,7 @@ gboolean command_func_quit(gint argc, gchar ** argv) { stop_main_loop(); + famahistory_command_savesession(); return TRUE; } @@ -132,6 +140,112 @@ command_func_window(gint argc, gchar ** argv) return TRUE; } +gboolean +command_func_history(gint argc, gchar ** argv) +{ + gchar **infostring; + gchar *string, strtitle[256]; + wchar_t *outbuf, wtitle[256]; + gint mask = 0; + if (argc == 0) + return FALSE; + g_sprintf(strtitle, "History infomation : "); + if (argc == 1) { + infostring = famahistory_info_get(HISINFO_USAGE | HISINFO_MAXNUMBER | + HISINFO_ENABLE | HISINFO_LISTNUM); + + g_assert(infostring); + string = g_strjoinv("\n", infostring); + outbuf = g_new(wchar_t, strlen(string) + 1); + + utf8_to_wchar(string, outbuf, strlen(string)); + utf8_to_wchar(strtitle, wtitle, strlen(strtitle)); + window_add_message(window_get_main(), + wtitle, + A_BOLD, outbuf); + + g_strfreev(infostring); + g_free(string); + g_free(outbuf); + return TRUE; + } + + if (g_ascii_strcasecmp("maxnumber", argv[1]) == 0) { + if (argc == 3) { + gint max = atoi(argv[2]); + famahistory_setmax(max); + g_sprintf(strtitle, "History infomation : %s", + "Succeed in setting max number of history."); + } else + mask |= HISINFO_USAGE; + mask |= HISINFO_MAXNUMBER; + infostring = famahistory_info_get(mask); + string = g_strjoinv("\n", infostring); + outbuf = g_new(wchar_t, strlen(string) + 1); + utf8_to_wchar(string, outbuf, strlen(string)); + utf8_to_wchar(strtitle, wtitle, strlen(strtitle)); + window_add_message(window_get_main(), + wtitle, A_BOLD, outbuf); + g_strfreev(infostring); + g_free(string); + g_free(outbuf); + return TRUE; + } + if (g_ascii_strcasecmp("enable", argv[1]) == 0) { + if (argc == 3) { + gint enab = -1; + if (g_ascii_strcasecmp("on", argv[2]) == 0) { + enab = 1; + } else if (g_ascii_strcasecmp("off", argv[2]) == 0) { + enab = 0; + } else + mask |= HISINFO_USAGE; + if (enab >= 0) { + famahistory_enable(enab); + g_sprintf(strtitle, "History infomation : %s", + "Succeed in setting of history enable flag."); + } + } else + mask |= HISINFO_USAGE; + mask |= HISINFO_ENABLE; + infostring = famahistory_info_get(mask); + string = g_strjoinv("\n", infostring); + outbuf = g_new(wchar_t, strlen(string) + 1); + utf8_to_wchar(string, outbuf, strlen(string)); + utf8_to_wchar(strtitle, wtitle, strlen(strtitle)); + window_add_message(window_get_main(), + wtitle, A_BOLD, outbuf); + g_strfreev(infostring); + g_free(string); + g_free(outbuf); + return TRUE; + } + if (g_ascii_strcasecmp("list", argv[1]) == 0) { + gint listnum; + g_sprintf(strtitle, "History infomation : has %d records", + famahistory_number()); + if (argc == 3) { + if (g_ascii_strcasecmp("all", argv[2]) == 0) + listnum = famahistory_number(); + else + listnum = atoi(argv[2]); + } else { + listnum = DEFAULTLISTNUMBER; + } + infostring = famahistory_info_getlist(listnum); + string = g_strjoinv("\n", infostring); + outbuf = g_new(wchar_t, strlen(string) + 1); + utf8_to_wchar(string, outbuf, strlen(string)); + utf8_to_wchar(strtitle, wtitle, strlen(strtitle)); + window_add_message(window_get_main(), + wtitle, A_BOLD, outbuf); + g_strfreev(infostring); + g_free(string); + g_free(outbuf); + return TRUE; + }return TRUE; +} + /* * Add a new command */ @@ -156,6 +270,7 @@ command_init() command_add("status", command_func_status); command_add("contact", command_func_contact); command_add("log", command_func_log); + command_add("history", command_func_history); } /* @@ -175,6 +290,6 @@ command_execute(gint argc, gchar ** argv) return FALSE; func(argc, argv); - return TRUE; } + diff --git a/src/ui-history.c b/src/ui-history.c index c418ca1..81b5f0f 100644 --- a/src/ui-history.c +++ b/src/ui-history.c @@ -2,56 +2,78 @@ #include #include #include +#include +#include #include +#include "common.h" #include "ui-history.h" +#include "warningstring.h" +#include "hintstring.h" #define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0) -#define DEFAULTMAXHISTNUMBER 500 -#define LIMITMAXHISTNUMBER 10000 +#define LIMITMAXHISTNUMBER 10000 +#define COMMAND_STRING_MAX_LENGHT 512 +#define MAX_HISTORY_NUMBER 50 FamaHistory famahis; -void famahistory_really_add __P((char *)); +void famahistory_really_add __P((gchar *)); +void famahistory_reinit __P((gint interact)); +void famahistory_disable(); +/** check whether the input line is equal to the previous one, + * force to add this line if varible force is 1*/ +gint famahistory_check_add __P((gchar *line, gint force)); +/** add this line into history session*/ +void famahistory_add __P((gchar *line)); +/** remove an indicated line*/ +HIST_ENTRY *famahistory_remove(gint offset); +/** get a history entry by offset,offset as 0 and number is invalid*/ +HIST_ENTRY *famahistory_get __P((gint offset)); +/** get current line entry*/ +HIST_ENTRY *famahistory_get_current(); +/** get the last history entry*/ +HIST_ENTRY *famahistory_get_last(); +/** get current line's offset of the list*/ +gint famahistory_current_offset(void); +/** load history file into history list,a line at a time*/ +gint famahistory_loadfile(gchar *filename); +/** save history file*/ +gint famahistory_savefile(gchar *filename); void -famahistory_initialize(int maxhistnumber) +famahistory_reinit(gint interact) { - history_search_delimiter_chars = ";&()|<>"; + famahis.history_record_enable = interact != 0; history_inhibit_expansion_function = NULL; - famahis.history_control = OMIT_SAMELINE; - history_base = 0; - famahistory_setmax(maxhistnumber); - using_history(); } void -famahistory_reinit(int interact) +famahistory_enable(gboolean enable) { - famahis.history_record_enable = interact != 0; - history_inhibit_expansion_function = NULL; + famahis.history_record_enable = enable; } -void -famahistory_disable() +gboolean +famahistory_getenable() { - famahis.history_record_enable = 0; + return famahis.history_record_enable; } -void famahistory_setmax(int maxhistnumber) +void famahistory_setmax(gint maxhistnumber) { if(maxhistnumber <= 0) - famahis.maxhistnumber = DEFAULTMAXHISTNUMBER; + famahis.maxhistnumber = MAX_HISTORY_NUMBER; famahis.maxhistnumber = min(LIMITMAXHISTNUMBER, maxhistnumber); } /* Check LINE against what HISTCONTROL says to do. Returns 1 if the line * should be saved; 0 if it should be discarded. */ -int -famahistory_check_control(char *line) +gint +famahistory_check_control(gchar *line) { HIST_ENTRY *temp; - int r; + gint r; if (*line == ' ') return 0; @@ -59,7 +81,7 @@ famahistory_check_control(char *line) case 0: /* nothing */ return 1; case 1: /* ignoredups */ - temp = current_history(); + temp = previous_history(); r = (temp == 0 || STREQ(temp->line, line) == 0); @@ -68,12 +90,17 @@ famahistory_check_control(char *line) return 0; } -/* Just check LINE against HISTCONTROL and HISTIGNORE and add it to the - * history if it's OK. Used by `history -s' as well as maybe_add_history(). - * Returns 1 if the line was saved in the history, 0 otherwise. */ -int -famahistory_check_add(char *line, int force) +/* Just check LINE against HISTCONTROL and add it to the + * history if it's OK. Returns 1 if the line was saved in the history, + * 0 otherwise. */ +gint +famahistory_check_add(gchar *line, gint force) { + gint histnumber; + histnumber = famahistory_number(); + famahis.currentpos = histnumber; + if (!famahis.history_record_enable) + return 0; if (force || famahistory_check_control(line)){ famahistory_add(line); return 1; @@ -81,37 +108,39 @@ famahistory_check_add(char *line, int force) return 0; } -/* Add a line to the history list. - * The variable COMMAND_ORIENTED_HISTORY controls the style of history - * remembering; when non-zero, and LINE is not the first line of a - * complete parser construct, append LINE to the last history line instead - * of adding it as a new line. */ +/* Add a line to the history list. */ void -famahistory_add(char *line) +famahistory_add(gchar *line) { - int histnumber; + gint histnumber, i, n; HIST_ENTRY *first; histnumber = famahistory_number(); - if (histnumber >= famahis.maxhistnumber){ - first = famahistory_remove(history_base); - free_history_entry(first); + if (histnumber >= famahis.maxhistnumber - 1){ + n = histnumber - famahis.maxhistnumber + 1; + for (i = 0; i < n; i++) { + first = famahistory_remove(history_base); + free_history_entry(first); + } } famahistory_really_add(line); } void -famahistory_really_add(char *line) +famahistory_really_add(gchar *line) { + gint histnumber; add_history(line); + histnumber = famahistory_number(); famahis.history_lines_in_session++; using_history(); + famahis.currentpos = histnumber; } -int -famahistory_loadfile(char *filename) +gint +famahistory_loadfile(gchar *filename) { struct stat buf; - int err; + gint err; /* Truncate history file for fama which desire it.*/ /* Read the history in maxhistnumber into the history list. */ if(!filename || !(*filename) || stat(filename, &buf) != 0) @@ -120,14 +149,14 @@ famahistory_loadfile(char *filename) return err; using_history(); famahis.history_lines_in_file = where_history(); - strcpy(famahis.filename, filename); + famahis.currentpos = where_history(); return 0; } -int -famahistory_savefile(char *filename) +gint +famahistory_savefile(gchar *filename) { - int err; + gint err; if(!filename || !(*filename)) return -1; if ((err = write_history(filename)) != 0) @@ -135,7 +164,7 @@ famahistory_savefile(char *filename) return 0; } -int +gint famahistory_number() { using_history(); @@ -151,22 +180,181 @@ famahistory_get_last() return he; } -HIST_ENTRY *famahistory_get(int offset) +HIST_ENTRY * +famahistory_get(gint offset) { using_history(); return history_get(offset); } -HIST_ENTRY *famahistory_current(void) +HIST_ENTRY * +famahistory_current(void) { using_history(); return current_history(); } -HIST_ENTRY *famahistory_remove(int offset) +HIST_ENTRY * +famahistory_remove(gint offset) { HIST_ENTRY *he = remove_history(offset); using_history(); famahis.history_lines_in_session--; return he; } + +void +famahistory_command_add(gint argc, gchar ** argv) +{ + gint i, offset = 0, arglen = 0; + gchar cmdstring[COMMAND_STRING_MAX_LENGHT] = {0}; + g_assert(argc >= 1); + //to avoid pasword being recorded in history file + //So discard the last argument + if (g_ascii_strcasecmp(argv[0], "connect") == 0 && argc >= 3) + argc = 2; + for(i = 0; i < argc; i++) { + arglen = strlen(argv[i]); + g_strlcpy(cmdstring + offset, argv[i], arglen + 1); + offset += arglen; + g_strlcpy(cmdstring + offset, " ", 2); + offset += 1; + } + famahistory_check_add(cmdstring, FALSE); +} + +gboolean +famahistory_command_loadprofile() +{ + GError *err = NULL; + + famahis.maxhistnumber = MAX_HISTORY_NUMBER; + + g_sprintf(famahis.histfilename, "%s/%s/%s", g_get_home_dir(), + FAMA_CONFIG_DIR, FAMA_HISTORY_FILE); + //get the max history number + famahis.maxhistnumber = g_key_file_get_integer(keyfile_get(), + "history", "history_maxnumber", &err); + famahis.maxhistnumber = max(MAX_HISTORY_NUMBER, famahis.maxhistnumber); + return TRUE; +} + +gboolean +famahistory_command_init() +{ + famahistory_command_loadprofile(); + /** famahistory has its default max number,if input histmaxnumber is 0 + * famahistory will use its default value*/ + history_search_delimiter_chars = ";&()|<>"; + history_inhibit_expansion_function = NULL; + famahis.history_control = OMIT_SAMELINE; + famahis.history_record_enable = TRUE; + history_base = 0; + if (famahistory_loadfile(famahis.histfilename) != 0) + return FALSE; + using_history(); + return TRUE; +} + +gboolean +famahistory_command_loadpre() +{ + HIST_ENTRY *he; + gint offset, totalcnt; + totalcnt = famahistory_number(); + offset = famahis.currentpos;// where_history(); + offset--; + if (offset == history_base - 1) + offset = totalcnt + history_base; + he = famahistory_get(offset); + if (he) + commandline_set_cmd(he->line); + else + commandline_set_cmd(NULL); + famahis.currentpos = offset; + return TRUE; +} + +gboolean +famahistory_command_loadnext() +{ + HIST_ENTRY *he; + gint offset, totalcnt; + totalcnt = famahistory_number(); + offset = famahis.currentpos;// where_history(); + offset++; + if (offset == history_base + totalcnt + 1) + offset = history_base; + he = famahistory_get(offset); + if (he) + commandline_set_cmd(he->line); + else + commandline_set_cmd(NULL); + famahis.currentpos = offset; + return TRUE; +} + +/** save current session to history file*/ +void +famahistory_command_savesession() +{ + gint rt; + rt = famahistory_savefile(famahis.histfilename); + if (rt != 0) + g_warning(WARNSTRING_CANTSAVEHISTORY); +} + +gchar ** +famahistory_info_get(gulong infomask) +{ + gint count = 0, i = 0; + gchar **strlist; + while (i < 32) { + count += (infomask >> i) & 0x00000001; + i++; + } + /* the first line is prompt of history usage*/ + count++; + strlist = g_new(gchar *, count + 1); + count = 0; + if (infomask & HISINFO_USAGE) { + strlist[count] = g_strdup_printf(HINTSTR_HISTORYUSAGE); + count++; + } + if (infomask & HISINFO_MAXNUMBER) { + strlist[count] = + g_strdup_printf(HINTSTR_HISTORYMAXNUM(famahis.maxhistnumber)); + count++; + } + if (infomask & HISINFO_ENABLE) { + strlist[count] = + g_strdup_printf(HINTSTR_HISTORYENABLE(famahis.history_record_enable)); + count++; + } + if (infomask & HISINFO_LISTNUM) { + strlist[count] = + g_strdup_printf(HINTSTR_HISTORYLISTNUM(famahistory_number())); + count++; + } + strlist[count] = NULL; + return strlist; +} + +gchar ** +famahistory_info_getlist(gint listnum) +{ + gint totaln, i; + gchar **strlist; + HIST_ENTRY *he; + totaln = famahistory_number(); + g_assert(listnum >= 0 && listnum <= totaln); + strlist = g_new(gchar *, listnum + 1); + for (i = 0; i < listnum; i++) { + he = famahistory_get(totaln - listnum + i); + strlist[i] = g_strdup_printf(" (%d)%s", + (totaln - listnum + 1 + i), he->line); + } + strlist[listnum] = NULL; + return strlist; +} + diff --git a/src/ui-history.h b/src/ui-history.h index e64b7a7..a3a27d1 100644 --- a/src/ui-history.h +++ b/src/ui-history.h @@ -4,60 +4,71 @@ #include #include #include +#include #define MAXFILEPATHLEN 256 typedef struct _famahistory{ /** Declarations of fama history.*/ - int history_record_enable; + gboolean history_record_enable; /** The number of lines that has been added to this history session.*/ - int history_lines_in_session; + gint history_lines_in_session; /** The number of lines that has been read from the history file.*/ - int history_lines_in_file; + gint history_lines_in_file; /** TRUE means to append the history to the history file at fama exit.*/ - int history_force_append; + gint history_force_append; /** A nit for picking at history saving. * Value of 0 means save all lines parsed by the shell on the history. * Value of 1 means save all lines that do not match the last line * saved. */ - int history_control; + gint history_control; /** filename of current history session*/ - char filename[MAXFILEPATHLEN]; + gchar histfilename[MAXFILEPATHLEN]; /** max number of this history session,default value is 500*/ - int maxhistnumber; + gint maxhistnumber; + /** current pos*/ + gint currentpos; }FamaHistory; -/** Initialize a history session and indicate the max number of history lines*/ -void famahistory_initialize __P((int maxhistnumber)); -void famahistory_reinit __P((int interact)); -void famahistory_disable(); +/** argc is arguments' number,argv is array of arguments*/ +void famahistory_command_add __P((gint argc, gchar ** argv)); + +/** Initialize a history session and load the max number of history lines + * from config file*/ +gboolean famahistory_command_init(); + +/** Load previous history and fill it in cmdline*/ +gboolean famahistory_command_loadpre(); + +/** Load previous history and fill it in cmdline*/ +gboolean famahistory_command_loadnext(); + +/** save current session to history file*/ +void famahistory_command_savesession(); + +/** get basic infomation of history according the input combination*/ +gchar **famahistory_info_get(gulong infomask); + +/** get array of history lines*/ +gchar **famahistory_info_getlist(gint listnum); + +/** set enable flag of this session*/ +void famahistory_enable(gboolean enable); + +/** get enable flag of this session*/ +gboolean famahistory_getenable(); +/** Control type of history_control.*/ + /** set max number of history lines*/ -void famahistory_setmax(int maxhistnumber); -/** check whether the input line is equal to the previous one, - * force to add this line if varible force is 1*/ -int famahistory_check_add __P((char *line, int force)); -/** add this line into history session*/ -void famahistory_add __P((char *line)); -/** remove an indicated line*/ -HIST_ENTRY *famahistory_remove(int offset); +void famahistory_setmax(gint maxhistnumber); + +/** get max number of history lines*/ +gint famahistory_getmax(); + /** return number of history lines*/ int famahistory_number(); -int famahistory_currrent_offset(void); -/** get a history entry by offset,offset as 0 and number is invalid*/ -HIST_ENTRY *famahistory_get __P((int offset)); -/** get current line entry*/ -HIST_ENTRY *famahistory_get_current(); -/** get the last history entry*/ -HIST_ENTRY *famahistory_get_last(); -/** get current line's offset of the list*/ -int famahistory_currrent_offset(void); -/** load history file into history list,a line at a time*/ -int famahistory_loadfile(char *filename); -/** save history file*/ -int famahistory_savefile(char *filename); -/** Control type of history_control.*/ #define OMIT_SAMELINE 1 /* #define min(x,y) \ @@ -71,5 +82,11 @@ int famahistory_savefile(char *filename); #define max(a,b) ( ( (a) >= (b) ) ? (a) : (b)) #define min(a,b) ( ( (a) <= (b) ) ? (a) : (b)) +/** famahistory_info_get use them*/ +#define HISINFO_MAXNUMBER (0x1) +#define HISINFO_ENABLE (0x1 << 1) +#define HISINFO_LISTNUM (0x1 << 2) +#define HISINFO_USAGE (0x1 << 3) + #endif diff --git a/src/ui-keyfile.c b/src/ui-keyfile.c index a02e444..76455ef 100644 --- a/src/ui-keyfile.c +++ b/src/ui-keyfile.c @@ -22,8 +22,10 @@ const gchar *default_keyfile = "[core]\n" "status_available=green\n" "status_away=cyan\n" "status_busy=magenta\n" - "status_idle=yellow\n" "status_offline=default\n" "status_other=red\n"; - + "status_idle=yellow\n" "status_offline=default\n" "status_other=red\n" + "\n[history]\n" + "history_filename=history\n" + "history_maxnumber=1024\n"; GKeyFile *keyFile = NULL; @@ -80,6 +82,7 @@ keyfile_write() path = g_strdup_printf("%s/%s", g_get_home_dir(), FAMA_CONFIG_DIR); if (g_mkdir_with_parents(path, 0700) != 0) { g_warning("Cannot create directories for '%s'", path); + g_free(path); return FALSE; } g_free(path); @@ -88,6 +91,7 @@ keyfile_write() data = g_key_file_to_data(keyFile, &length, &err); if (data == NULL) { g_warning("Cannot get keyfile data: %s", err->message); + g_free(path); return FALSE; } diff --git a/src/ui-stdin-handler.c b/src/ui-stdin-handler.c index b204bb5..e0e0494 100644 --- a/src/ui-stdin-handler.c +++ b/src/ui-stdin-handler.c @@ -1,4 +1,5 @@ #include "common.h" +#include "ui-history.h" void handle_input_on_command_line(gunichar c) @@ -45,6 +46,11 @@ handle_input_on_command_line(gunichar c) err->message); g_clear_error(&err); } else { + /* + * add to history session + */ + famahistory_command_add(argc, argv); + /* * Execute command!! */ @@ -71,7 +77,13 @@ handle_input_on_command_line(gunichar c) commandline_move_cursor(-1); } else if (c == KEY_RIGHT) { commandline_move_cursor(1); - } else if (c == '\t' || c == KEY_UP || c == KEY_DOWN) { + } else if (c == KEY_UP) { + famahistory_command_loadpre(); + commandline_draw(); + } else if (c == KEY_DOWN) { + famahistory_command_loadnext(); + commandline_draw(); + } else if (c == '\t') { /* * Ignore for the time being */ diff --git a/wscript b/wscript index f0e9714..9365112 100644 --- a/wscript +++ b/wscript @@ -18,7 +18,6 @@ def configure(conf): conf.check_header('ncursesw/panel.h') conf.check_header('ncursesw/ncurses.h') conf.check_header('readline/history.h') - conf.env['LIB_NCURSESW'] = "ncursesw" conf.env['LIBPATH_NCURSESW'] = '/usr/include' @@ -37,6 +36,7 @@ def configure(conf): conf.write_config_header('config.h') conf.env.append_value('CCFLAGS', '-I/usr/include/ncursesw') + conf.env.append_value('CCFLAGS', '-g') def build(bld): bld.add_subdirs('src')