Commit graph

443 commits

Author SHA1 Message Date
Zachary Yedidia
bb609467dd Update comment filetype when commenting 2021-08-20 14:42:38 -04:00
Zachary Yedidia
dceddcfd83 Fix save with sudo auto-detection and sudo/doas message 2021-08-20 13:55:59 -04:00
Zachary Yedidia
2eeeb0f2e4 Update runtime 2021-08-18 01:09:53 -04:00
john-batch
77f93bfd93
Make yes/no prompts case-insensitive (#2182) 2021-08-13 23:56:26 -04:00
Zachary Yedidia
7a1ba01621 Merge branch 'patch-3' of https://github.com/pyfisch/micro into pyfisch-patch-3 2021-08-06 20:44:57 -04:00
Zachary Yedidia
e290ce2de5 Fixes for syntax and docs
Fixes #2163
Ref #2173
2021-08-03 00:07:14 -04:00
Zachary Yedidia
0efc919f24 Merge 2021-08-02 21:06:28 -04:00
Zachary Yedidia
c315a91fc6 Allow aborting while opening a file with backup
Also fixes an issue where the abort prompt consumes interrupt signals.

Fixes #2151
2021-08-02 21:05:22 -04:00
pyfisch
6e1fe5b301 More precise filename detection for shell scripts
Make the regular expression much more precise:

* match literal dots instead of any char (match rc.conf but not rcXconf)
* match special filenames exactly (match PKGBUILD but not myPKGBUILD.something)

Run build-all to update internal/config/runtime.go

closes #2163
2021-07-21 22:09:46 +02:00
Ali Kefia
1a5518ebbb
Shellcheck as a new shell linter + runtime.go out of git control (#2157)
* shellcheck as a new shell linter + runtime.go out of git control

* keep runtime.go and keep both shfmt and shellcheck since we can remove from custom conf
2021-07-16 15:01:50 -04:00
Ali Kefia
4a2a72983f
Search the last match on line when search back (#2156) 2021-07-13 23:37:22 -04:00
Zachary Yedidia
33e064b3b9 Add default binding for FindLiteral 2021-07-04 20:00:49 -04:00
Dmitry Maluka
3bfd367d87
find: select prefilled text (#2127)
The new feature of prefilling the search bar with the selected text (added
in 3d0b5db) has an annoying side effect: if we do have some text selected
but we want to search for some other pattern, not the selected text,
then we have to manually delete the prefilled text before we can start
entering our wanted search pattern.

A simple solution is to select the prefilled text, so that we can replace it
with our pattern right away just by typing, without any additional keystrokes.
2021-06-09 17:04:11 -04:00
Ali Kefia
3d0b5db2e4
find: prefill with selection (#2115)
* find: prefill with selection

* keep search func - could be used in plugins
2021-06-02 16:04:31 -04:00
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