Commit Graph

3702 Commits

Author SHA1 Message Date
Maxime Coste
bd3ba77e96 Make Wrap highlighter only wrap on window width. 2017-05-07 16:26:14 +01:00
Maxime Coste
5ee21ec932 Respect tabstop in Buffer::offset_coord 2017-05-07 16:26:14 +01:00
Maxime Coste
57c2b32d20 Introduce highlighting phases and display setup computation
Highlighters now run in 3 phases:
Wrap, Move, and Colorize. That way we guarantee the wrap
highlighter runs first, then eventual line numbers/flags,
and finally the colorizers.

We also run a `compute_display_setup` method thats responsible
for computing the lines that will be displayed, eventually
scrolling the view to ensure the cursor is visible.
2017-05-07 16:26:14 +01:00
Maxime Coste
a4f9e29d60 Add a wrap highlighter 2017-05-07 16:26:14 +01:00
Maxime Coste
93408e4b76 Do not use any display information to determine where the cursor moves 2017-05-07 16:26:14 +01:00
Maxime Coste
3a3144f3f5 Fix use of invalidated iterator in the command map on exception
The command map can get mutated by command execution, so the iterators
can get invalidated (now that we use our curstom HashMap implementation,
all iterators are potentially invalidated by insert/removal)
2017-05-07 16:25:34 +01:00
Maxime Coste
80f1056851 Support appending selections to empty register
Fixes #1332
2017-04-25 17:25:44 +01:00
Maxime Coste
26a105b2b7 Style tweak in highglighters.cc 2017-04-24 07:04:15 +01:00
Maxime Coste
e264d189eb Add noexcept specifiers to unicode and utf8 functions 2017-04-23 12:47:26 +01:00
Maxime Coste
caed8a55c7 Set stdin to /dev/null instead of closing it when we dont have data to pipe to child
Fixes #1330
Fixes #1331
2017-04-22 09:39:55 +01:00
Maxime Coste
e722868c60 Fix generation of empty erase changes
Fixes #1308
2017-04-20 17:31:27 +01:00
Maxime Coste
ab3a255d58 Merge remote-tracking branch 'lenormf/command-force-write' 2017-04-20 16:25:24 +01:00
Maxime Coste
dbcddafbfd Change utf8::to_next/to_previous so that they are more symetrical
The previous implementation could yield different positions when
iterating forward and backward, leading to confusion in boost regex.

This makes an existing problem a bit more visible: iterating with
to_next and with read_codepoint wont behave the same way, as
read_codepoint will put the iterator onto the byte following the
utf8 codepoint, whereas to_next will put it on the next utf8
character start byte, which might be different if the buffer content
is not valid utf8.

Fixes #1195
2017-04-20 16:18:49 +01:00
Frank LENORMAND
51ab59cd36 src: Implement a write! command
This commit allows "forced" writes to a write-protected file, by
attempting to temporarily grant the current user write permissions on
it. After the buffer has been written, the previous permissions are
restored if the file existed, or set to 0644 otherwise.
2017-04-20 17:13:42 +03:00
Maxime Coste
30e6387071 Assume filename passed to write_buffer_to_file is already parsed 2017-04-20 09:55:56 +01:00
Maxime Coste
5103b15b84 Safer code for parsing commands
Fix some possible past the end of target string reads
Fixes #1310 (maybe, probably, who knows)
2017-04-19 22:04:03 +01:00
Maxime Coste
34bf8c23e1 Fix uninitialised value for cursor mode 2017-04-19 21:23:16 +01:00
Maxime Coste
bee2180da7 Do not try to split non range atoms in column highlighter
That means we wont have a very nice interaction between show_whitespaces
and column highlighters, but thats the simplest fix for now, if we want
a better behaviour we need to introduce a way to know that a replaced
range is splittable (meaning it means to have the same amount of columns
as the range it replaces)

Fixes #1275
2017-04-19 21:15:36 +01:00
Maxime Coste
52ffa98787 When not sending data to a subprocess, close its stdin
We were letting stdin untouched, which meant child processes had
access to our terminal input. That meant `!fmt` was trying to read
from our terminal input and catching keystrokes.

Fixes #1281
2017-04-17 20:39:24 +01:00
Maxime Coste
91bfd714e4 Place hardware terminal cursor at the current main cursor/prompt cursor position
Fixes #1318
Also fixes https://gitlab.com/gnachman/iterm2/issues/5408
2017-04-12 10:39:17 +01:00
Maxime Coste
80dd9ec4cb Name key '+' as plus and '-' as minus 2017-04-11 10:47:15 +01:00
Maxime Coste
413d8b7ddd Change multi modifier key syntax to be <c-a-space> instead of <ca-space>
Better fix for #1311
2017-04-11 10:44:14 +01:00
Maxime Coste
112bd156e4 Merge remote-tracking branch 'lenormf/fix-filter-backup-suffix' 2017-04-10 21:39:24 +01:00
Maxime Coste
c1c40a4b56 Remove some now unneeded uses of const String& params
HashMap supports finding String from StringView.
2017-04-10 21:33:20 +01:00
Maxime Coste
a4b82131e5 Add support for parsing multiple modifiers in keys
<ca-key> means control+alt key, <ac-key> works as well.
Fixes #1311
2017-04-10 21:19:56 +01:00
Frank LENORMAND
16068321c1 src: Support the -help flag
This commit allows a help message to be printed when a `-help` flag is
passed to the editor, which will subsequently quit after a summary and a
description of all the flags available have been displayed.

The GNU convention (passing a single `--help` argument to the program)
is also supported, although undocumented.

The man page also now documents the `+:` argument, although unrelated to
the original changeset.
2017-04-10 22:23:30 +03:00
Maxime Coste
94145f2a89 ncurses: When hiding the menu, recompute the info position 2017-04-04 08:36:21 +01:00
Maxime Coste
6ad2f721dd Do not disable autoinfo and autoshowcompl in non interactive context
Fixes #1303
Fixes #1152
2017-04-03 18:16:32 +01:00
Maxime Coste
f31e898f13 Change prompt completion to only update when idle 2017-04-03 18:11:09 +01:00
Maxime Coste
055ed5ff7e Expose hook params regex captures in hook_param_capture_N 2017-03-30 11:31:07 +01:00
Maxime Coste
2cfe3cae36 Add an InsertDelete hook 2017-03-30 10:38:56 +01:00
Maxime Coste
5f4f8991e5 Merge remote-tracking branch 'lenormf/fix-makefile-distclean' 2017-03-27 15:51:05 +01:00
Frank LENORMAND
ce7673b7b7 src: Fix the distclean Makefile target
Have the Makefile remove the actual binaries and generated documentation
when called with the `distclean` target
2017-03-26 10:49:17 +03:00
Maxime Coste
95e020ed77 Remove some unneeded type declarations in AliasRegistry 2017-03-24 20:13:18 +00:00
Frank LENORMAND
6b8587000b src: Introduce a -i suffix flag for filter backups
This commit allows the user to chose to backup the files on which a
filter has been run, by specifying a suffix for the backup file. The
former implementation always backed up the files with a hardcoded
".kak-bak" suffix.

When no suffix is specified on the command line, the files are not
saved.

Fixes #1288
2017-03-23 08:50:43 +03:00
Maxime Coste
ca17572301 Try to fix clang 3.5 compilation 2017-03-22 21:08:52 +00:00
Maxime Coste
777ba287e1 Merge faces in show_whitespaces highlighter instead of replacing it 2017-03-21 18:17:43 +00:00
Maxime Coste
8b1078e510 Use a HashMap to store the normal mode keymap 2017-03-16 23:40:38 +00:00
Maxime Coste
e44f95820e Fixes some clang-tidy warning and add a few missing meta.hh include 2017-03-16 23:34:02 +00:00
Maxime Coste
5f7464d90d Try to clean up option include a bit 2017-03-16 09:57:39 +00:00
Maxime Coste
7eaa058450 Move enum/flags option functions to option_types.hh 2017-03-15 18:28:32 +00:00
Maxime Coste
7d9f1df73a Small code tweaks regarding flags handling 2017-03-15 18:25:59 +00:00
Maxime Coste
458dd2e9fa Remove unneeded 'valid' helper template 2017-03-15 18:02:36 +00:00
Maxime Coste
db9b863222 Migrate WithBitOps template specialization to with_bit_ops function
This way we dont depend on knowing the base template to enable bit ops
on an enum type.
2017-03-15 18:00:58 +00:00
Maxime Coste
a49e175727 Migrate to a more value based meta programming model
Introduce Meta::Type<T> to store a type as value, and pass it
around, migrate enum_desc and option_type_name to this.
2017-03-15 17:42:02 +00:00
Maxime Coste
a88e58763b Move SelectionList::set implementation out of the header 2017-03-15 16:51:55 +00:00
Maxime Coste
5705b6c6f9 The canonical name for the documentation command is :doc, not :help 2017-03-15 11:49:00 +00:00
Frank LENORMAND
0acb350619 src: Make the cursor character an opening delimiter
This commit allows the editor to consider the character under the cursor
as an opening delimiter when using an object selector, instead of
ignoring it and looking for one before the cursor.
2017-03-15 14:39:40 +03:00
Frank LENORMAND
2aa5d3b016 src: Align the assistant in the middle of the popup 2017-03-14 19:06:09 +03:00
Dan Rosén
5a403a9611 Increase modelinefmt configuration power 2017-03-11 21:43:51 +01:00
Maxime Coste
34da4bf08b Add dilbert in the ui_options doctring 2017-03-10 12:09:09 +00:00
Maxime Coste
564da076a6 Merge remote-tracking branch 'lenormf/assistant-dilbert' 2017-03-10 12:06:35 +00:00
Maxime Coste
0faa5567ca Fix crash on non utf8 files trigering highlighting of backward ranges
Fixes #1274
2017-03-09 23:40:34 +00:00
Maxime Coste
a0b42323ed Add a -debug flag to :edit to set the buffer as debug data
As for the *debug* buffer, buffers with the debug flag wont get
used for cycling through buffer, or word completion.
2017-03-08 19:33:25 +00:00
Frank LENORMAND
59b65bb9fb ncurses: Add a Dilbert assistant
Drawn by myself.
2017-03-08 20:03:29 +03:00
Maxime Coste
da206d9323 Try to please clang-3.5 2017-03-07 17:21:55 +00:00
Maxime Coste
dc7c5f6e67 Collapse undo groups during an eval command 2017-03-07 16:18:09 +00:00
Maxime Coste
89fa6d4fbf Small code simplification 2017-03-07 16:11:40 +00:00
Maxime Coste
30c9b3c426 Merge branch 'patch-1' of git://github.com/guillaumecherel/kakoune 2017-03-07 15:52:44 +00:00
Maxime Coste
a1a566e921 Cleanup hash_map code 2017-03-07 15:48:04 +00:00
Maxime Coste
ba02498576 Expand a bit the hash map profiling code 2017-03-07 14:01:01 +00:00
guillaumecherel
81e7158bc1 Update Makefile 2017-03-07 14:20:09 +01:00
Maxime Coste
f3fdc24383 Remove temporary stats code from HashMap 2017-03-07 01:15:41 +00:00
Maxime Coste
f0ae0b8410 Replace IdMap with HashMap 2017-03-07 01:12:37 +00:00
Maxime Coste
6373338c50 Replace uses of UnorderedMap with HashMap 2017-03-07 01:03:26 +00:00
Maxime Coste
e9f93f1b2f Add support for HashMap options types 2017-03-06 22:25:08 +00:00
Maxime Coste
420373475e Introduce a custom HashMap implementation along with a quick benchmark 2017-03-06 22:25:08 +00:00
Maxime Coste
6757ddc6cb Simplify AliasRegistry::remove_alias 2017-03-06 19:44:36 +00:00
Maxime Coste
ed2d50ecef Remove unused AliasRegistry::flatten_aliases method
We do not complete alias names anymore, so this method is not
needed.
2017-03-04 19:45:41 +00:00
Maxime Coste
cc88b0f586 Change word object selector to fail if the cursor is not on a word char 2017-03-04 18:33:50 +00:00
Maxime Coste
887232987c Refactor surround unit test code 2017-03-04 17:43:24 +00:00
Maxime Coste
ed3c48057d Refactor regex based selection code 2017-03-03 23:43:54 +00:00
Maxime Coste
1728c67fef Fix indent selection respect for original selection cursor position
Fixes #1233
2017-03-03 22:03:20 +00:00
Maxime Coste
2fa98e04c3 Merge remote-tracking branch 'ekie/hook' 2017-03-03 21:14:14 +00:00
Maxime Coste
f8a625bc2f Merge remote-tracking branch 'occivink/master' 2017-03-03 21:13:16 +00:00
Maxime Coste
134a5d1f3e Merge remote-tracking branch 'lenormf/fix-spell' 2017-03-03 21:10:51 +00:00
Maxime Coste
ddc5e958e6 Return an optional selection in most selectors, fail rather than keep current
Instead of returning the current selection when a selector fails, return
an empty Optional<Selection>. That means object selections will now
remove the selections that dont match the object.
2017-03-03 20:17:11 +00:00
Maxime Coste
6759511b9e Ensure main selection index is correct directly in SelectionList::remove 2017-03-03 20:17:11 +00:00
Maxime Coste
8a1e5d12ac Make <a-space> throw on invalid index or last selection 2017-03-03 20:17:11 +00:00
Maxime Coste
e3cfde6d07 Add docstring support for mappings, and use them in autoinfo
Fixes #105
Fixes #1100
Closes #1165
2017-03-03 20:16:36 +00:00
Olivier Perret
033b259e5b <space>, <a-space>: throw on invalid preconditions 2017-03-03 13:50:00 +01:00
Frank LENORMAND
aecc0fbb0f src: Fix the string conversion of range faces
Fixes #1250
2017-03-01 22:16:35 +03:00
Eike Plack
a35f50d832 Add RawKey to hook completion list 2017-03-01 03:28:23 +01:00
Maxime Coste
7d487e3b4c Small naming tweak 2017-02-27 20:44:38 +00:00
Maxime Coste
e5e705e151 Fix clang warnings about uninitialized timestamp field
Closes #1241
2017-02-27 20:29:53 +00:00
Maxime Coste
88752ef895 Compile optimized and debug into different files, make kak a symlink 2017-02-27 20:11:56 +00:00
Maxime Coste
1f3abde926 Cleanup some tabby mess in the Makefile 2017-02-27 20:11:27 +00:00
Maxime Coste
8703f30063 Tweak some character categorization function implementations 2017-02-23 00:56:40 +00:00
Maxime Coste
55f6ca238f Refactor get_words to be simpler and faster 2017-02-23 00:51:54 +00:00
Maxime Coste
73bb260e6c Fix support for non ascii chars in completion_extra_word_char 2017-02-23 00:35:27 +00:00
Maxime Coste
2f7313ad59 Slight code cleanup in utf8_iterator.hh 2017-02-23 00:30:59 +00:00
Maxime Coste
a39f2b0c71 Refactor WordDB::add_words to be slightly faster 2017-02-23 00:26:24 +00:00
Maxime Coste
d9abc2a156 Refactor StringData and StringRegistry to remove need for purging
Purging unused strings could get pretty expensive with a lot of
interned strings as it requiered iterating on all of them. Use
a flag on the refcount of the StringData to see if the string
is interned, and notify the StringRegistry in this case.

This should improve the speed of editing big files with many words,
such as the one described in #1195
2017-02-23 00:03:32 +00:00
Maxime Coste
7a143a7f7c Use false instead of 0 in the kak_assert do while 2017-02-23 00:03:11 +00:00
Frank LENORMAND
98cfbc7c3c Properly wrap kak_assert into a do-while scope
Expanding the `kak_assert` macro to either an `if` statement or nothing
leads to issues when the macro is used in a conditional statement that
doesn't use braces.

Example: ncurses_ui.cc:476, in non debug mode, the macro will expand to
an empty line, resulting in the `ungetch` call not being executed if the
`ioctl` call succeeds (line 448).
2017-02-22 13:04:25 +03:00
Maxime Coste
467f5547d5 Try to please clang-3.5 2017-02-22 09:44:19 +00:00
Maxime Coste
e2f6b9a393 Fix overly strict backward_sorted_until
A change that ended exactly where the previous one started was not
considered backward sorted. Leading to some very bad performances in
certain cases, like '100000o<esc>u'
2017-02-20 19:46:12 +00:00
Maxime Coste
fe2d0fab71 Fix performance of word completion with many different selections
Fixes #1228
2017-02-20 19:28:02 +00:00
Maxime Coste
5eef2b9105 Correctly handle mutation of the watcher list while iterating on them
Fixes #1227
2017-02-20 13:50:30 +00:00
Maxime Coste
2b01da530d Fix hook list in commands.cc 2017-02-19 14:14:22 +00:00
Maxime Coste
9fdbcf761d Display an info box on startup with recent breaking changes 2017-02-19 13:59:44 +00:00
Maxime Coste
9271f0a87d Fix handling of disabled_hooks regex 2017-02-19 13:59:34 +00:00
Maxime Coste
edc2a88643 Rename BufNew and BufOpen hooks to BufNewFile and BufOpenFile
Fixes #1225
2017-02-19 13:08:06 +00:00
Maxime Coste
889a2144d4 Copy the list of hooks to run before iterating on them and running them
Running hooks could result in the hook list getting mutated, leading
to potential crashes.

Fixes #1222
2017-02-19 12:08:13 +00:00
Maxime Coste
38102595ef Small naming tweak in HookManager 2017-02-19 11:52:31 +00:00
Maxime Coste
c3af384c70 Detect when -client, -buffer or -try-client are used at the same time
Fixes #1218
2017-02-15 18:59:37 +00:00
Maxime Coste
0a1cb4b9b1 Detect when switches are specified more than once
Fixes #1219
2017-02-15 18:55:11 +00:00
Maxime Coste
9e0f085b86 Reorganize code in main.cc 2017-02-14 13:54:45 +00:00
Maxime Coste
d470bd2cc9 Make numeric registers setable
Fixes #1214
2017-02-14 00:02:01 +00:00
Maxime Coste
e3a04dfa65 Fix RegisterRestorer not handling potential throws on register assign
This should fix part of #1214
2017-02-13 23:31:16 +00:00
Maxime Coste
4f18e56320 Fix non-returning parse_key lambda 2017-02-13 14:02:09 +00:00
Maxime Coste
2edb7d62ef Add support for -on-change and -on-abort to prompt
Fixes #1209
2017-02-12 12:51:58 +00:00
Maxime Coste
9ba1665e58 Refactor show_whitespaces a bit 2017-02-09 23:52:38 +00:00
Maxime Coste
6163134f30 Merge remote-tracking branch 'lenormf/show-whitespaces-flags' 2017-02-09 23:33:08 +00:00
Maxime Coste
4ae441db68 Merge remote-tracking branch 'Delapouite/decl-completer' 2017-02-09 23:26:12 +00:00
Maxime Coste
86bba5d9d2 Merge remote-tracking branch 'Delapouite/line-flags' 2017-02-09 23:26:05 +00:00
Delapouite
0cf94292e4 Add command completer for types to declare-option 2017-02-09 10:18:13 +01:00
Delapouite
cfb2b4fade Fix missing new line char in declare_option_cmd info 2017-02-09 09:01:49 +01:00
Maxime Coste
1c63d28f15 Fix Buffer::offset_coord that was dropping the target coordinate 2017-02-07 23:13:14 +00:00
Maxime Coste
5342d67fa4 Remove unneeded padding in relative line numbers highlighting
We were still adding one more char to the line number width in case
it would contain a minus sign. The minus signs are not used anymore
in relative line numbering so we dont need to keep that addtional
char which is always a blank.
2017-02-07 23:01:23 +00:00
Maxime Coste
ce2b85ddac Add -match-capture support for regions higlighter
Closes #837
2017-02-06 23:00:13 +00:00
Maxime Coste
45b145f540 Small layout tweak for Buffer::HistoryNode 2017-02-06 13:33:20 +00:00
Frank LENORMAND
5d86b58a38 Allow modifying the characters used when highlighting whitespace
This commit adds the following flags to the `show_whitespaces`
highlighter, with a one character long parameter:

 * `-lf`: character replacing line feeds
 * `-spc`: character replacing spaces
 * `-nbsp`: character replacing non breakable spaces
 * `-tab`: character replacing a tabulation
 * `-tabpad`: character used as padding after a tabulation to satisfy
              the `tabstop` option
2017-02-04 10:21:13 +03:00
Maxime Coste
cb2e1a17b3 Fix some bugs in non blocking pipe writing 2017-02-03 18:40:03 +00:00
Maxime Coste
f500af9023 Merge remote-tracking branch 'ekie/move_buffer_end' 2017-02-03 13:49:33 +00:00
Maxime Coste
c793ef3aa8 Store shell-candidates completions in the Completion memory domain 2017-02-03 13:42:47 +00:00
Maxime Coste
02b7e58481 Make piping data into shell commands non blocking
Fixes #1180
2017-02-03 01:14:42 +00:00
Maxime Coste
d90919568a Also execute prompt callback when just starting
incsearch will immediatly display the result of using an empty
string (reusing the search register content).

Fixes #1174
2017-02-01 23:04:37 +00:00
Maxime Coste
bc0dfa9e8f Use <a-'> for backward rotate selection and move rotate content to <a-"> 2017-02-01 22:53:42 +00:00
Maxime Coste
65bbc19d6f Change n behaviour to only select next match for main selection
Select next match for all selections is still available as /<ret>
Fixes #1173
2017-02-01 20:00:05 +00:00
Maxime Coste
6a0354a597 Tweak ranked match ordering 2017-01-31 22:30:23 +00:00
Maxime Coste
472f5149c0 Formatting fix 2017-01-31 21:46:20 +00:00
Maxime Coste
f44415cee4 Add some noexcept to pointer policies 2017-01-31 21:45:55 +00:00
Eike Plack
01eceebf75 Support the vim behaviour for +line syntax
* Ommitting the linenumber will move to buffer end
2017-01-31 19:44:27 +01:00
Maxime Coste
34870eb353 Rework NCurses key parsing to properly handle <a-special key> 2017-01-30 13:38:56 +00:00
Maxime Coste
f30e164232 Make SharedString::create take a list of StringViews 2017-01-30 13:38:38 +00:00
Maxime Coste
9d09d14d99 Warning fix in ranked_match.cc 2017-01-30 11:22:14 +00:00
Maxime Coste
192ea9a9d9 Fix explicit insert completion menu/info not hiding
Fixes #1168
2017-01-30 10:32:29 +00:00
Maxime Coste
632e05d830 Fix infinite loop when comparing RankedMatches containing invalid utf8
If we had a word containing some invalid utf8, like a wrong sequence
of continuation bytes, we would infinitely loop back to the previous
valid character start.

Fixes #1157
2017-01-29 23:50:33 +00:00
Maxime Coste
1ff60ff592 Fix some uninitialized values 2017-01-29 23:37:42 +00:00
Maxime Coste
cb395d39f8 Use iswlower instead of islower
islower can crash with big codepoints, and is incorrect anyway.
2017-01-29 23:37:10 +00:00
Maxime Coste
565d835d57 Fix option name in haskell.kak 2017-01-29 16:10:48 +00:00
Maxime Coste
0051a4f896 Remove unneeded assignment to null in RefPtr::release 2017-01-29 14:26:41 +00:00
Maxime Coste
2052b225d9 Detect too deep command call stack
Fixes #1163
2017-01-29 13:56:05 +00:00
Maxime Coste
753f3a50d1 Make StringView and unit types trivial types 2017-01-29 13:49:45 +00:00
Maxime Coste
0cb192921a Remove unused WindowAndSelections timestamp field
The SelectionList already has a timestamp.
2017-01-29 12:50:16 +00:00
Maxime Coste
2b6fc6beb7 Remove unused Diff::posA field 2017-01-29 12:49:52 +00:00
Maxime Coste
68b92b9ac1 Make BufferIterator only a bidirectional iterator
Distance computation is too expensive on BufferIterators to
treat them as random access.
2017-01-28 13:06:03 +00:00
Maxime Coste
072064407a Remove hash from StringData
Maintaining the hash value of strings is not worth it as we only
use it for buffer reload, but pay for it on any buffer modifications.
2017-01-28 13:04:55 +00:00
Maxime Coste
125c8b7e80 Fix fifo reading not handling potential errors from the read call
Fixes #1153
2017-01-25 13:55:20 +00:00