Skip to content

Commit

Permalink
Merge pull request #7 from lagerfeuer/master
Browse files Browse the repository at this point in the history
Fix breaking change to Errno introduced in Crystal 0.34.0
  • Loading branch information
lagerfeuer authored Apr 18, 2020
2 parents 21b31dd + 1e1e4d7 commit 687eca3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: fancyline
description: Readline-esque library with fancy features
version: 0.3.1
version: 0.3.2

authors:
- Stefan Merettig <[email protected]>
Expand All @@ -10,6 +10,6 @@ dependencies:
github: Papierkorb/cute
version: ">= 0.3.1"

crystal: 0.32.1
crystal: 0.34.0

license: MPL-2
2 changes: 1 addition & 1 deletion src/fancyline.cr
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class Fancyline
# Copied from IO::FileDescriptor, as this method is sadly `private`.
protected def preserving_tc_mode(fd)
if LibC.tcgetattr(fd, out mode) != 0
raise Errno.new("Failed to enable raw mode on output")
raise RuntimeError.from_errno("Failed to enable raw mode on output")
end

before = mode
Expand Down
12 changes: 9 additions & 3 deletions src/fancyline/key.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ class Fancyline
module Key
enum Control
Backspace = 127
Return = 13 # Same as Ctrl-M
Return = 13 # Same as Ctrl-M
AltReturn
Tab = 9
Tab = 9
ShiftTab
Escape = 27
Escape = 27

CtrlA = 1
CtrlB = 2
Expand Down Expand Up @@ -156,6 +156,8 @@ class Fancyline
when 81 then Control::F2
when 82 then Control::F3
when 83 then Control::F4
else
nil
end
when 91 # Movement and F-keys
case yield.try(&.ord)
Expand Down Expand Up @@ -244,6 +246,8 @@ class Fancyline
when 70 then Control::End
when 72 then Control::Home
when 90 then Control::ShiftTab
else
nil
end
# Alt-Letter keys
when 97 then Control::AltA
Expand Down Expand Up @@ -272,6 +276,8 @@ class Fancyline
when 120 then Control::AltX
when 121 then Control::AltY
when 122 then Control::AltZ
else
nil
end
end
end
Expand Down

0 comments on commit 687eca3

Please sign in to comment.