Commit Graph

72 Commits (e6d2835b0907102831a8979688a8464c064ff842)

Author SHA1 Message Date
Michael Davis a2767269d0
crossterm: Handle 'hidden' modifier (#8120)
Crossterm supports the 'hidden' SGR parameter but we previously didn't
set the attribute when the "hidden" modifier was specified in a theme.
1 year ago
Michael Davis 546c8ca344 Handle switch from crossterm::Result to io::Result 1 year ago
Dillard Robertson ea88677394
Stop Terminal::drop from overriding work of Terminal::restore. (#7931)
When Application::run is exiting, either Terminal::restore or
Terminal::force_restore will be called depending
on if a panic occured or not.
Both of these functions will reset the cursor to terminal's default.

After this is done, Terminal::drop will be called.
If terminal.cursor_kind == Hidden, then
the cursor will be reset to a CursorKind::Block,
undoing the work of restore or force_restore.

This commit just removes the drop implementation,
as its job is already better handled in restore and force_restore.
1 year ago
Michael Davis b0129b552d
Fix style overwriting in table rows with multiple cells (#7281) 1 year ago
ZJPzjp 3b8c15618f
Fix warnings from clippy (#7013)
* Fix warnings from clippy

* revert MAIN_SEPARATOR_STR
2 years ago
Michael Davis ee7413a3fd
tui: Allow toggling mouse capture at runtime (#6675)
This picks up changes to the `editor.mouse` option at runtime - either
through `:set-option` or `:config-reload`. When the value changes, we
tell the terminal to enable or disable mouse capture sequences.
2 years ago
Daniel Sedlak e856906f76
Fix typos (#6643) 2 years ago
Pascal Kuthe 67783ddfd4
Performant and correct set_spans_truncated
the previous implementation used set_string_truncated. This is not only
awkward with this kind of "streaming" string (and therefore lead to an
inefficient and incorrect initial implementation) but that function also
truncates strings of width 1 when there is only a single char available.

The implementation here is performant, correct and also handles the
single width case correctly.
2 years ago
mWalrus e72be52996
Truncate paths in the file picker (#6410) 2 years ago
Michael Davis bbcdcd04a5
tui: Handle keyboard enhancement check failure (#6438)
If the terminal doesn't send the primary device attributes response to
the query, the `terminal::supports_keyboard_enhancement` function from
crossterm may timeout and return an Err.

We should interpret this error to mean that the terminal doesn't support
the keyboard enhancement protocol rather than an error in claiming the
terminal.
2 years ago
Philipp Mildenberger 198ff2c3f9
Fix clippy lints (#6454) 2 years ago
dependabot[bot] 52ced7e85f
build(deps): bump bitflags from 1.3.2 to 2.0.2 (#6387)
* build(deps): bump bitflags from 1.3.2 to 2.0.2

Bumps [bitflags](https://github.com/bitflags/bitflags) from 1.3.2 to 2.0.2.
- [Release notes](https://github.com/bitflags/bitflags/releases)
- [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bitflags/bitflags/compare/1.3.2...2.0.2)

---
updated-dependencies:
- dependency-name: bitflags
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* deps: Resolve bitflags 2.0 breaking changes

Bitflags 2.0 release made some breaking changes requiring some small
changes to the Helix codebase.

Almost all of the necessary changes are to manually `#[derive(..)]`
trait implementations which are no longer automatically derived for
all bitflags. All of these were previously automatically derived:

    #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy]

I have derived the minimum traits for each bitflag type.

The other change was to the `.bits` field. This is now a `.bits()`
method so the usage of this has been updated in the `Borders` type.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2 years ago
exp80 770496511c
Fix highlighting in picker with multiple columns (#6333) 2 years ago
Jonatan Pettersson d479adfdc6
Add undercurl config option #6196 (#6253)
If set to 'true' this option will force terminal undercurl support.
2 years ago
Michael Davis 563ac1a3cb tui: Log keyboard enhancement query time
In my testing this takes around 3-4ms in terminals that support the
enhanced keyboard protocol (Kitty, WezTerm) and a few hundred
microseconds in terminals that don't (st, Alacritty).
2 years ago
Michael Davis 611701c362 tui: Cache the keyboard enhancement check
Wether the host terminal supports keyboard enhancement can be cached
for the lifetime of a Helix session.

Caching this lookup prevents a potential lockup within crossterm's
event reading system where the query for the keyboard enhancement
support waits on the next keyboard event, which can happen if the
crossterm event stream is checked by `tokio::select!` in another
thread.
2 years ago
Michael Davis 3d85024717 Move terminal claim/restore code to helix-tui
This moves the `Application::claim_term` and
`helix-term::application::restore_term` functions into the helix-tui
crate. How the terminal should be claimed and restored is a TUI concern
and is implemented differently through different TUI backends.

This cleans out a lot of crossterm and TUI code in Application and
makes it easier to modify claim/restore based on information we query
from the terminal host. The child commit will take advantage of this
to cache the check for whether the host terminal supports the keyboard
enhancement protocol. Without this change, caching that information
takes much more code which is not easily reusable for anything else.

The code to restore the terminal is somewhat duplicated by this patch:
we want to restore the terminal in cases of panics. Panic handler hooks
must live for `'static` and the Application's terminal does not.
2 years ago
Michael Davis 79bf5e3094 Update crossterm to 0.26.1
Crossterm 0.26.x includes a breaking change for the command to set the
cursor shape. This commit includes a change which uses the new type.
2 years ago
Miguel Madrid-Mencía d2d3024337
Fix clippy 1.67 warnings (#5697) 2 years ago
Gokul Soumya 5c7db7aed5 Replace menu::Item::{row, label} with format() 2 years ago
Gokul Soumya b2837ff3be Minimize allocation when converting table rows to string 2 years ago
Gokul Soumya 7a76c6cbba Use upstream implementation of table column calculation
Changed in a68e38e59e.
2 years ago
Gokul Soumya 9aafcb2b9a Reuse table in picker 2 years ago
Blaž Hrastnik 98c121c9fc
Detect WezTerm and mark it as undercurl/Smulx capable 2 years ago
kristopherbullinger 7483c76222
update `x_offset` calculation in Buffer::set_string_truncated (#3839)
when `truncate_start` is `true`, the `x_offset` is now properly updated
according to the width of the content or the truncated length.
2 years ago
Blaž Hrastnik c2c1280f02
Resolve a bunch of upcoming clippy lints 2 years ago
A-Walrus c4d7cde6c8
Allow the area to be bigger than u16 (width and height remain u16) (#4318)
Now the editor can fill **very** large terminals.
Changed/removed tests which check the truncating behaviour.
2 years ago
Pascal Kuthe 963a0ac0bb
fix terminfo detection 2 years ago
Pascal Kuthe 4c36c067b0
avoid visual artificats on terminal emulators that do not support underline colors 2 years ago
Pascal Kuthe 114610f7dc
switch to termini for terminfo 2 years ago
Pascal Kuthe 71ee589bbc
make underline_style a seperate option
Underline styles are mutally exclusive and overwrite each other.
Therefore implementing as an modifier lead to incorrect behaviour
when the underline style is overwritten.

For backwards compatability the "underline" modified is retained (but
deprecated). Instead the "underline_style" and "underline_color"
optios should be used to style underlines.
2 years ago
Gokul Soumya 79d3d44c3d
Detect extended underline support using terminfo
The cxterminfo crate has been used over popular alternatives
like `term` since it supports querying for extended capabilities
and also for it's small codebase size (which will make it easy
to inline it into helix in the future if required).
2 years ago
A-Walrus 79a39c1063
Fix failing tests
Add underline field to doctests, and fix bugs
2 years ago
A-Walrus 3ad7d543ca
Add separate color for underlines 2 years ago
Gokul Soumya 999b45b28c
Support different kinds of underline rendering
Adds four new  modifiers that can be used in themes:

- undercurled
- underdashed
- underdotted
- double-underline
2 years ago
Gokul Soumya 6e2aaed5c2
Reuse menu::Item trait in picker (#2814)
* Refactor menu::Item to accomodate external state

Will be useful for storing editor state when reused by pickers.

* Add some type aliases for readability

* Reuse menu::Item trait in picker

This opens the way for merging the menu and picker code in the
future, since a picker is essentially a menu + prompt. More
excitingly, this change will also allow aligning items in the
picker, which would be useful (for example) in the command palette
for aligning the descriptions to the left and the keybinds to
the right in two separate columns.

The item formatting of each picker has been kept as is, even though
there is room for improvement now that we can format the data into
columns, since that is better tackled in a separate PR.

* Rename menu::Item::EditorData to Data

* Call and inline filter_text() in sort_text() completion

* Rename diagnostic picker's Item::Data
2 years ago
Falco Hirschenberger ed89f8897e
Add workspace and document diagnostics picker (#2013)
* Add workspace and document diagnostics picker

fixes #1891

* Fix some of @archseer's annotations

* Add From<&Spans> impl for String

* More descriptive parameter names.

* Adding From<Cow<str>> impls for Span and Spans

* Add new keymap entries to docs

* Avoid some clones

* Fix api change

* Update helix-term/src/application.rs

Co-authored-by: Bjorn Ove Hay Andersen <bjrnove@gmail.com>

* Fix a clippy hint

* Sort diagnostics first by URL and then by severity.

* Sort diagnostics first by URL and then by severity.

* Ignore missing lsp severity entries

* Add truncated filepath

* Typo

* Strip cwd from paths and use url-path without schema

* Make tests a doctest

* Better variable names

Co-authored-by: Falco Hirschenberger <falco.hirschenberger@itwm.fraunhofer.de>
Co-authored-by: Bjorn Ove Hay Andersen <bjrnove@gmail.com>
2 years ago
Gokul Soumya 8e8367eea6
Refactor Margin for fine grained control (#2727) 2 years ago
Ivan Tham 5bcb31a6df Make Borders u8 2 years ago
Ivan Tham 1837b5e4a6 Refactor Block with Default and bitflags
Specifying empty for bitflags is not recommended, it is now removed and added
Default. For BorderType, it now defaults to plain.
2 years ago
chunghha 3a398eec56
fix typos (#2304) 3 years ago
Ludwig Stecher 59c691d2db
Highlight matching text in file picker suggestions (#1635)
* Highlight matching text in file picker suggestions

* Remove cache, specialize highlighting code

* Fix outdated comments
3 years ago
Blaž Hrastnik b935fac957
Fix 1.60 lints 3 years ago
Blaž Hrastnik ad62e1e129 fix: Revert Block widget change that broke autoinfo background 3 years ago
Blaž Hrastnik 094a0aa3f9 Render code actions as a menu, allow adding padding to popup 3 years ago
Omnikar f064894e57
Fix Clippy lints in tests (#1563)
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
3 years ago
Blaž Hrastnik ac81b47a41 Don't calculate symbol width twice
This is potentially costly so we should avoid calling width()
3 years ago
Blaž Hrastnik e7eab95b94 Update to rust 1.58, fix a bunch of optional lints 3 years ago
Mathis Brossier f5b0821860
Fix panics when resizing (#1408)
* Change buffer.get & buffer.get_mut to return Option, Implement Trait Index & IndexMut to panic

* Prevent FilePicker from drawing outside buffer (rust panics)

* apply suggestion

* add function in_bounds to avoid useless calculations

Co-authored-by: mathis <mathis.brossier@universite-paris-saclay.fr>
3 years ago
Blaž Hrastnik 34f46e7502 Bump rust to 1.57, fix new lint failures 3 years ago