Commit graph

96 commits

Author SHA1 Message Date
Dmitry Maluka
dda79ca70e
Add statusline.inactive and statusline.suggestions color groups (#1832)
Add color groups for displaying statuslines of inactive split panes
and the suggestions menu with colors different from the statusline
of the active pane.
2023-03-13 16:18:44 -07:00
Dmitry Maluka
3f0cd019d7
Fix incorrect LastVisualX after changing bufWidth w/o resize (#2629)
* Fix incorrect LastVisualX after changing bufWidth w/o resize

When we resize a buffer pane with softwrap enabled, we update the
cursors LastVisualX values to ensure that moving cursor up or down
within a wrapped line will move the cursor to the correct location.
The problem is that we need to do it also in cases when the visual
buffer width within the buffer window is changing without resizing
the window itself, e.g. when toggling the ruler on/off.

So update LastVisualX whenever the buffer width changes, not neccesarily
as a result of resizing the buffer window.

* Update LastVisualX and relocate when toggling wordwrap on/off

Visual location of a cursor may change not only when softwrap is toggled
on or off but also when wordwrap is toggled on or off without changing
the softwrap setting. So need to update cursor LastVisualX values and
relocate the view if needed, just like when softwrap is toggled, to make
sure that moving the cursor up and down will work correctly and that the
cursor will not be left out of the view.
2022-12-02 17:49:06 -08:00
Dmitry Maluka
8ff7ec50ef
Fix relocate at the end of buffer when scrollmargin is 0 (#2578)
* Add LessEqual and GreaterEqual for SLoc

* Fix relocate at the end of buffer when scrollmargin is 0

Fix the following issue: when scrollmargin is set to 0 and we move the
cursor to the end of buffer (e.g. via Ctrl-End), the buffer view doesn't
move.

The cause is that the condition c.LessThan(w.Scroll(bEnd, -scrollmargin+1))
doesn't hold, since Scroll() takes care not to return a location beyond
the end of buffer, so in this case Scroll() just returns bEnd.
2022-10-01 13:03:40 -07:00
Ben Hammond
585dcc7d19
Adds options for tab bar and tab color reversing (#2480)
* Adds options for tab bar and tab color reversing

* Fixes small bug with tabreverse, options now work fully as expected
2022-07-17 12:18:11 -07:00
0x5c
987e409071
Added lines and percentage statusbar directives (#2055)
- "lines" for the number of lines in the buffer
- "percentage" for the percentage of the file at the current line

Fixes zyedidia#2049
2022-02-22 01:31:32 -08:00
Dmitry Maluka
ffbb257434
Support for highlighting all search matches (hlsearch) (#1762)
* Support for highlighting all search matches (hlsearch)

hlsearch is implemented efficiently using the buffer's line array,
somewhat similarly to the syntax highlighting.
Unlike the syntax highlighter which highlights the entire file,
hlsearch searches for matches for the displayed lines only.
Matches are searched when the given line is displayed first time
or after it was modified. Otherwise the previously found matches
are used.

* Add UnhighlightSearch action

and add it to the list of actions triggered by Esc key by default.

* Add comment explaining the purpose of search map

* Add hlsearch colors to colorschemes

Mostly just copied from the corresponding original (mostly vim) colorschemes.

* Highlight matches during/after replace as well

As a side effect it also changes the last search value, i.e. affects FindNext
and FindPrevious, but it's probably fine. In vim it works the same way.

* Improve hlsearch option description
2021-09-28 13:39:03 -07:00
Zachary Yedidia
3a97ce820c More style improvements 2021-08-21 18:04:08 -04:00
Dmitry Maluka
88c95c8fae Fix up X,Y values in BufView
Let's return absolute X, Y values, rather than relative to the bufwindow.
2021-04-09 01:48:58 +02:00
Dmitry Maluka
aaac60a78d Replace BufWidth & BufHeight with BufView
BufView returns not only the buffer's width and height but also its
x,y position. It may be useful e.g. for checking if a mouse click was
on the actual buffer or ourside it, e.g. on the gutter.
2021-04-08 23:54:18 +02:00
Dmitry Maluka
ab6ce444a7 Don't highlight padding spaces in word wrapping
Don't highlight space characters at the right edge which are used just
for padding after line break in word wrapping, i.e. don't correspond to
any real characters in the buffer.

This makes it look nicer e.g. when selecting word-wrapped text.
2021-04-08 23:54:14 +02:00
Dmitry Maluka
965e43ebf1 Implement word wrapping
Fixes #264
Fixes #1644
2021-04-08 23:54:10 +02:00
Dmitry Maluka
f2613eeb3b Simplify LocFromVisual implementation
Now that we have LocFromVLoc, we can radically simplify the code of LocFromVisual.
Less duplication, less potential bugs.
2021-04-08 23:54:06 +02:00
Dmitry Maluka
6d13710d93 Implement moving cursor up/down within a wrapped line
Modified behavior of CursorUp, CursorDown, CursorPageUp etc:
if softwrap is enabled, cursor moves by visual lines, not logical lines.

TODO: implement it also for Home and End keys: move cursor to the
visual start or end of a line. I haven't implemented it for now, because
I'm not sure what should be the behavior of StartOfTextToggle then
(considering that Home key is bound to StartOfTextToggle by default).

Fixes #1598
2021-04-08 23:54:02 +02:00
Dmitry Maluka
7a3d1e6e30 Add VLoc, VLocFromLoc and LocFromVLoc
VLoc allows any location in the buffer to be represented as a visual
location in the linewrapped buffer. In particular, this is useful
for implementing moving cursor up and down within a wrapped line.
2021-04-08 23:53:57 +02:00
Dmitry Maluka
0487db8b99 Fix horizontal scrolling with a wide rune at the right edge of window 2021-04-08 23:53:53 +02:00
Dmitry Maluka
cd7ab640c5 Fix displaying incomplete tab or wide rune at the right edge of window
Fix displaying tabs and wide runes which don't fit in the window.
Don't overwrite the vertical divider and the adjacent window.

- For tabs: display only as many of the tab's spaces as fit in the window.

- For wide runes: if a rune doesn't fit, don't display it in this line at all.
  If softwrap is on, display this rune in the next line.

Fixes #1979
2021-04-08 23:53:49 +02:00
Dmitry Maluka
a1651aec2f Fix horizontal scrolling issue after toggling softwrap on/off
Fixes #645
2021-04-08 23:53:44 +02:00
Dmitry Maluka
c960c93a83 Add BufWidth and BufHeight
Fixes issue with the usage of a slightly incorrect buffer height value
(v.Height should be v.Height-1 if statusline is displayed).

Also, to avoid too many duplications, the code reorganized a little:
buffer display params (width, height, gutter offset and others) are
calculated in a single place.
2021-04-08 23:53:40 +02:00
Dmitry Maluka
c5798b5b8c
Fix softwrap scrolling issues (#1981)
Softwrap implementation enhanced to fix various issues with scrolling,
centering, relocating etc.

The main idea is simple: work not with simple line numbers but
with (Line, Row) pairs, where Line is a line number in the buffer
and Row is a visual line (a row) number within this line.
The logic remains mostly the same, but simple arithmetic operations
on line numbers are replaced with corresponding operations on
(Line, Row) pairs.

Fixes #632, #1657
2021-04-07 16:18:51 -04:00
Zachary Yedidia
95fea064b0 Fix internal string binding representation 2020-11-05 15:52:25 -05:00
Dmitry Maluka
23162f7a34
Add tabbar.active color group (#1831)
Added tabbar.active color group for displaying the name of the active
tab in the tabbar with different colors.

If tabbar.active is not defined in the colorscheme, the active tab name
is displayed with the same colors as inactive ones.

Ref #1646
2020-10-17 20:53:08 -04:00
Dmitry Maluka
92e9060bcd
Fix suggestions display (#1825)
Fix the following bugs:

- If a split pane is not at the left edge of the screen, the statusline
with suggestions for it is displayed at wrong place.

- When keymenu is enabled, the statusline with suggestions is not
displayed at all.
2020-10-17 20:48:39 -04:00
Zachary Yedidia
49786cf8c3 Fix palette colors with tcell v2 2020-09-21 01:21:59 -04:00
Sourya Vatsyayan
fc3dd9a62f
Fix quality issues (#1856)
* Add .deepsource.toml

* Remove unnecessary comparison with bool

* Remove unnecessary use of slice

* Replace multiple `append`s with one

* Remove unnecessary wrapping of function call

* Fix check for empty string

* Simplify error creation with `fmt.Errorf`

* Fix defers before error check

Signed-off-by: sourya_deepsource <sourya@deepsource.io>

* Remove untrappable `os.Kill` signal

Signed-off-by: sourya_deepsource <sourya@deepsource.io>

* Remove empty else branch

Signed-off-by: sourya_deepsource <sourya@deepsource.io>

* Add missing error check

Signed-off-by: sourya_deepsource <sourya@deepsource.io>

* Merge variable declaration and assignment

Signed-off-by: sourya_deepsource <sourya@deepsource.io>

* Remove unnecessary `nil` check

Signed-off-by: sourya_deepsource <sourya@deepsource.io>

* Revert changes to generated files

Signed-off-by: sourya_deepsource <sourya@deepsource.io>

* Remove .deepsource.toml

Signed-off-by: sourya_deepsource <sourya@deepsource.io>

Co-authored-by: DeepSource Bot <bot@deepsource.io>
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2020-09-16 00:08:01 -04:00
Zachary Yedidia
11104fd093 Update to tcell v2 2020-09-05 14:52:35 -04:00
Dmitry Maluka
c7e72220dd
Add scrollbar color group (#1840)
Ref #1837
2020-08-23 15:45:43 -04:00
Dmitry Maluka
6e43af31cb
Fix non-working split resize with mouse drag (#1811)
Fix the 2nd part of #1773: resize via mouse drag doesn't work if the
split on the left contains other splits, i.e. is not a leaf node.

The problem is that only leaf nodes have unique id. For non-leaf nodes
ID() returns 0. So we shouldn't search the node by id.
So replace GetMouseSplitID() with GetMouseSplitNode().
2020-08-04 18:37:19 -04:00
Dmitry Maluka
a4cc5a4146
Fix erased vertical dividing line (#1810)
Fix the 1st part of #1773: the dividing line between vertical splits
is not displayed if the split on the left contains other splits, i.e.
is not a leaf node.
2020-08-04 18:33:16 -04:00
Dmitry Maluka
1f58eecf3c
Lower priority of cursorline and colorcolumn highlighting (#1697)
Fixes #1665
2020-06-08 16:15:54 -04:00
Dmitry Maluka
63900cb395
Fix highlighting at the end of line (#1705)
Fixes #1664
2020-06-04 23:32:31 -04:00
Colin Hughes
00edf0207f
Added hybrid line numbers (#1690)
* Added hybrid line numbers

* Changed rulerhybrid to relativeruler, modified documentation accordingly.

* Reverted go.mod and go.sum
I don't know how they got changed but they are good now.

Co-authored-by: Colin Hughes <semilin@pop-os.localdomain>
2020-05-28 22:24:09 -04:00
Zachary Yedidia
bfe68b1626 Allow divider customization with divchars option
Adds the `divchars` and `divreverse` options to customize divider
styles.
2020-05-21 14:35:54 -04:00
Zachary Yedidia
79c0ea17ad Use CharacterCount over RuneCount 2020-05-20 16:47:08 -04:00
Zachary Yedidia
bdff221870 Use DecodeCharacter over DecodeRune 2020-05-20 16:43:12 -04:00
Zachary Yedidia
eff89a98a7 Fix v2 import path for go mod 2020-05-04 10:16:15 -04:00
Zachary Yedidia
eb7189dcdb Make cursor follow selections
Fixes #1624
2020-04-21 09:33:21 -04:00
Zachary Yedidia
8f5888e7bf Use StartCol in colorcolumn calculation
Fixes #1615
2020-04-10 17:27:11 -04:00
Zachary Yedidia
60c8c81da3 Relocate during replace
Fixes #1587
2020-03-24 11:33:52 -04:00
Zachary Yedidia
18d540583b Don't clear infobar if not enabled
Fixes #1584
2020-03-17 14:21:36 -04:00
Zachary Yedidia
dff8b33e9c Apply basename option in tabbar as well 2020-02-24 13:48:37 -05:00
Zachary Yedidia
8a2048e7f6 Use tabbar color group, and mark modified tabs
Fixes #1523
2020-02-24 13:45:10 -05:00
Zachary Yedidia
a9120ce270 Share more buffer elements and fix rehighlight
Fixes #1521
2020-02-19 14:41:30 -05:00
Zachary Yedidia
cc994b6241 Fix relocation with softwrap on small buffers
Fixes #1512
2020-02-15 15:38:20 -05:00
Zachary Yedidia
38f88ade60 Search and replace within a selection
Closes #1098
2020-02-13 19:48:48 -05:00
Zachary Yedidia
a07ee26b05 Fix gutter offset when softwrap is enabled 2020-02-13 11:04:10 -05:00
Zachary Yedidia
bad78797bb Clicking tabbar arrow scrolls and fix multicursor
Closes #1503
2020-02-12 13:05:15 -05:00
Zachary Yedidia
6588f02f7b Only highlight matching brace if one is found
Fixes #1505
2020-02-12 01:32:23 -05:00
Zachary Yedidia
dcd4bae96f Clamp modifications
Fixes #1502
2020-02-12 00:55:52 -05:00
Zachary Yedidia
8224037080 Don't block when redraw channel becomes full
Fixes #1497
2020-02-11 20:03:32 -05:00
Zachary Yedidia
f3eaf99665 Draw FakeCursor in infobar when on a character
Fixes #1496
2020-02-10 19:55:13 -05:00