summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard R. Link <brlink@debian.org>2008-06-10 15:40:50 +0200
committerShawn <sabetts@juicebox.(none)>2008-10-22 14:23:55 -0700
commit3737db1e6072c557748ba0ffcdca1e810b15009f (patch)
tree086728bed62b01cf799732dc43a75d78de13dbc7
parentd11f0735321bc725441fbc1dec04e363d07c987a (diff)
downloadratpoison-3737db1e6072c557748ba0ffcdca1e810b15009f.zip
move all HAVE_HISTORY into history.c
-rw-r--r--src/actions.c2
-rw-r--r--src/editor.c18
-rw-r--r--src/history.c49
-rw-r--r--src/input.c2
-rw-r--r--src/main.c4
5 files changed, 48 insertions, 27 deletions
diff --git a/src/actions.c b/src/actions.c
index 221c1cd..66ea755 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -1681,7 +1681,6 @@ read_shellcmd (struct argspec *spec, struct sbuf *s, struct cmdarg **arg, const
cmdret *ret;
ret = read_string (spec, s, hist_SHELLCMD, exec_completions, arg);
-#ifdef HAVE_HISTORY
if (command_name && !ret) {
/* store for command history */
char *s = xmalloc (strlen(command_name) + strlen((*arg)->string) + 2);
@@ -1689,7 +1688,6 @@ read_shellcmd (struct argspec *spec, struct sbuf *s, struct cmdarg **arg, const
history_add (hist_COMMAND, s);
free(s);
}
-#endif
return ret;
}
diff --git a/src/editor.c b/src/editor.c
index b2a72f9..0623186 100644
--- a/src/editor.c
+++ b/src/editor.c
@@ -56,9 +56,7 @@ static edit_status editor_complete_next (rp_input_line *line);
static edit_status editor_insert (rp_input_line *line, char *keysym_buf);
-#ifdef HAVE_HISTORY
static char *saved_command = NULL;
-#endif
typedef struct edit_binding edit_binding;
@@ -358,7 +356,6 @@ editor_backward_kill_line (rp_input_line *line)
static edit_status
editor_history_previous (rp_input_line *line)
{
-#ifdef HAVE_HISTORY
const char *entry = history_previous (line->history_id);
if (entry)
@@ -384,18 +381,11 @@ editor_history_previous (rp_input_line *line)
}
return EDIT_INSERT;
-
-#else /* HAVE_HISTORY */
-
- return EDIT_NO_OP;
-
-#endif /* HAVE_HISTORY */
}
static edit_status
editor_history_next (rp_input_line *line)
{
-#ifdef HAVE_HISTORY
const char *entry = history_next (line->history_id);
if (entry)
@@ -422,10 +412,6 @@ editor_history_next (rp_input_line *line)
line->position = line->length;
return EDIT_INSERT;
-
-#else /* HAVE_HISTORY */
- return EDIT_NO_OP;
-#endif /* HAVE_HISTORY */
}
static edit_status
@@ -467,13 +453,10 @@ editor_insert (rp_input_line *line, char *keysym_buf)
static edit_status
editor_enter (rp_input_line *line)
{
-#ifdef HAVE_HISTORY
int result;
char *expansion;
-#endif
line->buffer[line->length] = '\0';
-#ifdef HAVE_HISTORY
result = history_expand_line (line->history_id, line->buffer, &expansion);
PRINT_DEBUG (("History Expansion - result: %d\n", result));
@@ -491,7 +474,6 @@ editor_enter (rp_input_line *line)
free (line->buffer);
line->buffer = expansion;
}
-#endif /* HAVE_HISTORY */
return EDIT_DONE;
}
diff --git a/src/history.c b/src/history.c
index 4178cf9..9f9b7d1 100644
--- a/src/history.c
+++ b/src/history.c
@@ -25,8 +25,8 @@
#include "ratpoison.h"
#ifdef HAVE_HISTORY
-
#include "readline/history.h"
+#endif
static char *
get_history_filename (void)
@@ -47,6 +47,7 @@ get_history_filename (void)
return filename;
}
+#ifdef HAVE_HISTORY
void
history_load (void)
{
@@ -97,6 +98,7 @@ history_add (int history_id, char *item)
PRINT_DEBUG (("Adding item: %s\n", item));
add_history (item);
}
+#endif /* HAVE_HISTORY */
static const char *
extract_shell_part (const char *p)
@@ -113,6 +115,7 @@ extract_shell_part (const char *p)
return NULL;
}
+#ifdef HAVE_HISTORY
const char *
history_previous (int history_id)
{
@@ -158,5 +161,49 @@ int history_expand_line (int history_id, char *string, char **output)
{
return history_expand (string, output);
}
+#else /* HAVE_HISTORY */
+
+void
+history_add (int history_id, char *item)
+{
+}
+
+void
+history_load (void)
+{
+}
+
+void
+history_save (void)
+{
+}
+
+void
+history_reset (void)
+{
+}
+
+void
+history_resize (int size)
+{
+}
+
+const char *
+history_previous (int history_id)
+{
+ return NULL;
+}
+
+const char *
+history_next (int history_id)
+{
+ return NULL;
+}
+
+int history_expand_line (int history_id, char *string, char **output)
+{
+ *output = xstrdup(string);
+ return 0;
+}
#endif /* HAVE_HISTORY */
diff --git a/src/input.c b/src/input.c
index db36ba7..35454df 100644
--- a/src/input.c
+++ b/src/input.c
@@ -537,9 +537,7 @@ get_more_input (char *prompt, char *preinput, int history_id,
Window focus;
int revert;
-#ifdef HAVE_HISTORY
history_reset();
-#endif /* HAVE_READLINE_HISTORY_H */
/* Create our line structure */
line = input_line_new (prompt, preinput, history_id, compl_fn);
diff --git a/src/main.c b/src/main.c
index 050844a..919f4ca 100644
--- a/src/main.c
+++ b/src/main.c
@@ -713,9 +713,7 @@ main (int argc, char *argv[])
update_modifier_map ();
init_user_commands();
initialize_default_keybindings ();
-#ifdef HAVE_HISTORY
history_load ();
-#endif /* HAVE_HISTORY */
/* Scan for windows */
if (screen_arg)
@@ -790,9 +788,7 @@ clean_up (void)
{
int i;
-#ifdef HAVE_HISTORY
history_save ();
-#endif /* HAVE_HISTORY */
free_keymaps ();
free_aliases ();