Commit Graph

163 Commits

Author SHA1 Message Date
Anton Ovchinnikov
9925b3a047 Remove redundant casts 2015-03-09 00:40:50 +01:00
Michael Reed
49e7164165 Macro cleanup: USER_HIGHLIGHT 2015-03-05 19:03:36 -05: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
7dd48d7af0 Enable -Wconversion: mark.c.
Refactoring summary:
- MB_STRNICMP: Inlined.
- MB_STRNCMP: Inlined.
2015-02-18 20:54:13 -05: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
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
Björn Linse
f468fb70cb api/vim: allow guis and tests to retrieve the entire color table 2015-02-02 14:56:58 -03:00
Marco Hinz
4d70aae770 Add EndOfBuffer hl group for ~ lines after the last line in buffers
This makes it possible to highlight the lines starting with ~ at the end
of buffers and other elements highlighted using NonText.

As proposed by mhinz at
https://groups.google.com/forum/#!topic/vim_dev/p3de1iU1GXI/discussion
2015-02-02 01:16:41 -05:00
Eliseo Martínez
31dacda874 Remove long_u: (various): Refactor long_u. 2015-01-19 19:41:27 +01:00
Justin M. Keyes
5c6348e999 Merge pull request #1816 from Pyrohh/macro_cleanup
Macro cleanup
2015-01-15 09:59:45 -05:00
Michael Reed
d2e7cce560 Macro cleanup: Miscellaneous
These were found with -Wunused-macros. There are many more macros which
triggered that warning, but they were primarily part of larger sets of
macros so leave them alone.
2015-01-14 22:23:16 -05:00
Michael Reed
d86ebc7afb Macro cleanup: PROTO
Regarding dict_lookup() in eval.c: both definitions are the same, the
only difference being the spacing between the indirection operator and
the indentation level.
2015-01-14 15:07:16 -05:00
Thiago de Arruda
3e9c55b51b main: Fix color schemes for abstract_ui
- Set 't_Co' to 256 at startup. The value can be changed by the user for
  compatibility with terminals that are less capable.
- `has('gui_running')` will return 1 if at least one rgb UI is attached.

Even though these changes are hacky, they are necessary to make the transition
to the new UI architecture smoother.
2015-01-13 21:21:20 -03:00
Thiago de Arruda
8f3e61a043 syntax: Refresh UI when the color scheme changes 2015-01-13 21:21:20 -03:00
Thiago de Arruda
29bc6dfabd ui: Add 'rgb' parameter to ui_attach
When set to false, nvim will send cterm color numbers with `highlight_set`.
2015-01-13 11:54:52 -03:00
Thiago de Arruda
631099d02a syntax: Take rgb fg/bg when allocating cterm attr number 2015-01-13 11:54:52 -03:00
Thiago de Arruda
926503c84e ui: Fix ui resizing and change some method names 2015-01-13 11:54:28 -03:00
Thiago de Arruda
fc8f768690 ui: Add update_fg/update_bg methods
It is necessary to notify the UI when the default background/foreground colors
change in order to render correctly.
2015-01-13 11:53:27 -03:00
Michael Reed
16d0976150 Remove QNX/pterm remnants
The function qnx_init() (wrapped in an ifdef in main.c) doesn't even
exist.
2015-01-11 21:00:06 -05:00
Eliseo Martínez
7f7262e933 Cleanup: Rename getdigits() family functions. 2015-01-11 21:04:08 +01:00
Eliseo Martínez
04c0658024 Cleanup: Refactor getdigits().
Problem  : getdigits() currently returns a long, but at most places,
           return value is casted (unsafely) into an int. Making casts
           safe would introduce a lot of fuss in the form of assertions
           checking for limits.
Note     : We cannot just change return type to int, because, at some
           places, legitimate long values are used. For example, in
           diff.c, for line numbers.
Solution : Introduce new functions:
           - get_digits()      : Gets an intmax_t from a string.
           - get_int_digits()  : Wrapper for ints.
           - get_long_digits() : Wrapper for longs.
           And replace getdigits() invocations by the appropiate
           wrapper invocations.
2015-01-11 17:18:39 +01:00
Eliseo Martínez
31c8440fee Remove long_u: term: Enable -Wconversion. 2015-01-10 10:52:21 +01:00
Felipe Oliveira Carvalho
3c857900fe Define and use the ARRAY_SIZE macro
A similar macro is defined in the Linux kernel [1].

To refactor the code I used a slightly modified Coccinelle script I found in
[2].

```diff
// Use the macro ARRAY_SIZE when possible
//
// Confidence: High
// Copyright: (C) Gilles Muller, Julia Lawall, EMN, DIKU.  GPLv2.
// URL: http://www.emn.fr/x-info/coccinelle/rules/array.html
// Options: -I ... -all_includes can give more complete results

@@
type T;
T[] E;
@@

- (sizeof(E)/sizeof(*E))
+ ARRAY_SIZE(E)

@@
type T;
T[] E;
@@

- (sizeof(E)/sizeof(E[...]))
+ ARRAY_SIZE(E)

@@
type T;
T[] E;
@@

- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)

@n@
identifier AS,E;
@@

- #define AS(E) ARRAY_SIZE(E)

@@
expression E;
identifier n.AS;
@@

- AS(E)
+ ARRAY_SIZE(E)
```

`spatch --in-place --sp-file array_size.cocci -I src/ -I build/include/ -I build/src/nvim/auto/ src/nvim/*.c`

[1] http://lxr.free-electrons.com/source/include/linux/kernel.h#L54
[2] http://www.emn.fr/z-info/coccinelle/rules/#macros
2014-12-18 15:41:37 -03:00
Eliseo Martínez
885661d25b Fix warnings: syntax.c: get_id_list(): Double free: FP.
Problem    : Double free @ 5213.
Diagnostic : False positive.
Rationale  : I haven't been able to find the real reason why this is
             signaled. Nonetheless, I've been able to track down the
             introduction of this warning to commit
             77135447e0.
             The change there affecting this function is just a
             transformation maintaining semantics. So, this must be a
             FP, though I can't explain why.
Resolution : Revert changes in mentioned commmit touching this function.
2014-12-17 22:10:14 +01:00
Felipe Oliveira Carvalho
0bc40e660c Simple refatorings that didn't fit the pattern of the last commit 2014-12-13 23:36:11 -03:00
Felipe Oliveira Carvalho
77135447e0 Reduce indentation level by early returning or continuing loop
Replace code like this

```c
func() {
    if (cond) {
	...
	...
	...
    }
    return ret;
}
```

```c
for (...) {
    if (cond) {
	...
	...
	...
    }
}
```

with

```c
func() {
    if (!cond) {
	return ret;
    }
    ...
    ...
    ...
}
```

```c
for (...) {
    if (!cond) {
	continue;
    }
    ...
    ...
    ...
}
```
2014-12-13 23:36:11 -03:00
Felipe Oliveira Carvalho
e11a5699be Use GA_DEEP_CLEAR where appropriate 2014-12-11 20:22:37 -03:00
Thiago de Arruda
86542c6fd0 syntax: Use RGB/GUI attribute information for "abstract_ui"
Instead of using classic cterm color numbers and attributes, treat "abstract_ui"
as a GUI: Pass rgb color numbers and gui attributes when the "highlight_set" UI
method is called. The terminal UI will have to translate RGB color information
to an appropriate color number, and the "term"/"cterm" :highlight keys will
eventually be deprecated.
2014-12-08 23:44:24 -03:00
Thiago de Arruda
bf6bb27e79 ui: Remove redundant ui.h includes
Also move read_error_exit to os/input.c
2014-11-27 15:00:30 -03:00
Thiago de Arruda
1865b8c1c1 ui: Remove ui_delay, ui_breakcheck and ui_set_shellsize
These functions only used to call another os_* function, so remove them and
replace all occurences in the project.
2014-11-27 14:27:18 -03:00
Eliseo Martínez
fcd5a8643c Fix warnings: syntax.c: get_id_list(): Double free: FP.
Problem    : Double free @ 5213.
Diagnostic : False positive.
Rationale  : Suggested error path contains two consecutive invocations
             of `ends_excmd(*p)` having different results, which is not
             possible. First invocation is before the while loop. Second
             invocation is the while loop condition itsef.
Resolution : Refactor while loop into do-while loop. That removes the
             impossible path from analysis, and, in addition, is a bit
             more efficient.
2014-11-15 12:49:18 +01:00
Eliseo Martínez
ce9c4e9a6f Fix warnings: syntax.c: syn_regexec(): Uninitialized arg: MI.
Problem    : Uninitialized argument value @ 2863.
Diagnostic : Multithreading issue.
Rationale  : Error can only occur if global `syn_time_on` is changed
             while the function is executing.
Resolution : Use local copy of gloval var.
2014-11-15 12:49:18 +01:00
Wayne Rowcliffe
9b6f192693 Replace FOR_ALL_WINDOWS with FOR_ALL_WINDOWS_IN_TAB(curtab) 2014-09-24 19:00:50 -05:00
Wayne Rowcliffe
fe99930c46 Convert FOR_ALL_WINDOWS to use a locally declared pointer 2014-09-08 17:27:41 -05:00
André Twupack
16a04bae0a vim-patch:7.4.318 #968
Problem:    Check for whether a highlight group has settings ignores fg and bg color settings.
Solution:   Also check cterm and GUI color settings. (Christian Brabandt)

https://code.google.com/p/vim/source/detail?r=5c47dacf397c1c65d2dfc237b3ff395c66ec3d4d
2014-08-18 01:25:17 +00:00
Florian Walch
4fa8a0c43c clang-analyzer: Reduce scope in syntax.c. 2014-08-07 15:19:59 +02:00
Nicolas Hillegeer
0564f781ab vim: move disptick_T from vim.h to syntax_defs.h
Make vim.h smaller, bit by bit.
2014-07-16 19:05:34 +02:00
Nicolas Hillegeer
db7cd61f62 profiling: implement on top of os_hrtime()
Should be better than gettimeofday() since libuv uses higher resolution
clocks on most UNIX platforms. Libuv also tries to use monotonic clocks,
kernel bugs notwithstanding, which is another win over gettimeofday().

Necessary for Windows, which doesn't have gettimeofday(). In vanilla vim,
Windows uses QueryPerformanceCounter, which is the correct primitive for
this sort of things, but that was removed when slimming up the codebase.
Libuv uses QueryPerformanceCounter to implement uv_hrtime() on Windows so
the behaviour of vim profiling on Windows should now be the same.

The behaviour on Linux should be different (better) though, libuv uses more
accurate primitives than gettimeofday().

Other misc. changes:
- Added function attributes where relevant (const, pure, ...)
- Convert functions to receive scalars: Now that proftime_T is always a
  (uint64_t) scalar (and not a struct), it's clearer to convert the
  functions to receive it as such instead of a pointer to a scalar.
- Extract profiling funcs to profile.c: make everything clearer and reduces
  the size of the "catch-all" ex_cmds2.c
- Add profile.{c,h} to clint and -Wconv:
  - Don't use sprintf, use snprintf
  - Don't use long, use int16_t/int32_t/...
2014-07-16 17:12:34 +02:00
Pavel Platto
0868818d3e Include stdbool.h in some files which use it
Done by manual inspection of the output of this script:
grep -r -l -w "bool\|true\|false" * | grep 'c$\|h$' > has_bool
grep -r -l "stdbool.h" * | grep 'c$\|h$' > has_include
grep -F -x -v -f has_include has_bool
2014-07-11 18:33:07 -04:00
Brandon Coleman
0fff487690 move errno.h include out of vim.h 2014-07-09 00:18:20 +02:00
Brandon Coleman
e69cfa6c15 move assert.h include out of vim.h 2014-07-09 00:18:19 +02:00
Brandon Coleman
bf219e1442 move <inttypes.h> include out of vim.h 2014-07-09 00:18:19 +02:00
Brandon Coleman
82b71a3056 move ascii.h include out of vim.h 2014-07-09 00:18:18 +02:00
Klemen Košir
a568e8b644 Replaced most TRUE/FALSE macros in arabic, mbyte and spell. #645 2014-07-08 17:34:08 +00:00
Klemen Košir
ef34a0ab13 Replace int with bool in some files. #654 2014-07-08 17:25:48 +00:00
Felipe Oliveira Carvalho
5ed74cfb7c Introduce ga_append_via_ptr() and GA_APPEND_VIA_PTR()
Similar to GA_APPEND(). Replaces this pattern:

    ga_grow(&ga, 1);
    item_type *p = ((item_type *)ga.ga_data) + ga.ga_len;
    p->field1 = v1;
    p->field2 = v2;
    ga.ga_len++;
2014-06-30 03:57:50 -04:00
Felipe Oliveira Carvalho
45e7814e6a Introduce GA_APPEND()
This macro is used to append an element to a growable array. It replaces this
common idiom:

   ga_grow(&ga, 1);
   ((item_type *)ga.ga_data)[ga.ga_len] = item;
   ++ga.ga_len;
2014-06-30 03:57:50 -04:00
Felipe Oliveira Carvalho
be3a4b6ca8 ga_growsize should be >= 1
I know it could be 0 sometimes. Running the tests with
`assert(gap->ga_growsize > 0)` in ga_grow() crashes nvim while running the
tests.

 - Add a setter for ga_growsize that checks whether the value passed is >=1 (log
	 in case it's not)
 - log when ga_grow() tries to use a ga_growsize that's not >=1
 - use GA_EMPTY_INIT_VALUE is many places
2014-06-30 03:57:50 -04:00
Felipe Oliveira Carvalho
f7e64c3c5f No OOM in vim_strnsave_up()
And some cleanup in strsave_up()
2014-06-16 01:36:30 -03:00
Douglas Schneider
bdf79dd619 Replace vim_strncpy calls: syntax.c 2014-06-13 18:08:21 -04:00