Commit graph

429 commits

Author SHA1 Message Date
Zachary Yedidia
56c7744e23 Fix erlang comment syntax 2021-05-31 20:26:32 -04:00
Zachary Yedidia
0b0c99f1f5 Warn for readonly instead of setting option
Fixes #2106
2021-05-19 14:58:00 -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
1f73f8587c
Add buffer.WordAt (#2070)
Add buffer.WordAt function returning the word around a given location
in the buffer. Useful for plugins.
2021-04-07 16:20:39 -04: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
ae114a766c Merge 2021-03-02 17:16:54 -05:00
Zachary Yedidia
6761bdf8aa Fix noregex interactive replace
Fixes #2052
2021-03-02 17:16:19 -05:00
Zachary Yedidia
c014af9280 Add ForceQuit action
Closes #1039
2021-03-01 21:55:49 -05:00
Dmitry Maluka
de8f4bf72f
Fix regressions in buffer settings initialization (#2035)
Fix regressions after ba98b55:

- Unable to override filetype autodetection by setting a specific filetype
  for specific files, i.e. this doesn't work:

    "*.h": {
        "filetype": "c++"
    },

- Unable to enable/disable syntax highlighting for specific files,
  i.e. this doesn't work:

    "*.c": {
        "syntax": false
    },

- "readonly" setting doesn't work (neither global nor per-filetype).
2021-02-22 18:18:37 -05:00
Zachary Yedidia
975e78d9c0 Remove conf highlighting (too many conflicts)
Fixes #2031

The conf highlighter interferes with many more specific highlighters and
doesn't provide much value on its own.
2021-02-20 14:27:58 -05:00
Zachary Yedidia
8aadf6af65 Fix #2030: warn for invalid pane type 2021-02-18 19:02:23 -05:00
Zachary Yedidia
ba98b558d9 Only initialize buffer settings once
Ref #2009
2021-02-07 13:14:40 -05:00
Zachary Yedidia
c21b85929f gofmt 2021-01-27 22:52:40 -05:00
Zachary Yedidia
c3a17a71be Rename to incsearch 2021-01-27 13:49:38 -05:00
Zachary Yedidia
120cd02b30 Merge branch 'PR-find-on-type' of https://github.com/ilius/micro into ilius-PR-find-on-type 2021-01-27 13:48:01 -05:00
Siddhant N Trivedi
cf35b8021c
Fix some quality issues (#1914)
* Add .deepsource.toml

* Fix unnecessary typecasting on `bytes.Buffer`

* Fix check for empty string

* Replace nested if block with else-if

* Replace nested if block with else-if

* Replaced string.Replace() with string.ReplaceAll where n<0

* Remove deepsource toml file

Signed-off-by: siddhant-deepsource <siddhant@deepsource.io>

Co-authored-by: DeepSource Bot <bot@deepsource.io>
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2021-01-09 13:39:21 -05:00
Dmitry Maluka
e80f899480
Fix non-working TryBindKey and UnbindKey (#1970)
Fixed regression: since merging keybindings branch, TryBindKey and
UnbindKey and accordingly "bind" and "unbind" commands don't work
(fail to unmarshal bindings.json).

This is just a quick fixup to make TryBindKey and UnbindKey work again.
They still work with "buffer" bindings only.
2021-01-05 19:37:49 -05:00
Saeed Rasooli
dd37ad5ce4
add settings option "findontype" to allow disabling search-on-type 2021-01-04 10:30:47 +03:30
Zachary Yedidia
54c23cae72 Merge branch 'python-highlight-zero' of https://github.com/a11ce/micro into a11ce-python-highlight-zero 2020-12-27 18:42:53 -05:00
worldmaker
06a5f1a62d
fix the missing break in JumpToMatchingBrace (#1960)
In JumpToMatchingBrace, the loop should stop immediately after finding the matching bracket.
It causes multiple jumps in certain situations:
`(I  [  ]{  }) => (  I[  ]{  })`
2020-12-27 18:38:16 -05:00
Zachary Yedidia
3321e844fc Merge 2020-12-26 14:45:27 -05:00
Zachary Yedidia
b5ce418201 Only use internal clipboard on error 2020-12-26 14:45:22 -05:00
Dmitry Maluka
57a3927f02
Don't automatically disable readonly option (#1957)
Fix the regression after 3b34a02: setting readonly option to true
in onBufferOpen lua callback doesn't work, since it is automatically
reset to false if write permission is not denied.
2020-12-23 15:21:20 -05:00
Dmitry Maluka
e4f7f80862
Fix potential file leaks (#1958) 2020-12-23 15:21:01 -05:00
Zachary Yedidia
ecde9a53d7 Update runtime 2020-12-20 14:53:04 -05:00
Zachary Yedidia
299ba2fe97 Fix stat error detection
Fixes #1955
2020-12-20 13:05:10 -05:00
Zachary Yedidia
6b7c04b421 Add Dracula colorscheme to defaults
See https://draculatheme.com/micro.
2020-12-20 01:08:41 -05:00
Zachary Yedidia
c13acf6b19 Merge 2020-12-17 21:55:59 -05:00
Zachary Yedidia
3b34a021e3 Improve file permission detection
Mark files as readonly automatically if write permission is denied.
Display errors when opening files (except for non-existence errors).

Fixes #1224
2020-12-17 21:54:18 -05:00
Zachary Yedidia
4c21808c6c Remove clipboard error message 2020-12-16 21:35:07 -05:00
a11ce
1e5f8c020e Highlight 0 as a constant number in python3 2020-12-15 18:57:28 -05:00
Carlos Henrique Guardão Gandarez
7a5f7e443a
Make more libraries available (#1917)
* Make more libraries available to plugin dvelopment

* Add Unzip function to util
2020-11-21 01:46:17 -05:00
Zachary Yedidia
7df04a58eb Clear prompt before callback
Ref #1913
2020-11-16 14:07:22 -05:00
Zachary Yedidia
f3b21362f3 Disable fake cursor for Windows Terminal
Ref #1900
2020-11-06 13:45:34 -05:00
Zachary Yedidia
95fea064b0 Fix internal string binding representation 2020-11-05 15:52:25 -05:00
Zachary Yedidia
5d230754a8 Merge 2020-11-05 15:39:29 -05:00
Zachary Yedidia
19067a9bf0 Enable ignorecase by default
Closes #1908
2020-11-05 15:39:05 -05:00
Dmitry Maluka
298fa40f90
Fix buffer.RuneAt (#1895)
Fix buffer.RuneAt returning the rune not at the given location (as the
documentation claims) but just before it.
2020-10-19 20:36:14 -04: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