Commit graph

84 commits

Author SHA1 Message Date
Sanne Wouda
722fedc8fd rewrite input_mapping_execute for clarity
For the case
```
bind \et "commandline -i 1" "commandline -i 2"
```
the order of execution of the commands is now in-order.

Note that functions codes are prepended to the queue in reverse order, so they
will be executed in-order.  This should allow all bindings of the form
```
bind \et beginning-of-line force-repaint
```
to remain unchanged.
2015-04-19 16:56:48 -07:00
Sanne Wouda
32936b0eb9 Change lookahead_list into a queue
Using builtin `commandline -f`, one would expect to have commands executed in
the order that they were given.  This motivates the change to a queue.

Unfortunately, fish internals still need lookahead_list to act as a stack.  Add
and rename functions to support both cases and have lookahead_list as
a std::deque internally.

This code is delicate, and we should probably dog-food this in nightly for
a while before the next-minor release.

Fixes #1567
2015-04-19 16:56:48 -07:00
David Adam
9b43e6fa8b use configure to define NOMACROS
(added in 9ec808a4c)
2014-12-21 23:38:02 +08:00
David Adam
a8059c5962 Solaris build fixes: pick the right curses more of the time 2014-12-21 23:37:23 +08:00
David Adam
68029095b5 Remove del_curterm workaround on *BSD.
FreeBSD PR was https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=108117
OpenBSD PR was 5447.

Both have been fixed for years.

This reverts commit c55cbd3f2f, among
others.
2014-12-08 08:01:03 +08:00
ridiculousfish
7ac593273e Remove a bunch of dead code identified by cppcheck 2014-10-31 01:15:50 -07:00
ridiculousfish
a529fc9d83 Set of fixes for issues identified by cppcheck 2014-10-30 22:40:35 -07:00
Kevin Ballard
35595dbffd Make escape() return a wcstring
This avoids the potential for leaking the resulting string.
2014-09-25 18:20:03 -07:00
Kevin Ballard
80078491bd Fix build failure
std::vector::erase() didn't take const_iterator until C++11 >_<
2014-09-22 21:25:51 -07:00
Kevin Ballard
0a3f220572 Rework mode handling of bind
Binds with the same sequence in multiple modes was not working right.
Fix up the implementation to propagate modes everywhere as necessary.
This means that `bind` will properly list distinct binds with the same
sequence, and `bind -e` will take mode into account properly as well.
Note that `bind -e seq` now assumes the bind is in the default bind
mode, whereas before it would erase the first binding with that sequence
regardless of mode.

`bind -e -a` still erases all binds in all modes, though `bind -M mode
-e -a` still only erases all binds in the selected mode.
2014-09-22 21:04:06 -07:00
ridiculousfish
b8181f9eb8 Further support for term24bit. Teach output.cpp what to do with it. 2014-09-19 18:45:04 -07:00
ridiculousfish
555ff00a30 Initial work to support for term-24bit ("true color") 2014-09-19 18:45:04 -07:00
Kevin Ballard
24ac7d2698 Fix commandline behavior in bind functions
When a key is bound to a fish function, if that function invokes
`commandline`, it gets a stale copy of the commandline. This is because
any keys passed to `self-insert` (the default) don't actually get added
to the commandline until a special character is processed, such as the
R_NULL that gets returned after running a binding for a fish command.

To fix this, don't allow fish commands to be run for bindings if we're
processing more than one key. When a key wants to invoke a fish command,
instead we push the invocation sequence back onto the input, followed by
an R_NULL, and return. This causes the input loop to break out and
update the commandline. When it starts up again, it will re-process the
keys and invoke the fish command.

This is primarily an issue with pasting text that includes bound keys in
it. Typed text is slow enough that fish will update the commandline
between each character.

---

I don't know of any way to write a test for this, but the issue can be
reproduced as follows:

    > bind _ 'commandline -i _'

This binds _ to a command that inserts _. Typing the following works:

    > echo wat_is_it

But if you copy that line and paste it instead of typing it, the end
result looks like

    > _echo wat_isit

With this fix in place, the pasted output correctly matches the typed
output.
2014-08-29 12:29:48 -07:00
ridiculousfish
3915faf382 bind should not show -k for bindings that are escape sequences, not keys 2014-07-07 10:45:26 -07:00
ridiculousfish
655293ece9 input_readch must return R_EOF instead of WEOF. Fixes #1452 2014-05-25 15:22:44 -07:00
ridiculousfish
58ebdd4a7e Attempt to silence some warnings 2014-04-27 17:23:19 -07:00
ridiculousfish
0d3169ef70 Run restyle.sh to enforce style rules. 2014-03-31 10:01:39 -07:00
ridiculousfish
bd895aa76c Changes to bind_mode implementation based on code review and merge
errors
2014-03-30 16:58:46 -07:00
ridiculousfish
d4fafeb6d6 Merge branch 'master' into 1218_rebase
Conflicts:
	builtin.cpp
	builtin_commandline.cpp
	highlight.cpp
	input.cpp
	input.h
	reader.cpp
	screen.cpp
	screen.h
2014-03-29 14:19:45 -07:00
ridiculousfish
be33d3f2a4 Revert "Merge pull request #1317 from pullreq/cpp"
This reverts commit 74135c0600, reversing
changes made to 6d749789ce.

See discussion in #1317
2014-02-28 02:16:48 -08:00
Geoff Nixon
18dd6f58e3 Fixes .c -> .cpp in comments. For doxygen. 2014-02-27 06:23:40 -08:00
ridiculousfish
f733dc5eae Fix the build by including <algorithm> header 2014-02-12 21:08:22 -08:00
ridiculousfish
503bbd85b5 Test and fix issue where, if binding X is a prefix of binding Y, and X
is specified before Y, then Y will never be invoked because X will
always get there first. Now instead we order bindings in descending
order by length, so that we always test the binding before any others that
prefixes it. Fixes #1283.
2014-02-12 12:52:31 -08:00
ridiculousfish
7d8766980b Support escape or up-arrow to cancel the completion search field. 2014-01-27 02:17:31 -08:00
ridiculousfish
5be3606236 Increased support for completion search field. Use btab (shift-tab) to
complete-and-search.
2014-01-27 00:56:13 -08:00
Julian Aron Prenner
844b01cb6b Add 'and' input function; fixes a bug with t,T
'and' will prevent later input functions from being executed if the
previous one did not succeed (e.g. a jump to a char not on the command
line)
2014-01-23 10:23:04 +01:00
Julian Aron Prenner
4a9be7bf11 Experimental support for f,F,t,T vi commands.
Input functions can now have arguments
2014-01-22 10:00:44 +01:00
ridiculousfish
9edf9ad2ac Correct the correspondence between name_arr and the input codes. 2014-01-21 16:08:35 -08:00
Julian Aron Prenner
fd8ab78372 Update $fish_bind_mode only if necessary 2014-01-20 14:03:48 +01:00
Julian Aron Prenner
cd64a777c3 Set $fish_bind_mode to default on fish startup; set $fish_key_bindings
when sourcing fish_vi_mode.fish
2014-01-19 10:27:39 +01:00
Julian Aron Prenner
3728fc7dba Add kill-selection function and visual binds for 'y' and 'd' 2014-01-18 10:18:29 +01:00
Julian Aron Prenner
c8d5131a42 Add experimental support for selection and visual mode 2014-01-15 15:07:22 +01:00
Julian Aron Prenner
fc21bb6eda Replace builtin 'bind_mode' with variable $fish_bind_mode 2014-01-15 12:04:52 +01:00
Julian Aron Prenner
dede320630 Rename 'new-mode' to 'sets-mode', prepare for selection support. 2014-01-15 11:39:19 +01:00
Julian Aron Prenner
dc90cd6bc4 Better input handling; add support multiple binding commands 2014-01-01 00:11:32 +01:00
Julian Aron Prenner
a302f37447 Fix bug 2013-12-31 16:16:28 +01:00
Julian Aron Prenner
2587649ca2 Allow restricting earsing and listing of bindings to specific mode;
implement force repaint and multi-char bindings;
2013-12-31 14:53:29 +01:00
Julian Aron Prenner
d1faac58dd Implement bind modes 2013-12-31 01:52:41 +01:00
ridiculousfish
b04fc5a39e Add missing const cast for setup_term
https://github.com/fish-shell/fish-shell/issues/1142
2013-11-26 10:56:43 -08:00
David Adam
2c39d5b6c0 fall back to ANSI terminal type if setupterm fails
Closes: https://github.com/fish-shell/fish-shell/issues/1060

'ansi' should always be present (tested on Solaris, Linux, FreeBSD,
Darwin).

Also overrides TERM so that other programs behave consistently e.g.
fish_pager.

The error message makes no specific mention of terminfo or termcap as
these vary across operating systems.

(r+ @ridiculousfish with thanks)
2013-11-26 21:56:49 +08:00
David Adam
8d1667e9e8 more detailed debugging when terminal type cannot be found
Ref: #1060
2013-11-26 21:56:49 +08:00
Christian Rishøj
cd1c2f74d3 add support for downcase-word, upcase-word and capitalise-word 2013-09-09 18:46:16 +02:00
Christian Rishøj
a259c37415 transpose-words 2013-06-02 00:59:22 -07:00
Ian Ray
35610da204 Fix wchar_t cast 2013-05-25 14:03:18 -07:00
Christian Rishøj
f32dfe2da6 command and binding for transpose-chars 2013-05-24 23:56:12 -07:00
ridiculousfish
c80bd104d2 Add errret param to other calls to setupterm 2013-05-13 01:41:50 -07:00
ridiculousfish
2da81b0ae7 Formatting and style updates 2013-05-05 02:33:17 -07:00
ridiculousfish
bcf3accb74 Eliminate a static string from input_terminfo_get_sequence 2013-04-15 13:07:17 -07:00
David Adam (zanchey)
daf5ef1bbd Kill termio.h and sys/termios.h
On FreeBSD, compilation complains that "this file includes
<sys/termios.h> which is deprecated, use <termios.h> instead". On Linux
and FreeBSD, <sys/termios.h> literally just pulls in <termios.h>. On OS
X and Solaris, <termios.h> pulls in <sys/termios.h>.

<termio.h> doesn't exist on FreeBSD or Mac OS X, and on Linux is marked
as deprecated and just includes <termios.h>. It does exist on Solaris,
but no `struct termio` is ever actually used in the codebase.
2013-03-05 12:25:00 -08:00
ridiculousfish
c55cbd3f2f Hopeful fix for https://github.com/fish-shell/fish-shell/issues/594 2013-02-26 18:31:08 -08:00