summaryrefslogtreecommitdiff
path: root/text-motions.c
AgeCommit message (Collapse)Author
2023-07-16partial revert of commit f55312baJohn Vogel
text_paragraph_prev(): Bring back the previous usage of text_iterator_byte_get() in the while conditional and text_iterator_char_prev() in the loop body. Fixes #1028 - { moves back a paragraph too much if cursor at start of line
2020-09-17text: improve text_line_down on the last line of the fileMarc André Tanner
Fix #873
2020-01-28Merge branch 'master' of https://github.com/eafe/visMarc André Tanner
2020-01-26vis: don't search off screen when highlighting matchesGeorgi Kirilov
2020-01-24text: unconditionally use REG_NOTEOL for backward searchesMarc André Tanner
This fixes empty backward searches ?$ starting at the line end.
2020-01-23text: fix search wrapping for overlapping matchesMarc André Tanner
Previously, searches wrapping around did not report any results if they started from within the eventual match. Fix this by enlarging the search area to the whole text after reaching the first boundary. See also #787.
2020-01-23text: fix spurious regex anchor matchesMarc André Tanner
The regex anchors ^ and $ must not match at the start/end of the search range unless it is preceded/succeeded by a new line. This is implemented at the text-motion layer by passing the appropriate REG_NOT{B,E}OL flags to the search backend, meaning the caller can influence the anchor behavior depending on the context. This is important as for example in the command language the anchors apply to existing selections, not line boundaries.
2020-01-12vis: fix search wrapping bugszsugabubus
1) “$” matches in the middle of the text. visvis ^ - standing here \/ - at first we search forward-\ \_/ - wrap, if nothing found <---/ After wrapping, in the second range “$” will treat end of the range as EOL so “/vis$” will wisely match and moves cursor to the first column. 2) No match after wrapping. vissssss ^^ - standing here or here \\____/ - search this before wrapping ---\ V - search range after wrapping <--/ “/vis” will *not* match (after wrapping), because it crosses ranges. --- So the real solution would be that instead of the end position, the start position of the possible match should be limited because a match can cross the search ranges. To keep things simple, simply search two whole text after wrapping. visvis \____/
2018-07-11add tab character to special characters array (#1)eafe
The special characters array doesn't contain the tab character thus causing issue 711. By adding the tab character to the array, quotes are matched correctly across tab characters, too. Although much less used, other white space characters such as \v, \f, and \r should perhaps be added as well.
2018-04-08Fix "parenthese" in identifiersTwoFinger
2018-03-14Merge branch 'paranthese-typo' of https://github.com/Two-Finger/visMarc André Tanner
2018-03-11Reset parsing state after mbrtowc(3) failureMarc André Tanner
The standard says "if an encoding error occurs ... the conversion state is unspecified".
2018-03-05Fix a typo in identifiersTwoFinger
2018-02-27text-motion: ignore blank lines for next/prev paragraph motionsMarc André Tanner
2018-02-27text-motion: implement text_line_blank_{prev,next}Marc André Tanner
2017-04-09text: use MB_LEN_MAX instead of MB_CUR_MAXMarc André Tanner
2017-04-09text: drop special handling of \r\n line endingsMarc André Tanner
2017-04-08text: simplify \r\n handlingMarc André Tanner
2017-04-04vis: add motions to move by codepointsMarc André Tanner
Some people might prefer this for <Backspace> behavior. Except for that and debugging purposes using `ga` and `g8` it is not yet that useful.
2017-03-19vis: make sure g_ does not cross line boundariesMarc André Tanner
This also eliminates dead code as reported by CID 142387.
2017-02-25vis: fix $ motion for lines containing \rMarc André Tanner
2017-02-25vis: make ^ and g_ only skip blank (spaces+tabs) charactersMarc André Tanner
2017-02-24vis: fix ^ motion for blank lines terminated by \r\nMarc André Tanner
2017-02-15vis: remove motion and text objects related to C functionsMarc André Tanner
These do not really belong into the editor core. If desired they could be implemented in Lua instead.
2017-02-15text-motions: remove unused text_line_lastcharMarc André Tanner
2016-10-09vis: fix g_ motion to never cross line boundariesMarc André Tanner
2016-08-24text-motions: improve matching quotation marks heuristicMarc André Tanner
Prefer quotation marks on the same line to when looking for matching pairs. Improves #358.
2016-04-27text-motions: fix character next motion within a lineMarc André Tanner
2016-04-13text-motion: simplify implementation of [{, ]}, [( and ]) motionsMarc André Tanner
2016-04-12Add "[(" and "])" motions for jumping to a parenthese pair's start/endRob Pilling
2016-04-12Add "[{" and "]}" motions to jump to a block's start/endRob Pilling
2016-04-11text-motions: fix misspelled function name "is_word_boundry"Steven Noonan
Should be "is_word_boundary" Signed-off-by: Steven Noonan <steven@uplinklabs.net>
2016-04-06text-motion: restore old text_{line_,}find_prev behaviorMarc André Tanner
This partially reversts the "Fix to/till movements" commit 0d4093c3371079c5f75055338f0341f684542465 The pos += len hunk was interfering with other code which does not want this behavior. The original issue should be fixed directly within the to/till movements.
2016-03-23Remove identically replicated copyright comments from source filesMarc André Tanner
2016-02-13Convert call sites of text_line_char_{get,set} to text_line_width_{get,set}Marc André Tanner
2016-02-13text-motion: add functions to get/set position based on display widthMarc André Tanner
This is inherently a tricky thing to do because we cannot rely on the current display state. The reason being that the position/cursor which is modified might not currently be in the visible area. Tabs are a particular problem because they have a variable display width. However this new code is certainly not worse than the current behaviour which relies on text_line_char_{get,set} and thus simply counts graphemes. Not yet completely convinced that this is the right approach.
2016-02-03text-motion: hide ugly casts for isboundary behind a #defineMarc André Tanner
2016-02-03text-motion: hide ugly casts for isspace behind a #defineMarc André Tanner
2016-02-03text-motion: export custom word motion functionsMarc André Tanner
2016-02-03fix {, }, (, ) movementsMarkus Teich
- split the functions, so the algorithms are more clear - paragraph movements work backwards - paragraph movements work consistently with \r\n line breaks always placing the cursor on the first character of the first empty line before/after the paragraph - sentence movements now work better at BOF/EOF - save a few lines of code
2016-01-27text-motion: change text_bracket_match APIMarc André Tanner
2016-01-20Fix to/till movementsMarkus Teich
Some corner cases allowed to move between lines with the to/till movements. The change in find_prev serves two purposes. When searching for a string which the cursor is already above the match, this match is returned (pos += len). Secondly there was a failure when searching for strings with len == 1 which lead to `matched == 0` which was always true, even if the string was not found, therefore leading to a wrong return value.
2016-01-10text-motion: fix integer overflow in text_search_{forward,backward}Marc André Tanner
2015-11-23Cast argument to ctype.h is* functions to unsigned charMarc André Tanner
The signedness of char is implemenation defined, calling the is* type of functions with negative values leads to undefined behaviour.
2015-11-08Update year numbers in Copyright clauseMarc André Tanner
2015-11-07text-motion: do not treat ' as string delimiter in match bracketMarc André Tanner
Currently symbols inside a string are ignored. This means that if the opening (closing) symbol is inside (outside) the string while the closing (opening) one is outside (inside), it will not be matched. It is not yet clear whether this "optimization" is useful. Closes #97
2015-08-07vis: limit to/till movements to current lineMarc André Tanner
2015-08-02text-motion: make text_bracket_match more robustMarc André Tanner
Brackets which occur inside strings are ignored.
2015-08-02vis: add motions [[, [], ][, ]]Marc André Tanner
They behave not like in vim, but instead try to find the start/end of C-like function definitions. The first character stands for the direction [ for backwards, ] for forwards. The second character denotes the start [ or end ] respectively.
2015-08-01text-motion: fix text_find_{next,prev}Marc André Tanner
It is after all a stupid O(n*m) algorithm, hence restart after a failed partial match. Code like this would benefit from a proper test suite ...