Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Reimplement builtin terminal UI with termkey/unibilium #1820

Merged
merged 14 commits into from
Feb 17, 2015

Conversation

tarruda
Copy link
Member

@tarruda tarruda commented Jan 15, 2015

This PR will throw a lot of old code into the garbage can.

@justinmk
Copy link
Member

:)

@@ -4,6 +4,7 @@
/.deps/
/tmp/

*.i
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the build put *.i files in the build/ subdirectories (in which case, ignoring them here wouldn't be necessary)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@marvim marvim added the WIP label Jan 15, 2015
@bfredl
Copy link
Member

bfredl commented Jan 15, 2015

Nice line count of this PR. 👍 Segfaults for the moment with my nvimrc tho, but with nvim -u NONE it works just fine :)

@bfredl
Copy link
Member

bfredl commented Jan 15, 2015

Not sure if helpful, but all craches ends with

Program received signal SIGABRT, Aborted.
0x00007fa72c06ba97 in raise () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007fa72c06ba97 in raise () from /usr/lib/libc.so.6
#1  0x00007fa72c06ce6a in abort () from /usr/lib/libc.so.6
#2  0x00007fa72c0ab2b3 in __libc_message () from /usr/lib/libc.so.6
#3  0x00007fa72c0b072e in malloc_printerr () from /usr/lib/libc.so.6
#4  0x00007fa72c0b0eeb in _int_free () from /usr/lib/libc.so.6
#5  0x00000000005f48b5 in destroy_screen (ui=0x170aff0) at /home/bjorn/Programming/neovim/src/nvim/tui/tui.c:315
#6  0x00000000005f448c in try_resize (ev=...) at /home/bjorn/Programming/neovim/src/nvim/tui/tui.c:241
#7  0x00000000005e328d in process_events_from (queue=0x16fac90) at /home/bjorn/Programming/neovim/src/nvim/os/event.c:174
#8  0x00000000005e3189 in event_poll (ms=0) at /home/bjorn/Programming/neovim/src/nvim/os/event.c:135
#9  0x00000000005e59d2 in input_poll (ms=0) at /home/bjorn/Programming/neovim/src/nvim/os/input.c:25

It crashes on resize and at random times it decides to resize itself (e.g. when doing cmdline completion) with the aforementioned result.

@BlackEdder
Copy link

This ui doesn't seem to work correctly with terminology (https://www.enlightenment.org/p.php?p=about/terminology) and from my limited testing neither did pynvim. The problem seem to have to do with getting the correct terminal width. The first letter of every sentence starts at the end of the line and then wraps around. Might be a tickit issue I guess (@leonerd)?

@@ -189,8 +192,14 @@ list(APPEND NVIM_LINK_LIBRARIES
${LIBUV_LIBRARIES}
${MSGPACK_LIBRARIES}
${LUAJIT_LIBRARIES}
"-Wl,--whole-archive"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is failing to build on Mac OS X:

ld: unknown option: --whole-archive

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should add that the error above is on Yosemite where it is using LLVM's linker. Mavericks is probably a different story, but FreeBSD may fail as well. There is a -all_load, but the corresponding -noall_load is obsolete. Turns out -all_load affects all static archives. :-( There is also a -force_load LIBRARY, but detecting the presence of the option at build time is kind of a pain since it requires an archive.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I don't understand why this flag is necessary for libtickit & dependencies, I've used it before but only for building shared libraries that include other static libraries. Do you know a another way of avoiding missing reference errors during link stage?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just reverse the order to:

${LIBTICKIT_LIBRARIES}
${LIBTERMKEY_LIBRARIES}
${LIBUNIBILIUM_LIBRARIES}

And it is fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just reverse the order to:

👍 great, thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to understand why the change in order was necessary. Is it because unibilium/termkey are skipped when it determines none of its symbols are directly used by the nvim binary? If so then it actually makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because linking is very linear. In this case, libtickit depends on both libtermkey and libunibilium. If you link libtickit last, then those functions won't be resolved again (because they were present in previous libraries). However, if you change the order so that libtickit gets linked first, then the linker knows about the unresolved functions in libtickit can fix them up correctly when libtermkey and libunibilium are linked in next.

In general, you want the objects with the most dependencies to be linked in first, and the objects with no dependencies linked in last. And you want to make sure to link the dependencies in after the object that requires them. What you are really doing is a topological sort. :-)

@tarruda
Copy link
Member Author

tarruda commented Jan 16, 2015

Nice line count of this PR. 👍 Segfaults for the moment with my nvimrc tho, but with nvim -u NONE it works just fine :)

I'm just getting started, I think this PR will remove more than 7k lines :)

It crashes on resize and at random times it decides to resize itself (e.g. when doing cmdline completion) with the aforementioned result.

Could be what @oni-link spotted, I will investigate.

@tarruda
Copy link
Member Author

tarruda commented Jan 17, 2015

This ui doesn't seem to work correctly with terminology (https://www.enlightenment.org/p.php?p=about/terminology) and from my limited testing neither did pynvim. The problem seem to have to do with getting the correct terminal width. The first letter of every sentence starts at the end of the line and then wraps around. Might be a tickit issue I guess (@leonerd)?

👍 Will investigate.

Some legacy functional tests are failing, but the UI should be as stable as the python version.

@fwalch
Copy link
Member

fwalch commented Jan 17, 2015

Is it possible to get the libtickit/libtermkey changes into upstream before this is merged into master? I ask because e.g. Arch Linux will need to package these libraries, and first introducing a special libtickit-unstable-neovim and then replacing it with libtickit-unstable at some point will be a bit more work.

@tarruda
Copy link
Member Author

tarruda commented Jan 17, 2015

Is it possible to get the libtickit/libtermkey changes into upstream before this is merged into master? I ask because e.g. Arch Linux will need to package these libraries, and first introducing a special libtickit-unstable-neovim and then replacing it with libtickit-unstable at some point will be a bit more work.

👍. Don't worry as this will only be merged when all tests are fixed and the changes are sent back to @leonerd.

Did you get a chance to test this branch? How stable is it for you?

@fwalch
Copy link
Member

fwalch commented Jan 17, 2015

Did you get a chance to test this branch? How stable is it for you?

I had to check nvim --version to make sure I'm really using this branch, because I didn't notice any differences. Didn't have any problems so far :-)

@tarruda
Copy link
Member Author

tarruda commented Jan 17, 2015

I had to check nvim --version to make sure I'm really using this branch, because I didn't notice any differences. Didn't have any problems so far :-)

Nice, if you don't mind please keep using it. This PR introduces some serious architectural changes and the more people are testing it the better.

I'm interested in knowing this branch deals with troubling key mappings. One of the compelling reasons I choose libtickit/libtermkey is because it is capable of understanding an encoding scheme that uniquely identifies each key(though I'm not sure if some special terminal configuration is required for that)

// setup libtickit
data->tt = tickit_term_new();
tickit_term_set_input_fd(data->tt, data->in_fd);
tickit_term_set_output_fd(data->tt, data->in_fd);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data->out_fd instead of data->in_fd?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

char buf[64];

if (type == TICKIT_KEYEV_KEY) {
if (!strcmp("BackSpace", str)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Backspace instead of BackSpace.

@tarruda tarruda mentioned this pull request Jan 17, 2015
@Tranquility
Copy link
Contributor

I realized a small problem with the shell output. Unlike the pynvim ui it is extremely fast which is awesome but the the background color is wrong. Only the text has background color of the colorscheme but the part without text is black.

@aktau
Copy link
Contributor

aktau commented Jan 18, 2015

I'm not entirely through the code yet, but where did input encoding go? (the removed lines in os/input.c).

@tarruda
Copy link
Member Author

tarruda commented Jan 19, 2015

I'm not entirely through the code yet, but where did input encoding go? (the removed lines in os/input.c).

I've removed it, the input_enqueue function should always receive utf-8 strings as input. I'm gonna investigate if that input conversion code is really necessary, and if so it will be done in the tickit UI layer.

@tarruda
Copy link
Member Author

tarruda commented Feb 17, 2015

Ok, this is as ready as its gonna get, merging after the tests.

@elmart as soon as you identify a pattern for reproducing the YCM slowdown, I will investigate and hopefully come up with a fix soon

@justinmk
Copy link
Member

Great job!

The `wait` function will only return after all input has been processed by nvim.
It is useful to time assertions correctly.
Without waiting for the 'gg' command to be processed, its possible that the
following assertion will fail.
The `system` function is never executed with these tests because the ctrl+c is
queued with the input string that calls it(The `process_interrupts` function
will destroy all previous input when a ctrl+c is found).
Some screen tests such as system/ctrl+c(viml_system_spec.lua) can take some time
to respond(default kill timeout is 2 seconds for an interrupted job) and fail
when running under a slow environment such as travis.
This is required to correctly handle certain keys such as <delete>
Ignore all keys that aren't prefixed with KS_EXTRA.
The input buffer is only used for data that really came from another process and
is only visible to os/input.c. Remove the input_buffer_{save,restore} functions,
they are not necessary(Also can result in problems if data comes while the
typeahead is saved).
- Remove abstract_ui global, now it is always active
- Remove some terminal handling code
- Remove unused functions
- Remove HAVE_TGETENT/TERMINFO/TERMIOS/IOCTL #ifdefs
- Remove tgetent/terminfo from version.c
- Remove curses/terminfo dependencies
- Only start/stop termcap when starting/exiting the program
- msg_use_printf will return true if there are no attached UIs(
  messages will be written to stdout)
- Remove `ex_winpos`(implement `:winpos` with `ex_ni`)
Now all terminal-handling code was moved to src/nvim/tui, which implements a
new terminal UI based on libtermkey and unibilium
Now the attrentry_T structure will store all attributes in separate fields for
cterm and rgb UIs.
- The syntax `gui=` is invalid when setting properties of highlight group.
- Wait for the initial "-- More --" prompt before continuing. Required to avoid
  a race condition
@tarruda tarruda changed the title [RFC] Reimplement builtin terminal UI using libtermkey/unibilium [RFC] Reimplement builtin terminal UI with termkey/unibilium Feb 17, 2015
@tarruda tarruda merged commit 40b7990 into neovim:master Feb 17, 2015
@jszakmeister jszakmeister removed the RFC label Feb 17, 2015
@bigeagle
Copy link

Hi, using the merged version, there're still a problem that the terminal's background color cannot be automatically "resetted". To repeat this bug, nvim -u NONE and try to show some error message, e.g. :q on an unsaved file and there would be an error message with red bg color, now press : and the red background is still there.
I'm using xterm-256color.

@neovim neovim locked and limited conversation to collaborators Feb 17, 2015
@justinmk
Copy link
Member

Please report in a new issue.

@elmart
Copy link
Contributor

elmart commented Feb 18, 2015

as soon as you identify a pattern for reproducing the YCM slowdown, I will investigate and hopefully come up with a fix soon

Ok.

Really great work, @tarruda. Thumbs up! 👍

@mjlbach mjlbach added this to Done in LSP integration Mar 14, 2021
@mjlbach mjlbach removed this from Done in LSP integration Mar 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
refactor changes that are not features or bugfixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet