Commit Graph

176 Commits

Author SHA1 Message Date
ftilde 95233e9e5c Add support for alternate screen (#88)
* Add (optional) support for alternate screen (#77)

The user can manually switch between main and alternate screen or
(preferably) use the wrapper struct for automatic screen restoration.

* Add two examples for screen switching

* Improve screen module documentation
2017-02-27 13:42:55 +01:00
IGI-111 ba72d0bcec Added color support detection (#91)
* Added color support detection

Color support is inferred by using either OSC 4 escape codes or the
value of TERM.

* minor refactor and cosmetic changes
2017-02-26 09:35:39 +01:00
Loïc Damien 23ef0260dd Fix 64 bit build for musl and android (#90) 2017-02-25 20:17:54 +01:00
Alexandre Bury c9c91292e5 Replace most `std::io::Write::write` with `write_all` (#82)
`std::io::Write` doesn't guarantees that it will write everything,
and could even return a non-fatal `ErrorKind::Interrupted` error.
`write_all` has exactly the code required to deal with this.
2016-12-21 14:20:48 +01:00
Alexandre Bury 32ff8ba96e Replace UnknownCsi with generalized Event::Unsupported (#80) 2016-12-19 16:40:44 +01:00
ticki f9eaf6d0bc Merge branch 'master' of github.com:Ticki/libterm 2016-12-18 19:29:18 +01:00
ticki 7047acbabf Add `Color` implementation for `&Color`
Fix #53
2016-12-18 19:28:25 +01:00
Alexandre Bury c2df3d7edd Discard leftover input when consumed (#76)
* Discard leftover input when consumed

The iterator given to `parse_event` now `take()` the value from
`leftover`.

* Always save leftover

`parse_event` will consume it when required.

* Remove OptionIterator, directly uses std::option::Iter
2016-12-18 00:49:40 +01:00
Alexandre Bury 00ca758d45 Add `UnknownCSI` event type (#73)
* Add `UnknownCSI` event type.

* Compile test from `raw` module

But don't run it.

* Fix unused import warning in doc-test

* Rename UnknownCSI -> UnknownCsi
2016-12-16 18:20:17 +01:00
ticki e67128f795 Fix wrapping width. 2016-11-10 09:25:20 +01:00
Felix Obenhuber dd3df793dc Fixed build for android targets (#72)
Bionic needs signed ioctrl arguments.
2016-11-06 20:29:39 +01:00
ticki 2f008188e3 Add @gycos to the author list. 2016-11-06 10:26:45 +01:00
Alexandre Bury 8c82c461f9 Handles CSI `~` sequences with multiple values (#70)
* Handles CSI `~` sequences with multiple values

Fixes #62

* Fix doc typo
2016-11-06 10:23:02 +01:00
Alexandre Bury 786001f095 Fix CSI sequence detection (#69)
Properly detects CSI sequence termination.

Fixes #47, #68.
2016-11-06 10:22:12 +01:00
ticki bb8d1704cd Revert "True terminal restoration" (#67) 2016-10-27 22:09:41 +02:00
IGI-111 0e0b5be856 Added true terminal restoration (#66)
Using the "alternate screen" capability, the RawTerminal trait restores
the terminal in its previous state by sending the proper escape codes.
2016-10-27 22:03:29 +02:00
Alexandre Bury 09d31132e2 Protects AsyncReader::read against empty buffer. (#65)
Move the check to the beginning of the loop to protect against empty buffer.
2016-10-27 22:02:29 +02:00
Matthew Nicholson ea06c6fd56 Modify Keys and Events to detect Esc key presses (#45)
* modify Keys and Events to detect Esc key presses

The strategy used here is to read two bytes at a time, going on the
assumption that escape sequences will consist of multi byte reads and
solitary Esc key presses will consist of single byte reads.

Tests had to be modified to account for these new multi byte reads by
including dummy bytes when a single byte was previously expected.

Fixes ticki/termion#43

* expand keys example to include Esc key presses

* add test for Esc key press
2016-10-26 11:53:36 +02:00
Jordan MacDonald 654db645cb Derive PartialEq for Rgb type (#56) 2016-10-22 08:40:06 +02:00
David Irvine 5085815f58 bug/lib.rs Allow musl builds (#58) 2016-10-20 14:28:34 +02:00
Alexandre Bury 4358ed6c48 Derive Copy for color::{Rgb, Fg, Bg, Reset} (#54) 2016-10-09 07:13:41 +02:00
Esption a0751f21b0 Add Debug to color structs and Clone to Rgb / Fg / Bg (#51) 2016-10-03 07:15:12 +02:00
ticki f2cec304e8 Default to the TTY device in async_stdin. 2016-09-24 20:04:46 +02:00
ticki 0d1025c532 Take a reference to the stream instead of the stream itself (in `is_tty` 2016-09-24 19:13:16 +02:00
ticki e63b645859 Update the documentation. 2016-09-07 11:39:32 +02:00
ticki 2ff0916514 Bump to 1.0.7. 2016-09-07 11:09:48 +02:00
IGI-111 5ebda9866f added mouse hold support (#48)
This adds support for the escape codes generated in rxvt and xterm
format by holding a button and moving the mouse around.
2016-09-07 11:05:41 +02:00
llogiq 21716b2f93 fixed a few clippy warnings (#44) 2016-08-04 22:37:03 +02:00
Jeremy Soller a3cc227620 Convert VarError to io::Error (#41) 2016-07-30 16:37:12 +02:00
Jeremy Soller f9928bd6fe Fix Redox `get_tty` by adding `env` import (#40) 2016-07-30 11:48:27 +02:00
ticki 7e3ed4ec93 Fix Redox get_tty 2016-07-29 21:56:33 +02:00
ticki 8572ee6eb8 Get the tty device, get_tty 2016-07-29 19:49:29 +02:00
ticki 5634d5d082 Fix Goto 2016-07-24 20:22:47 +02:00
ticki cd6b692db4 Merge pull request #33 from jackpot51/patch-1
Add escapes to undo styles
2016-07-24 19:56:45 +02:00
Jeremy Soller b81bcc6749 Fix formatting 2016-07-24 08:24:49 -06:00
Jeremy Soller ef023ed596 Allow colors to be reset to terminal defaults 2016-07-24 08:23:10 -06:00
Jeremy Soller 6cdcbac536 Add escapes to undo styles 2016-07-24 08:19:34 -06:00
Jeremy Soller fae35e2ea1 Fix RawTerminal drop 2016-07-24 07:07:21 -06:00
ticki 25c7cd8635 Fix Redox raw mode 2016-07-23 22:06:17 +02:00
ticki 9bd833a663 Fix the tests 2016-07-23 20:41:43 +02:00
ticki 59d4ae427a Fix mouse input 2016-07-23 19:03:03 +02:00
ticki 30afb4c32e Fix examples & merge 2016-07-23 18:50:33 +02:00
ticki 5b94db9663 Merge 2016-07-23 17:49:52 +02:00
ticki e36ff1c71b Termion 1.0.0: Complete overhaul of how escape codes are handled, add truecolor support.
This commit is a major semver bump. Every progra utilizing escape codes generated by Termion is likely broken. The main change is to make each escape has their own type implementing the Display trait.

- Use formatters, mainly Display for escapes.

- Add Truecolor support (`color::Rgb`).

- Put each primitive into distinct modules.

- Add is_tty for checking if some stream is a TTY.

- Add multiple new examples.
2016-07-23 16:40:27 +02:00
ticki fb1d702b13 Merge pull request #29 from IGI-111/master
Implemented mouse input
2016-07-20 13:54:56 +02:00
IGI-111 1c50a795f8 added some tests 2016-07-20 13:06:04 +02:00
IGI-111 ab12a8f8a6 fixed formatting 2016-07-20 11:03:30 +02:00
IGI-111 206c61de9e made mouse optional and fixed small issues 2016-07-20 01:13:03 +02:00
ticki 220005031b Merge pull request #27 from Munksgaard/add-controls
Add more controls
2016-07-19 22:30:20 +02:00
IGI-111 cc9c32b981 added mouse input
The event system has been reworked to allow the detection of mouse
events as well as key presses.
Xterm, rxvt and X10 emulated escape codes are supported, they are
enabled and disabled by sending the right escape codes when creating a
RawTerminal.

To allow for byte manipulation, which was necessary to implement those
features, the backend iterator has been changed from chars() to bytes()
(with specific treatment of unicode sequences), making the whole crate
not require nightly rustc.
2016-07-19 18:17:12 +02:00
IGI-111 2f6ebb8669 added tests 2016-07-16 22:46:29 +02:00
IGI-111 4402ebd8b3 fix wrong range used 2016-07-16 19:21:51 +02:00
IGI-111 5eae7cf732 function keys now use ranges for detection 2016-07-16 19:10:04 +02:00
IGI-111 70c12b20d6 added doc for function keys 2016-07-16 18:51:33 +02:00
IGI-111 3552c6eae0 added rxvt Home and End escape codes 2016-07-15 12:19:02 +02:00
IGI-111 0e74a7672f added more special keys
Key now supports Home, End, PageUp, PageDown, Delete, Insert and
Function keys. All this is done through the detection of both VT100
escape codes and more modern standard counterparts.
For instance, F2 can be both
    ESC OQ
on VT100, screen, and some versions of xterm and
    ESC [12~
on rxvt and other xterm versions depending on your terminal
2016-07-15 07:41:31 +02:00
Philip Munksgaard fa75b334d0 Improve function documentation 2016-07-14 21:51:00 +02:00
Philip Munksgaard 7a723b0ef5 Add more controls
Add support for scrolling up and down, and moving the cursor up and
down.
2016-07-13 23:43:37 +02:00
ticki 133497a4be Inline 2016-07-02 16:17:07 +02:00
ticki d52e2a2426 Fix documentation for colors 2016-07-02 15:59:51 +02:00
ticki a7821206e9 Update README 2016-07-02 15:42:18 +02:00
ticki b499d4825f Refactor how colors are handled 2016-07-02 15:06:47 +02:00
ticki 8bcb946b07 Update readme 2016-06-14 14:29:31 +02:00
ticki 49bb0932c7 Merge branch 'master' of github.com:Ticki/libterm 2016-06-14 14:24:23 +02:00
ticki 11225e561d Fix #24, make use of Result instead 2016-06-14 14:24:07 +02:00
MovingtoMars aaeeb06d42 fix cursor moving 2016-06-11 22:29:04 +12:00
MovingtoMars d1b3cf6633 add move_cursor_{left,right} to TermWrite 2016-06-11 11:23:30 +12:00
ticki 119cbda718 Switch from usize to u16 in terminal_size 2016-05-03 19:42:37 +02:00
Ticki b36e5fa721 Fix build with 'nightly' feature 2016-04-02 23:06:10 +02:00
Ticki 6a792cd86d Add unit tests for read_line 2016-04-02 19:20:47 +02:00
Ticki b5c4f2512d Merge pull request #14 from untitaker/refactor-read-passwd
Refactor read_passwd
2016-04-02 18:32:39 +02:00
Ticki bf1a6ecc2e Amend #15 2016-04-02 18:31:03 +02:00
Jeremy Soller f5936c0035 Use env for terminal size in redox
Undo color changes to test redox 256 color support

Get terminal size for Redox's kernel terminal

Use env for terminal size in redox
2016-04-02 18:31:03 +02:00
Jeremy Soller cd59514615 Use 8-color mode when possible. 2016-04-02 18:30:48 +02:00
Ticki b288548756 Fix #18 2016-04-02 18:05:31 +02:00
Ticki 7da5fbf36f Clean up imports in raw module 2016-03-20 22:55:08 +01:00
Markus Unterwaditzer cdd7a302b2 Refactor read_passwd
Line-reading logic is now in its own method
2016-03-20 16:15:05 +01:00
Ticki 12e08141c4 Merge branch 'master' of github.com:Ticki/libterm 2016-03-17 17:13:11 +01:00
Ticki b10a24e112 Remove 'into_async', use 'async_stdin' instead 2016-03-17 17:12:47 +01:00
Jeremy Soller 72f87e0176 Fix redox support 2016-03-16 12:59:12 -06:00
shortenda 65615c3c39 Fix typo 2016-03-16 01:43:35 -07:00
Ticki 7d1d424c8a Small doc fixes 2016-03-16 08:52:09 +01:00
Ticki 28a95cf447 Libterm is now termion 2016-03-15 21:36:33 +01:00
Ticki 6ca81b2ec0 Fix nightly feature 2016-03-15 20:56:53 +01:00
Ticki b65328c304 Asynchronous key events 2016-03-15 20:32:25 +01:00
Ticki 73ae06124a Add Key::Null for null bytes 2016-03-15 18:01:33 +01:00
Ticki 32d8ccfa24 Use IO error, instead of a custom one 2016-03-13 11:55:24 +01:00
Ticki 7145651a83 Fix bug in Keys 2016-03-10 21:57:42 +01:00
Ticki 2335596a1a TerminalRestorer -> RawTerminal 2016-03-10 16:24:41 +01:00
Ticki 9efbb4e227 Fix ctrl input 2016-03-10 15:21:11 +01:00
Ticki d8e5ea3262 CTRL modified input 2016-03-10 15:12:59 +01:00
Ticki 3800f31e92 Use libc termios struct 2016-03-10 07:05:08 +01:00
Ticki 08746c0d2a Add tests to 'terminal_size' 2016-03-09 19:17:00 +01:00
Ticki 5d4826d4ff Add test to _everything_ 2016-03-09 17:18:31 +01:00
Ticki 7269b5f07d Add restore() method for restoring the defaults 2016-03-09 13:07:38 +01:00
Ticki 0efce912d0 Minor cosmetic changes 2016-03-09 11:38:43 +01:00
Ticki 543b2f8975 Hi -> Light 2016-03-09 11:19:51 +01:00
Ticki 6f1621d2d0 Introduce 'Key', which can decode special key input 2016-03-09 09:39:22 +01:00
Ticki abe4681158 Fix examples 2016-03-08 21:40:48 +01:00
Ticki a16cc84ea3 Rename WriteExt to TermWrite 2016-03-08 21:39:24 +01:00