curses 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +7 -0
- data/curses.gemspec +1 -1
- data/sample/addch.rb +16 -0
- data/sample/attr_demo.rb +32 -0
- data/sample/colors.rb +26 -0
- data/sample/mouse_move.rb +75 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dbe3f75b839ed01f58ee7743d9d2e147491255aabc4292d04ddcf00a2eaec25
|
4
|
+
data.tar.gz: 057d072c126f7d00f8f23cd6fdb246255f94545af1bdb836648b68903a1f959f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bd61ea426ca6a68141099c8f6b734cd9094ade75fb5cb11525f285c41e6bec346e3b163bc0f37e1a29b96857ac1d2430f751f056e28641da7116c46ba458a19
|
7
|
+
data.tar.gz: bd3f77e5ff14b8c9aeb86d2e498a66f53d66999f55eb81848cf953946a10f242d906b2047eb8e342f0149a436766c810d53c3c06ee942e69d3ae20068e3c8e14
|
data/History.md
CHANGED
data/curses.gemspec
CHANGED
data/sample/addch.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative "../lib/curses"
|
2
|
+
include Curses
|
3
|
+
|
4
|
+
init_screen
|
5
|
+
begin
|
6
|
+
addstr("The following letter A should be BOLD and UNDERLINED by using addch:\n")
|
7
|
+
addch('A'.ord | A_BOLD | A_UNDERLINE)
|
8
|
+
|
9
|
+
addstr("\nIt should look the same as when using attron and addstr:\n")
|
10
|
+
attron(A_BOLD | A_UNDERLINE)
|
11
|
+
addstr("A")
|
12
|
+
getch
|
13
|
+
|
14
|
+
ensure
|
15
|
+
close_screen
|
16
|
+
end
|
data/sample/attr_demo.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "curses"
|
2
|
+
include Curses
|
3
|
+
|
4
|
+
init_screen
|
5
|
+
begin
|
6
|
+
attrs = {
|
7
|
+
A_NORMAL => 'Normal display (no highlight)',
|
8
|
+
A_STANDOUT => 'Best highlighting mode of the terminal',
|
9
|
+
A_UNDERLINE => 'Underlining',
|
10
|
+
A_REVERSE => 'Reverse video',
|
11
|
+
A_BLINK => 'Blinking',
|
12
|
+
A_DIM => 'Half bright',
|
13
|
+
A_BOLD => 'Extra bright or bold',
|
14
|
+
A_PROTECT => 'Protected mode',
|
15
|
+
A_INVIS => 'Invisible or blank mode',
|
16
|
+
A_ALTCHARSET => 'Alternate character set',
|
17
|
+
}
|
18
|
+
|
19
|
+
longest_description = attrs.values.map(&:size).max
|
20
|
+
attrs.each { |attribute, description|
|
21
|
+
|
22
|
+
attrset(A_NORMAL)
|
23
|
+
addstr("#{description.ljust(longest_description)}: ")
|
24
|
+
|
25
|
+
attrset(attribute)
|
26
|
+
addstr([*('a'..'z'), *('0'..'9')].join + "\n")
|
27
|
+
}
|
28
|
+
getch
|
29
|
+
|
30
|
+
ensure
|
31
|
+
close_screen
|
32
|
+
end
|
data/sample/colors.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require "curses"
|
2
|
+
include Curses
|
3
|
+
|
4
|
+
begin
|
5
|
+
init_screen
|
6
|
+
|
7
|
+
if !Curses.has_colors?
|
8
|
+
addstr "This Terminal does not support colors!"
|
9
|
+
else
|
10
|
+
start_color
|
11
|
+
|
12
|
+
addstr "This Terminal supports #{colors} colors.\n"
|
13
|
+
|
14
|
+
Curses.colors.times { |i|
|
15
|
+
Curses.init_pair(i, i, 0)
|
16
|
+
attrset(color_pair(i))
|
17
|
+
addstr("#{i.to_s.rjust(3)} ")
|
18
|
+
addstr("\n") if i == 15 || (i > 16 && (i - 15) % 36 == 0)
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
getch
|
23
|
+
|
24
|
+
ensure
|
25
|
+
close_screen
|
26
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Mouse movement tracking using CSI 1003 and 1006 (SGR). Will print a cursor that moves with the mouse.
|
4
|
+
#
|
5
|
+
|
6
|
+
require "curses"
|
7
|
+
include Curses
|
8
|
+
|
9
|
+
@positions = []
|
10
|
+
|
11
|
+
def draw_cursor(y, x, button, state)
|
12
|
+
|
13
|
+
# Keep a trail of 10 previous positions visible on the screen
|
14
|
+
if @positions.size >= 10
|
15
|
+
y_old, x_old = @positions.shift
|
16
|
+
setpos(y_old, x_old)
|
17
|
+
addstr(" ")
|
18
|
+
end
|
19
|
+
|
20
|
+
setpos(2, 1)
|
21
|
+
addstr("Mouse is at y=#{y.to_s.ljust(3)} x=#{x.to_s.ljust(3)} button=#{button.to_s.ljust(3)} #{'%08b' % button}")
|
22
|
+
|
23
|
+
setpos(y, x)
|
24
|
+
addstr("+")
|
25
|
+
@positions << [y, x]
|
26
|
+
end
|
27
|
+
|
28
|
+
init_screen
|
29
|
+
crmode
|
30
|
+
noecho
|
31
|
+
stdscr.box('|', "-")
|
32
|
+
setpos(1,1)
|
33
|
+
addstr("Please move your mouse. Press 'q' to close.")
|
34
|
+
|
35
|
+
begin
|
36
|
+
# Switch on mouse continous position reporting
|
37
|
+
print("\x1b[?1003h")
|
38
|
+
|
39
|
+
# Also enable SGR extended reporting, because otherwise we can only
|
40
|
+
# receive values up to 160x94. Everything else confuses Ruby Curses.
|
41
|
+
print("\x1b[?1006h")
|
42
|
+
|
43
|
+
loop do
|
44
|
+
c = get_char
|
45
|
+
case c
|
46
|
+
when "q"
|
47
|
+
return
|
48
|
+
when "\e" # ESC
|
49
|
+
case get_char
|
50
|
+
when '['
|
51
|
+
csi = ""
|
52
|
+
loop do
|
53
|
+
d = get_char
|
54
|
+
csi += d
|
55
|
+
if d.ord >= 0x40 && d.ord <= 0x7E
|
56
|
+
break
|
57
|
+
end
|
58
|
+
end
|
59
|
+
if /<(\d+);(\d+);(\d+)(m|M)/ =~ csi
|
60
|
+
button = $1.to_i
|
61
|
+
x = $2.to_i
|
62
|
+
y = $3.to_i
|
63
|
+
state = $4
|
64
|
+
draw_cursor(y, x, button, state)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
ensure
|
71
|
+
print("\x1b[?1003l")
|
72
|
+
print("\x1b[?1006l")
|
73
|
+
close_screen
|
74
|
+
end
|
75
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shugo Maeda
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-06-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -64,10 +64,14 @@ files:
|
|
64
64
|
- ext/curses/depend
|
65
65
|
- ext/curses/extconf.rb
|
66
66
|
- lib/curses.rb
|
67
|
+
- sample/addch.rb
|
68
|
+
- sample/attr_demo.rb
|
69
|
+
- sample/colors.rb
|
67
70
|
- sample/form.rb
|
68
71
|
- sample/hello.rb
|
69
72
|
- sample/menu.rb
|
70
73
|
- sample/mouse.rb
|
74
|
+
- sample/mouse_move.rb
|
71
75
|
- sample/rain.rb
|
72
76
|
- sample/view.rb
|
73
77
|
- sample/view2.rb
|