diff options
author | Michael Jennings <mej@kainx.org> | 2001-06-12 01:04:45 +0000 |
---|---|---|
committer | Michael Jennings <mej@kainx.org> | 2001-06-12 01:04:45 +0000 |
commit | c3f775c1b5720075e34efc6bb8d2dbf7ec5e6b4e (patch) | |
tree | 42d5b34d4a29cd98194a7679bc480c21479bb696 /src/script.c | |
parent | d6cf1648376e616941d7f15875be0f48e2da0f6e (diff) | |
download | eterm-c3f775c1b5720075e34efc6bb8d2dbf7ec5e6b4e.tar.gz |
Mon Jun 11 17:49:55 PDT 2001 Michael Jennings <mej@eterm.org>
Okay, first off, I removed 3 scaled backgrounds. See www.kainx.org or
my post to enlightenment-devel for details.
Second, I redid the default bindings for the mouse wheel. Basically,
the wheel alone will scroll by pages. Ctrl+wheel will scroll by pages
in groups of 5. Shift+wheel will scroll by a single line. If you
hold down the Alt key, the same combinations will work the same way,
but instead of scrolling within Eterm, they'll scroll the application
in the terminal (by sending PgUp/PgDn and up/down arrows). This works
in less, bash, and any other application which groks those keys.
I also added a --without-mousewheel option to configure that will turn
off the default scrollwheel bindings. Of course, you can always use
action bindings in the config file to bind/rebind these any way you
like.
While I was at it, I found and fixed a bug in the handling of the
Alt and Meta keys.
I added a scroll() function to the script stuff which allows you to
bind keys/buttons to scroll up and down. While I was at it, I added
comments to script.c for each function you can use.
And finally, the config file parser was moved to libast.
SVN revision: 4806
Diffstat (limited to 'src/script.c')
-rw-r--r-- | src/script.c | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/src/script.c b/src/script.c index 2fa3bc8..5dae3b9 100644 --- a/src/script.c +++ b/src/script.c @@ -50,6 +50,7 @@ static eterm_script_handler_t script_handlers[] = { "paste", script_handler_paste }, { "quit", script_handler_exit }, { "save", script_handler_save }, + { "scroll", script_handler_scroll }, { "search", script_handler_search }, { "spawn", script_handler_spawn }, @@ -122,6 +123,18 @@ eterm_handle_winop(char *action) #endif /********* HANDLERS **********/ + +/* copy(): Copy the current selection to the specified clipboard or cut + * buffer + * + * Syntax: copy([ <buffer> ]) + * + * <buffer> is either a number 0-7, in which case the selection is copied to + * the the cut buffer specified, or one of the words "clipboard," "primary," + * or "secondary" (or any initial substring thereof), in which case the + * selection is copied to the specified clipboard. The default buffer is + * the "primary" buffer (XA_PRIMARY in Xlib-speak). + */ void script_handler_copy(char **params) { @@ -149,6 +162,15 @@ script_handler_copy(char **params) selection_copy(sel); } +/* exit(): Exit Eterm with an optional message or return code + * + * Syntax: exit([ { <msg> | <code> } ]) + * + * <msg> is an optional exit message. <code> is a positive or + * negative integer return code. Either one may be specified, but not + * both. If neither is specified, Eterm exits with a return code of 0 + * and no message. + */ void script_handler_exit(char **params) { @@ -167,6 +189,17 @@ script_handler_exit(char **params) exit(code); } +/* paste(): Paste the contents of the specified clipboard or cut buffer + * into the terminal window + * + * Syntax: paste([ <buffer> ]) + * + * <buffer> is either a number 0-7, in which case the contents of the cut + * buffer specified are pasted, or one of the words "clipboard," "primary," + * or "secondary" (or any initial substring thereof), in which case the + * contents of the specified clipboard are pasted. The default buffer is + * the "primary" buffer (XA_PRIMARY in Xlib-speak). + */ void script_handler_paste(char **params) { @@ -194,6 +227,16 @@ script_handler_paste(char **params) selection_paste(sel); } +/* save(): Save the current theme/user configuration + * + * Syntax: save([ { theme | user } ,] [ <filename> ]) + * + * The "user" settings are saved by default, and the default + * filename is user.cfg. So save() by itself will save the + * current user settings to user.cfg. save(theme) will save + * the theme settings instead; the default filename in that case + * will be theme.cfg. + */ void script_handler_save(char **params) { @@ -208,12 +251,80 @@ script_handler_save(char **params) } } +/* scroll(): Scroll backward or forward in the scrollback buffer + * + * Syntax: scroll(N) or scroll(Nl) -- Scroll N lines + * scroll(Np) -- Scroll N pages/screensful + * scroll(Nb) -- Scroll N buffers + * + * N is a floating point number. Use a negative number to scroll + * up and a positive number to scroll down. Fractions can be used + * also (e.g., to scroll one half page, use scroll(0.5p)). It is + * possible to spell out "lines," "pages," and "buffers" as well, + * and the type may be passed as a second parameter if you wish. + */ +void +script_handler_scroll(char **params) +{ + char *type; + double cnt_float; + long count; + int direction = DN; + + if (params && *params) { + cnt_float = strtod(params[0], &type); + if (cnt_float == 0.0) { + return; + } else if (cnt_float < 0.0) { + cnt_float = -cnt_float; + direction = UP; + } + if (!type) { + type = params[1]; + } + if (type && *type) { + for (; *type && !isalpha(*type); type++); + if (str_leading_match("lines", type)) { + count = (long) cnt_float; + } else if (str_leading_match("pages", type) || str_leading_match("screens", type)) { + count = (long) ((cnt_float * TermWin.nrow) - CONTEXT_LINES); + } else if (str_leading_match("buffers", type)) { + count = (long) (cnt_float * (TermWin.nrow + TermWin.saveLines)); + } else { + print_error("Invalid modifier \"%s\" in scroll()\n", type); + return; + } + } else { + count = (long) cnt_float; + } + + if (count <= 0) { + return; + } + scr_page(direction, count); + } +} + +/* search(): Search the scrollback buffer for a string and highlight + * any occurances of it. + * + * Syntax: search([ <str> ]) + * + * <str> is an optional search string to highlight. If none is given, + * search() will clear the previously-highlighted search term. + */ void script_handler_search(char **params) { scr_search_scrollback(params ? params[0] : NULL); } +/* spawn(): Spawns a child process to execute a sub-command + * + * Syntax: spawn([ <command> ]) + * + * If no command is specified, the default is to execute another Eterm. + */ void script_handler_spawn(char **params) { @@ -228,6 +339,12 @@ script_handler_spawn(char **params) } } +/* nop(): Do nothing + * + * Syntax: nop() + * + * This function can be used to cancel undesired default behavior. + */ void script_handler_nop(char **params) { |