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

Already on GitHub? Sign in to your account

Some fixes for Linux terminals (specifically, libvte based ones) #13

Merged
merged 3 commits into from Mar 12, 2013

Conversation

Projects
None yet
2 participants
Contributor

epitron commented Mar 11, 2013

  • HOME/END keys fixed

  • Alt-D hotkey added (deletes the next word, standard in readline)

  • IO#getch replaced with IO#raw to make ALT-keys and arrow-keys work in VTE
    (Any keys which send more than 1 character to the terminal were getting
    the 2nd and/or 3rd characters dropped.

    After investigation, I figured out that IO#getch was using system calls
    to initialize/deinitialize raw mode EVERY time you called it. This introduced
    enough delay that it would miss some characters.

    KDE's konsole didn't have this problem because it emulates a 9600 baud modem,
    but VTE-based terminals, like gnome-terminal, guake, and xfce4-terminal
    send all the characters immediately.

    The solution was to just initialize raw mode once with IO#raw, and only
    deinitialize it after the user was finished with readline.

    This should fix pasting problems in VTE as well.)

@epitron epitron Some fixes for Linux terminals (specifically, libvte based ones):
 - HOME/END keys fixed
 - Alt-D hotkey added (deletes the next word, standard in readline)
 - IO#getch replaced with IO#raw to make ALT-keys and arrow-keys work in VTE
   (Any keys which send more than 1 character to the terminal were getting
   the 2nd and/or 3rd characters dropped.

   After investigation, I figured out that IO#getch was using system calls
   to initialize/deinitialize raw mode EVERY time you called it. This introduced
   enough delay that it would miss some characters.

   KDE's konsole didn't have this problem because it emulates a 9600 baud modem,
   but VTE-based terminals, like gnome-terminal, guake, and xfce4-terminal
   send all the characters immediately.

   The solution was to just initialize raw mode once with IO#raw, and only
   deinitialize it after the user was finished with readline.

   This should fix pasting problems in VTE as well.)
533d4f7
Contributor

epitron commented Mar 11, 2013

NOTE: This commit is a lot more readable in WORD-diff mode: epitron/coolline@533d4f7?w=1

epitron added some commits Mar 11, 2013

@epitron epitron Added a "default_line" parameter to the readline method, which pre-po…
…pulates the input line with the string of your choice. Also added a "replace_line" method, for use in callbacks that replace the entire line.
925b91d
@epitron epitron Updated the gemspec:
 * Renamed to .gemspec (new style)
 * 'README.md' will now be shown as the first page in rdoc/yard (or on rdoc.info)

Updated Rakefile:
 * New tasks: build, install, release

Bumped the gem version to 0.4.1
04c43b2

@Mon-Ouie Mon-Ouie merged commit 04c43b2 into Mon-Ouie:master Mar 12, 2013

Contributor

epitron commented Mar 12, 2013

Sweeeeet.

Owner

Mon-Ouie commented Apr 6, 2013

I think I might have reintroduced one issue I have here.

The problem with IO#read is that it reads a single /byte/, which causes
encoding issues when the user inputs multibyte characters.

I'm not sure how to get both issues fixed (or if IO#getch still makes those
syscalls every time if the input is already in raw-mode)

EDIT:

I just realize I can just use IO#getc. This shouldn't reintroduce your problem.

Contributor

epitron commented Apr 6, 2013

Good old IO! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment