Commit Graph

19394 Commits

Author SHA1 Message Date
Björn Linse
5be040ffe4 jobsend: Don't append extra newline after last item
This allows sending binary data that is not newline terminated
2015-03-03 20:18:24 +01:00
Thiago de Arruda
81a346553c deps: Add libvterm to the project dependencies
libvterm is a terminal emulation library with abstract display. It will be used
to implement builtin terminal emulation into Nvim.
2015-02-28 10:41:53 -03:00
Mike Zeller
f28941b96d illumos requires the use of limits.h for things like INT_MAX #2049 2015-02-26 11:42:05 -05:00
Eliseo Martínez
36092f3a0c Fix warnings: message.c: copy_hotkeys_and_msg: Garbage value: FP. #2062
Problem    : Branch condition evaluates to a garbage value @ 2868.
Diagnostic : False positive.
Rationale  : Array has_hotkey, declared at 2812, is initialized by
             console_dialog_alloc (only the needed number of elements).
             That same number of elements is used by
             copy_hotkeys_and_msg.
             Suggested path error is impossible, because it involves a
             different number of elements in those functions.
Resolution : Above condition is cumbersome to prove through assertions.
             Thus, we prefer to just initialize the array to all-false
             at declaration point before calling console_dialog_alloc.
2015-02-26 09:04:36 +01:00
Thiago de Arruda
d7e560e5b3 job: Allow spawning jobs connected to pseudo terminals 2015-02-23 21:43:33 -03:00
Thiago de Arruda
1ec7db70ec job: Refactor process spawning and startup arguments
- process spawning was decoupled from the rest of the job control logic.  The
  goal is reusing it for spawning processes connected to pseudo terminal file
  descriptors.
- job_start now receives a JobOptions structure containing all the startup
  options.
2015-02-23 21:43:33 -03:00
Thiago de Arruda
0b8d3cb507 job: Send SIGTERM before calling job_stop in job_teardown
Send sigterm immediately since it can be caught by processes. If they don't
respond and are still alive after a while, SIGKILL will be sent.
2015-02-23 21:43:33 -03:00
Thiago de Arruda
d28011ee1c eval: Fix buffering of data in job autocommands
Job autocommands will no longer buffer data chunks that don't end in newlines
characters.
2015-02-23 21:43:33 -03:00
Florian Walch
0df6b9168e Simpler handling for "always-on"/"always-off" options. #2002
'compatible' and 'edcompatible' are forced to be off.
'ttyfast' is forced to be on.
2015-02-22 14:55:58 -05:00
Thiago de Arruda
97f8251472 tui: Also use xterm-256color when TERM=screen and COLORTERM != NULL
When COLORTERM != null force xterm-256color capabilities when TERM equals xterm
or screen.
2015-02-21 22:28:38 -03:00
Eliseo Martínez
c784ffb308 Fix warnings: window.c: close_last_window_tabpage(): Use after free: RI.
Problem    : Use after free @ 1795.
Diagnostic : Real issue.
Rationale  : prev_curtab can in fact be freed as a result of call
             `win_close_othertab(win, free_buf, prev_curtab);`, but it's
             later used at
             `sprintf(..., tabpage_index(prev_curtab));`.
             This was introduced at
             3ffc5d81c3.
Resolution : Move prev_idx calculation before the call freeing
             prev_curtab.
2015-02-21 10:35:48 +01:00
Eliseo Martínez
56e339c594 Fix warnings: screen.c: screen_puts_len(): Various (4): FP/MI.
Problems   : Assigned value is garbage or undefined @ 5363.
             Result of operation is garbage or undefined @ 5356.
             Result of operation is garbage or undefined @ 5320.
             Result of operation is garbage or undefined @ 5192.
Diagnostic : False positives / Multithreading issues.
Rationale  : Suggested error paths contain incoherent values for
             has_mbyte, enc_utf8, and enc_dbcs, which should always hold
             the relationship has_mbyte = enc_utf8 || enc_dbcs, with
             enc_utf8 and enc_dbcs being mutually exclusive.
             Asserting on the globals, though, fails, because checker
             believes they could be modified by other threads in
             between.
Resolution : Make local copy of globals and assert relationship on them.
2015-02-21 10:35:48 +01:00
Thiago de Arruda
6293b5513c tui: Use unibi_format instead of unibi_run
The current will segfault for large chunks of output because the output buffer
will be overrun.

Using unibi_format is simple because we can simply flush the buffer when its
full.
2015-02-21 05:09:02 -03:00
Thiago de Arruda
eb8f6bec86 tui: Remove option cache 2015-02-21 05:09:02 -03:00
Thiago de Arruda
c58907dac1 tui: Set setaf/setab capabilities for TERM=xterm
Many common terminals that set TERM=xterm and $COLORTERM support 256 colors. If
this is detected, use force the hardcoded xterm's setaf/setab capabilities.
2015-02-21 05:09:02 -03:00
Thiago de Arruda
3baba1e7bc refactor: Remove term modules and termcap options
- Removed term.c, term.h and term_defs.h
- Tests for T_* values were removed. screen.c was simplified as a
  consequence(the best strategy for drawing is implemented in the UI layer)
- Redraw functions now call ui.c functions directly. Updates are flushed with
  `ui_flush()`
- Removed all termcap options(they now return empty strings for compatibility)
- &term/&ttybuiltin options return a constant value(nvim)
- &t_Co is still available, but it mirrors t_colors directly
- Remove cursor tracking from screen.c and the `screen_start` function. Now the
  UI is expected to maintain cursor state across any call, and reset it when
  resized.
- Remove unused code
2015-02-21 05:08:21 -03:00
Eliseo Martínez
a4bed17d0d coverity/13746: Negative array index write: FP.
Problem    : Negative array index write @ 1042.
Diagnostic : False positive.
Rationale  : Suggested error path cannot occur: idx should be >= 0, as
             previous check ensures there's a matching while/for.
Resolution : Assert idx >= 0.
2015-02-20 17:34:07 +01:00
Eliseo Martínez
24fa25a57f coverity/13683: Out-of-bounds access: RI.
Problem    : Out-of-bounds access @ 3730.
Diagnostic : Real issue.
Rationale  : str is constructed step by step, str_l growing each time.
             str_m is the maximum length of str. So, at every step,
             avail is computed to see if the piece to be added fits in.
             If not, piece is truncated to a max of `avail`, so that str
             stays in bounds. Such blocks where pieces are added are of
             the form `if (str_l < str_m)`. It then follows that once
             one of those pieces exhausts available space on str, no
             other such block should be entered. Formally:

               str_l < strl_m && avail = str_m - str_l && x >= avail
                                    -->
                             str_l + x >= str_m

             Now, suggested error path successively enters blocks where
             str is exhausted. We're not sure if coverity just fails to
             follow above implications, or, on the contrary, it's aware
             of them, but it's signaling the more complex possibility of
             implications not being fulfilled because of possible
             arithmetic overflows. We opt then to assume this last case,
             as the possibility is in fact there.
Resolution : Refactor code so that tracked condition doesn't depend on
             arithmetic implications. Check for overflow.
2015-02-20 17:34:07 +01:00
Eliseo Martínez
33cecbbf16 coverity/72768: Negative array index read: FP.
Problem    : Negative array index read @ 5674.
Diagnostic : False positive.
Rationale  : Problem occurs if for loop does not find any match, which
             implies shl->lnum == 0, and then we enter the
             `if (shl->lnum == lnum)` branch, which implies lnum == 0 as
             well. That's not possible, as function should not be called
             with lnum == 0.
Resolution : Change conditions `shl->lnum == lnum` into `bot != -1`.
2015-02-20 17:34:07 +01:00
Fabian Brosda
20054df06e legacy test: migrate test 72 2015-02-20 13:26:59 -03:00
Thiago de Arruda
9894720a05 tui: Don't use 'timeout' for determining esc timeout 2015-02-20 09:43:13 -03:00
Thiago de Arruda
c65f18f686 tui: Set default color attributes when scrolling
This is necessary for some terminals, or else they will clear/insert lines with
wrong background color
2015-02-20 09:27:34 -03:00
Thiago de Arruda
1ed7ae6260 tui: Fix terminfo extension indexes
For unibilium extension indexes, use signed integer type initialized with -1 to
distinguish from the first extension string which will always have index 0.
2015-02-20 09:27:34 -03:00
Thiago de Arruda
bbcddc55ee tui: Replace uv_tty_t by uv_pipe_t
It seems uv_tty_t doesn't work properly on OSX(it is set to blocking mode,
which causes UV_RUN_NOWAIT to misbehave).
2015-02-20 09:27:34 -03:00
Thiago de Arruda
20f52f4235 tui: Only send the pastetoggle key if necessary 2015-02-20 09:27:34 -03:00
Fabian Brosda
0a7cd65cbc vim-patch:7.4.525 #1988
Problem:    map() leaks memory when there is an error in the expression.
Solution:   Call clear_tv(). (Christian Brabandt)

https://code.google.com/p/vim/source/detail?r=v7-4-525
2015-02-19 17:08:43 -05:00
Eliseo Martínez
36340803af Enable -Wconversion: os_unix.c. 2015-02-18 20:54:14 -05:00
Eliseo Martínez
cbabf9491b Enable -Wconversion: keymap.c. 2015-02-18 20:54:13 -05:00
Eliseo Martínez
94db26edbd Enable -Wconversion: indent.c.
Note: Clint was failing because of recommending not to use long. But
converting to long is the proper refactoring here, in as far as other
longs exist. We could, then, disable clint rule, or remove this file
from checking. We choose the former, as it's being discussed what to do
with longs, but a decision has not been taken. So, it seems most
reasonable to allow longs for now, to enable proper refactorings, and
then, when a decision is taken, refactor all longs to some other thing.
2015-02-18 20:54:13 -05:00
Eliseo Martínez
7dd48d7af0 Enable -Wconversion: mark.c.
Refactoring summary:
- MB_STRNICMP: Inlined.
- MB_STRNCMP: Inlined.
2015-02-18 20:54:13 -05:00
Eliseo Martínez
690e43b461 Enable -Wconversion: Passing-by: Remove dead code (MACOS_CONVERT).
MacOS (pre Mac OS X) is not supported anymore.
2015-02-18 20:54:12 -05:00
Eliseo Martínez
7a7c933b86 Enable -Wconversion: ui.c.
Refactoring summary:
- ui_write(): len: int --> size_t
    * parse_abstract_ui_codes(): len: int --> size_t
    * string_convert(): lenp: int * --> size_t *
        - string_convert_ext(): lenp      : int * --> size_t *
                                unconvlenp: int * --> size_t *
            * utf8len_tab_zero: char[] --> uint8_t[]
            * iconv_string(): slen      : int --> size_t
                              unconvlenp: int * --> size_t *
                              resultlenp: int * --> size_t *
        - mch_print_text_out(): len: int --> size_t
    * out_pos: int --> size_t
2015-02-18 20:54:12 -05:00
Thiago de Arruda
e7c945ab59 input: Escape utf8 sequences that contain CSI/K_SPECIAL 2015-02-18 13:16:30 -03:00
Thiago de Arruda
25ceadab37 tui: Remove support for overriding escape sequences with nvim options
- Add xterm/iterm sequences for changing cursor shape(with tmux wrapping).
  Enabled by setting the NVIM_TUI_ENABLE_CURSOR_SHAPE environment variable.
- Remove nvim_override parameter from unibi_out. In the future another way of
  overriding the terminal strings will be added.
2015-02-18 10:46:20 -03:00
Thiago de Arruda
761ccba86f tui: Fix use after free(reported by clang static analyzer) 2015-02-18 10:31:36 -03:00
Thiago de Arruda
59fb8f8172 tui: Add support bracketed paste
Inspired by the vim-bracketed-paste plugin but adapted for the new TUI. Also
initialize some variables of type `Error` that were uninitialized
2015-02-18 09:07:16 -03:00
Thiago de Arruda
26371f4ccc tui: Fix to_status_line terminfo sequence for xterm
Moving the cursor to the status line(to set the title) requires a different
sequence for xterm than the one used by urxvt.
2015-02-17 23:09:36 -03:00
Thiago de Arruda
7ea91de054 tui: Fix background clear for some terminals
Some terminals will perform clearing functions using the current attributes.
Ensure the default attributes are set before clearing.
2015-02-17 23:09:36 -03:00
Felipe Morales
3ffc5d81c3 Add TabClosed event
TabClosed is triggered when a tab page closes.
2015-02-16 23:24:31 -05:00
Felipe Morales
66d94869a0 Add TabNewEntered
TabNewEntered is triggered after vim has entered a buffer in new tab.
2015-02-16 23:24:30 -05:00
Felipe Morales
817be96be5 Add TabNew event
TabNew triggers when entering a new tab page, but not when entering an
already created one.
2015-02-16 23:24:30 -05:00
Thiago de Arruda
419da839e0 cleanup: Remove unused functions and builtin termcaps 2015-02-16 23:17:39 -03:00
Thiago de Arruda
d8f3458ec7 syntax: Refactor to store all term and gui attributes independently
Now the attrentry_T structure will store all attributes in separate fields for
cterm and rgb UIs.
2015-02-16 23:17:39 -03:00
Thiago de Arruda
9a2dd7c498 ui: Rewrite the builtin terminal UI
Now all terminal-handling code was moved to src/nvim/tui, which implements a
new terminal UI based on libtermkey and unibilium
2015-02-16 23:17:39 -03:00
Thiago de Arruda
e0e41b30c6 ui: Remove/adapt some old code for a big UI refactor
- Remove abstract_ui global, now it is always active
- Remove some terminal handling code
- Remove unused functions
- Remove HAVE_TGETENT/TERMINFO/TERMIOS/IOCTL #ifdefs
- Remove tgetent/terminfo from version.c
- Remove curses/terminfo dependencies
- Only start/stop termcap when starting/exiting the program
- msg_use_printf will return true if there are no attached UIs(
  messages will be written to stdout)
- Remove `ex_winpos`(implement `:winpos` with `ex_ni`)
2015-02-16 23:17:39 -03:00
Thiago de Arruda
6383ea6e8e ui: Remove redundant cursor_goto calls 2015-02-16 23:17:38 -03:00
Thiago de Arruda
d225349dc6 input: Remove input_buffer_{save,restore}
The input buffer is only used for data that really came from another process and
is only visible to os/input.c. Remove the input_buffer_{save,restore} functions,
they are not necessary(Also can result in problems if data comes while the
typeahead is saved).
2015-02-16 23:17:38 -03:00
Thiago de Arruda
e17f92eb29 input: Fix handle_mouse_event function
Ignore all keys that aren't prefixed with KS_EXTRA.
2015-02-16 23:17:38 -03:00
Thiago de Arruda
2b6ffa61bf input: Prefer keycodes in input_enqueue key translation
This is required to correctly handle certain keys such as <delete>
2015-02-16 23:17:38 -03:00
Thiago de Arruda
8f31ebc4f7 macro: Add MAX macro and rename min to MIN 2015-02-16 23:17:38 -03:00