[asterisk-commits] seanbright: trunk r317395 - /trunk/main/asterisk.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu May 5 16:20:09 CDT 2011
Author: seanbright
Date: Thu May 5 16:20:00 2011
New Revision: 317395
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=317395
Log:
Add some new editline bindings by default, and allow for user specified configuration.
I excluded the part of this patch that used the HOME environment variable since
the built-in editline library goes to great lengths to disallow that. Instead
only settings the EDITRC environment variable will use a user specified file.
Also, the default environment variable use to determine the edit more is
AST_EDITMODE instead of AST_EDITOR (although the latter is still supported).
(closes issue #15929)
Reported by: kkm
Patches:
astcli-editrc-v2.diff uploaded by kkm (license 888)
015929-astcli-editrc-trunk.240324.diff uploaded by kkm (license 888)
Tested by: seanbright
Modified:
trunk/main/asterisk.c
Modified: trunk/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/asterisk.c?view=diff&rev=317395&r1=317394&r2=317395
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Thu May 5 16:20:00 2011
@@ -2569,7 +2569,13 @@
static int ast_el_initialize(void)
{
HistEvent ev;
- char *editor = getenv("AST_EDITOR");
+ char *editor, *editrc = getenv("EDITRC");
+
+ if (!(editor = getenv("AST_EDITMODE"))) {
+ if (!(editor = getenv("AST_EDITOR"))) {
+ editor = "emacs";
+ }
+ }
if (el != NULL)
el_end(el);
@@ -2580,7 +2586,7 @@
el_set(el, EL_PROMPT, cli_prompt);
el_set(el, EL_EDITMODE, 1);
- el_set(el, EL_EDITOR, editor ? editor : "emacs");
+ el_set(el, EL_EDITOR, editor);
el_hist = history_init();
if (!el || !el_hist)
return -1;
@@ -2597,6 +2603,18 @@
el_set(el, EL_BIND, "?", "ed-complete", NULL);
/* Bind ^D to redisplay */
el_set(el, EL_BIND, "^D", "ed-redisplay", NULL);
+ /* Bind Delete to delete char left */
+ el_set(el, EL_BIND, "\\e[3~", "ed-delete-next-char", NULL);
+ /* Bind Home and End to move to line start and end */
+ el_set(el, EL_BIND, "\\e[1~", "ed-move-to-beg", NULL);
+ el_set(el, EL_BIND, "\\e[4~", "ed-move-to-end", NULL);
+ /* Bind C-left and C-right to move by word (not all terminals) */
+ el_set(el, EL_BIND, "\\eOC", "vi-next-word", NULL);
+ el_set(el, EL_BIND, "\\eOD", "vi-prev-word", NULL);
+
+ if (editrc) {
+ el_source(el, editrc);
+ }
return 0;
}
More information about the asterisk-commits
mailing list