Commit Graph

316 Commits (40abec80e1062503d70055ed9e968cd4b31411a7)

Author SHA1 Message Date
Blaž Hrastnik 6bb744aeac Remove the jump 3 years ago
Dmitry Sharshakov 8361de45dc
Mouse selection support (#509)
* Initial mouse selection support

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Disable mouse event capture if editor crashes

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Translate screen coordinates to view position

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Select full lines by dragging on line numbers

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* editor: don't register dragging as a jump

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Count graphemes correctly

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Do not select lines when dragging on the line number bar

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Split out verify_screen_coords

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Do not iterate over the graphemes twice

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Switch view by clicking on it

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Add disable-mouse config option

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Support multiple selections with mouse

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Remove unnecessary check

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Refactor using match expression

Co-authored-by: Gokul Soumya <gokulps15@gmail.com>
Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Rename local variable

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Rename mouse option

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Refactor code

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Fix dragging selection

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Fix crash when clicking past last line

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Count characters better

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Remove comparison not needed anymore

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Validate coordinates before resolving position

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Tidy up references to editor tree

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Better way to determine line end and avoid overflow

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Fix for last line

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* Add unit tests for text_pos_at_screen_coords

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>

Co-authored-by: Gokul Soumya <gokulps15@gmail.com>
3 years ago
Nathan Vegdahl a873e719d5 Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Gokul Soumya 1493313750
Show pending keys in status line (#515)
* Show pending keys and counts in status line

* Refactor pending key display
3 years ago
Nathan Vegdahl f62ec6e51e Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Gokul Soumya 88d6f65239
Allow multi key remappings in config file (#454)
* Use tree like structure to store keymaps

* Allow multi key keymaps in config file

* Allow multi key keymaps in insert mode

* Make keymap state self contained

* Add keymap! macro for ergonomic declaration

* Add descriptions for editor commands

* Allow keymap! to take multiple keys

* Restore infobox display

* Fix keymap merging and add infobox titles

* Fix and add tests for keymaps

* Clean up comments and apply suggestions

* Allow trailing commas in keymap!

* Remove mode suffixes from keymaps

* Preserve order of keys when showing infobox

* Make command descriptions smaller

* Strip infobox title prefix from items

* Strip infobox title prefix from items
3 years ago
Nathan Vegdahl 0883b4fae0 Collect some common patterns into methods on `Range`. 3 years ago
Blaž Hrastnik 63e54e30a7 Implement in-memory prompt history
Implementation is similar to kakoune: we store the entries into
a register.
3 years ago
Nathan Vegdahl 43594049dd Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Blaž Hrastnik 1789dfabfe fix: ui/menu: Don't allow scrolling past the end of completion
Fixes #472
3 years ago
Blaž Hrastnik 817a7e0bd6 fix: Only try expanding directory completion if it makes sense
Fixes #487
3 years ago
Blaž Hrastnik 58d08d36ae Simplify ui/menu.rs 3 years ago
Ivan Tham eba0bbda2e Resume last picker
Inspired by space ' in doom emacs.
3 years ago
Nathan Vegdahl 1910fa7723 Fix incorrect line hihglight when a selection is at the end of a line. 3 years ago
Nathan Vegdahl b0311f4fc2 Fixed primary cursor position calculation to use 1-width semantics.
This had a bunch of knock-on effects that were buggy, such as bracket
match highlighting.
3 years ago
Nathan Vegdahl 079d4ed86d Properly fix `last_line` view calculation.
Turned out to be simpler than I thought.  Didn't even need to change the
other use-sites.
3 years ago
Nathan Vegdahl 1a9ae72fcb Fix last line number being drawn in the status bar. 3 years ago
Nathan Vegdahl e462f32723 Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Blaž Hrastnik 5292fe0f7d Calculate completion popup sizing
Fixes #220
3 years ago
Nathan Vegdahl a77274e8bb Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Kirawi bb121a3e4b
Injection Query Support (#430)
* wip

* wip

* fixed unsafe

* fix clippy

* move out reference variable

* fmt

* remove arc

* change safety comment
3 years ago
Nathan Vegdahl 85d5b399de Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Nathan Vegdahl 4952d6f801 Fix phantom lines in some CRLF files.
Fixes #415.  The issue was that cursor highlighting wasn't extending
to encompass the entire CRLF grapheme, and therefore ended up splitting
it.  This presumably was messing up other grapheme rendering as
well, and this fixes that as well.
3 years ago
Ivan Tham d02bbb7bae Fix info panic on small terminal 3 years ago
Ivan Tham 5977b07e19 Reduce calculation and improve pattern in infobox
- switch to use static OnceCell to calculate Info once
- pass Vec<(&[KeyEvent], &str)> rather than Vec<(Vec<KeyEvent>, &str)>
- expr -> tt to allow using | as separator, make it more like match
3 years ago
Ivan Tham 6710855eac Fix rendering issues for infobox 3 years ago
Ivan Tham 9effe71b7d Apply suggestions from blaz for infobox 3 years ago
Ivan Tham 8985c58fd3 Add infobox 3 years ago
Nathan Vegdahl 22dca3b111 Allow last line in file to lack a line break character. 3 years ago
Nathan Vegdahl 2224a1527e Merge branch 'master' into great_line_ending_and_cursor_range_cleanup 3 years ago
Nathan Vegdahl efa3389b6a Fix unused variable, parameter, and `mut` warnings in helix-term. 3 years ago
Nathan Vegdahl 702a0491db Remove #[allow(unused)] from helix-term, and fix unused imports.
Lots of other warning still left.  Will address in subsequent commits.
3 years ago
Nathan Vegdahl d07074740b Add `Range` methods for various kinds of validation. 3 years ago
Joe Neeman d64d75e724 Add some async job infrastructure. 3 years ago
Blaž Hrastnik e9159887a9 ui: Use a box drawing character vertical line for splits 3 years ago
Blaž Hrastnik d94410a678 Sort the files in descending order 3 years ago
Blaž Hrastnik 82fc28a0ce ui: Simplify conditional 3 years ago
Blaž Hrastnik bcca152ad5 Merge tab & char rendering code 3 years ago
Blaž Hrastnik 01b1a62e2c This char_index is unused 3 years ago
Blaž Hrastnik 4edfac21f6 Allocate the tab stop only once 3 years ago
Blaž Hrastnik 1b102d5532 Extract the merge "operator" into helix-core 3 years ago
Blaž Hrastnik ae58d813b2 Appease clippy 3 years ago
Blaž Hrastnik f9cdb2afe2 Turn diagnostics rendering into span injection too 3 years ago
Blaž Hrastnik 057bd630d8 Simplify selection rendering by injecting highlight scopes 3 years ago
Blaž Hrastnik cad14c6b46 Address nightly clippy warnings 3 years ago
Nathan Vegdahl a6cadddef4 Fix silly mistake in previous phantom line bug fix.
Fixes #381.  I was trying to change an index value that... wasn't
even an index value.
3 years ago
Nathan Vegdahl 2dba228c76 Fix highlight code splitting graphemes.
This resulted in phantom blank lines in files with CRLF line
endings, but could potentially have manifested with other
graphemes as well.
3 years ago
Wojciech Kępka eb6fb63e74
Sort files in file picker by access, modification and creation date (#336)
* Sort files in file picker by access date

* Fallback file time to modified then created then UNIX_EPOCH

* Use `sort_by_key`

* Refactor
3 years ago
Keith Simmons 4418e17547
reverse the dependency between helix-tui and helix-view (#366)
* reverse the dependency between helix-tui and helix-view by moving a fiew types to view

* fix tests

* clippy and format fixes

Co-authored-by: Keith Simmons <keithsim@microsoft.com>
3 years ago
Gokul Soumya 18beda38ac Add … when chars are truncated in picker 3 years ago
Ivan Tham 10548bf0e3 Fix previous broken refactor key into helix-view
Need to be used for autoinfo

Revert "Revert "Refactor key into helix-view""

This reverts commit 10f9f72232.
3 years ago
Gokul Soumya fb8e7dc25b Fix picker item width overflow
Fixes #352
3 years ago
Blaž Hrastnik 39dc09e6c4 ui: Paginate prompt completion 3 years ago
wojciechkepka 3606d8bd24 Patch the primary cursor with insert and select styles 3 years ago
wojciechkepka c534fdefdc Refactor, add `ui.cursor.primary` 3 years ago
wojciechkepka d70be55f70 Add ability to theme primary selecition 3 years ago
wojciechkepka ac1e98d088 Add ability to theme cursor 3 years ago
Blaž Hrastnik 9706f1121d Fix small screen panics 3 years ago
Nathan Vegdahl 481c4ba044 Increment char_index by grapheme char count.
It was just assuming single-char graphemes before.
3 years ago
Joe Neeman fd1ae35051 Make the prompt callback take a Context. 3 years ago
Lionel Flandrin b56174d738 Implement change_current_directory command 3 years ago
Blaž Hrastnik 20f33ead67 minor: Remove old TODOs 3 years ago
Blaž Hrastnik a70de6e980
Merge pull request #224 from helix-editor/line_ending_detection
Line ending detection
3 years ago
wojciechkepka cc357d5096 Add progress spinners to status line 3 years ago
wojciechkepka b2804b14b1 Add a `Spinner` 3 years ago
Nathan Vegdahl e686c3e462 Merge branch 'master' of github.com:helix-editor/helix into line_ending_detection
Rebasing was making me manually fix conflicts on every commit, so
merging instead.
3 years ago
Nathan Vegdahl 4efd6713c5 Work on moving code over to LineEnding instead of assuming '\n'.
Also some general cleanup and some minor fixes along the way.
3 years ago
wojciechkepka fc39a6c40d Add comment, statusline + commandline = 2 3 years ago
wojciechkepka 0882712b45 Use full screen size 3 years ago
wojciechkepka 980e602352 Make completion window move to top when cursor is below half 3 years ago
Nathan Vegdahl 5d22e3c4e5 Misc fixes and clean up of line ending detect code. 3 years ago
Blaž Hrastnik 34ebe82654 ui: prompt: Add more keymappings 3 years ago
Blaž Hrastnik e9a3245aae Re-export unicode crates from helix_core 3 years ago
Blaž Hrastnik 9275021497 ui: prompt: Better unicode support
We copied over eval_movement from wezterm, that already solves most of
our problems. self.cursor is now byte-based.
3 years ago
wojciechkepka 2d629a880c Fix overflow 3 years ago
wojciechkepka a2db161d5a Add theme completer 3 years ago
wojciechkepka ce97a2f05f Add ability to change theme on editor 3 years ago
Blaž Hrastnik 10f9f72232 Revert "Refactor key into helix-view"
Did not use defaults when custom keymap was used

This reverts commit ca806d4f85.
3 years ago
Jan Hrastnik cdd9347457 Merge remote-tracking branch 'origin/master' into line_ending_detection 3 years ago
Ivan Tham ca806d4f85 Refactor key into helix-view
Now also make use of Deserialize for Config.
3 years ago
wojciechkepka 1c1474c3b8 Add `ui.statusline.inactive`, use `ui.statusline` for statusline text 3 years ago
Wojciech Kępka 41b07486ad
Fix expansion of `~` (#284)
* Fix expansion of `~`, dont use directory relative to cwd.

* Add `expand_tilde`

* Bring back `canonicalize_path`, use `expand_tilde` to `normalize`

* Make `:open ~` completion work

* Fix clippy

* Fold home dir into tilde in Document `realitve_path`
3 years ago
Benoît CORTIER 42142cf680 Fix panic when entering unicode in command prompt
It was attempted to use `String::insert` and `String::remove` to insert
without taking care of unicodes.

Fixes https://github.com/helix-editor/helix/issues/282
3 years ago
Benoît CORTIER 8664d70e73 Replace `Editor::current` by a macro
This is necessary to workaround ownership issues across function calls.
The issue notably arised when implementing the registers into `Editor`
and I was getting annoyed again when implementing copy/pasting into
system clipboard.
The problem is addressed by using macro calls instead of function calls.
There is no notable side effect.
3 years ago
PabloMansanet f7e00cf720
Configurable keys 2 (Mapping keys to commands) (#268)
* Add convenience/clarity wrapper for Range initialization

* Add keycode parse and display methods

* Add remapping functions and tests

* Implement key remapping

* Add remapping book entry

* Use raw string literal for toml

* Add command constants

* Make command functions private

* Map directly to commands

* Match key parsing/displaying to Kakoune

* Formatting pass

* Update documentation

* Formatting

* Fix example in the book

* Refactor into single config file

* Formatting

* Refactor configuration and add keymap newtype wrappers

* Address first batch of PR comments

* Replace FromStr with custom deserialize
3 years ago
Jan Hrastnik a4f5a0134e trying out line ending helper functions in commands.rs 3 years ago
Jan Hrastnik 3756c21bae rebase on branch line_ending_detection 3 years ago
Gokul Soumya d1c8a74771 Add theme key for selected line number
Adds `ui.linenr.selected` which controls highlight of linu numbes which
have cursors on.

- Fallback to linenr if linenr.selected is missing

- Update docs and themes

- Add TODOs for themes with temporary linenr.selected
3 years ago
Ivan Tham 124514aa70 Add cursor kind to separate hidden cursor from pos
Now IME cursor position should be correct since we can still set cursor
position without drawing the cursor.
3 years ago
Benoît CORTIER 6bdf609caa Remove RwLock for registers
Registers are stored inside `Editor` and accessed without `RwLock`.
To work around ownership, I added a sister method to `Editor::current`:
`Editor::current_with_context`. I tried to modify `Editor::current`
directly but it's used at a lot of places so I reverted into this for
now at least.
3 years ago
Benoît CORTIER 6fb2d2679d Use `_impl` suffix instead of `_` prefix
Helpers / internal implementations where using the `_` prefix.
However, this prefix also suppress unused warnings.
I suggest we use the `_impl` suffix instead.
3 years ago
Ivan Tham 002f1ad397 Add filter ability to picker
Inspired by doom emacs. Able to filter picker options multiple times.
3 years ago
Nathan Vegdahl 4faf1d3bf4 Remove indent style status-line display for now. 3 years ago
Nathan Vegdahl 358ea6a37c Implement command to change the indent-style setting of a document. 3 years ago
Nathan Vegdahl 8648e483f7 Render indent-style status in status line.
Also cleaned up the status line code a little.
3 years ago
Ivan Tham 1bda454149 Add ctrl-w for prompt 3 years ago
Gokul Soumya f33aaba53f Add ui.selection to theme.toml
Enables changing the color of the selection which was previously
hard coded.
3 years ago
Blaž Hrastnik d545e61644 ui: Prompt should figure out a reasonable column width
Fixes #192
Refs #225
3 years ago
Wojciech Kępka d8b5d1181f Add `Copy` derive to `PromptEvent` 3 years ago
Wojciech Kępka b500a2a138 commands: Add more write commands 3 years ago