curses 1.4.1 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ubuntu.yml +1 -1
- data/.github/workflows/windows.yml +1 -1
- data/History.md +23 -0
- data/curses.gemspec +2 -2
- data/ext/curses/curses.c +139 -3
- data/sample/addch.rb +19 -0
- data/sample/attr_demo.rb +32 -0
- data/sample/colors.rb +26 -0
- data/sample/mouse_move.rb +75 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8f509004a715c7c6215130a814987b82b964d9dcf3606e6a289e1666b3a5577
|
4
|
+
data.tar.gz: 0e54526e4d59b8e7d4b154403d71e7bae99db4cfe0dea25ce381f737f265bfef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 168a0e62efe441de9fa4f737c4f83085f48f4c9330a4f9d2f0eb98beed3bb1a39ec68beb3ee59fa4ba78000c6805a51e039c4c99a8540d7e84b805620749ba17
|
7
|
+
data.tar.gz: deed017c806a7cc9fddb233ad58d52c545473f578238fb514bed2af63003e2ec74488edfdb0c281ed255e47d16b487ce0a74d0d2e24b43a9c3ea4a00f900e2f2
|
data/History.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
### 1.4.4 / 2022-02-03
|
2
|
+
|
3
|
+
Bug fixes:
|
4
|
+
|
5
|
+
* Define Curses.colors even if COLORS is a macro.
|
6
|
+
Issue #69 by dvarrui.
|
7
|
+
* Use require instead of require_relative.
|
8
|
+
Pull request #68 by dvarrui.
|
9
|
+
|
10
|
+
### 1.4.3 / 2022-01-06
|
11
|
+
|
12
|
+
New features:
|
13
|
+
|
14
|
+
* Added flushinp, menu mark, fore and back functions.
|
15
|
+
Pull request #66 by Isty001.
|
16
|
+
|
17
|
+
### 1.4.2 / 2021-06-14
|
18
|
+
|
19
|
+
New features:
|
20
|
+
|
21
|
+
* Added samples for addch, attron, mouse tracking and colors.
|
22
|
+
Pull request #62 by coezbek.
|
23
|
+
|
1
24
|
### 1.4.1 / 2021-05-22
|
2
25
|
|
3
26
|
Bug fixes:
|
data/curses.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new { |s|
|
2
2
|
s.name = "curses"
|
3
|
-
s.version = "1.4.
|
3
|
+
s.version = "1.4.4"
|
4
4
|
s.author = ["Shugo Maeda", 'Eric Hodel']
|
5
5
|
s.email = ["shugo@ruby-lang.org", 'drbrain@segment7.net']
|
6
6
|
s.homepage = "https://github.com/ruby/curses"
|
@@ -9,7 +9,7 @@ Gem::Specification.new { |s|
|
|
9
9
|
s.files = `git ls-files --recurse-submodules -z`.split("\x0")
|
10
10
|
s.extensions = ["ext/curses/extconf.rb"]
|
11
11
|
s.require_path = "lib"
|
12
|
-
s.required_ruby_version = Gem::Requirement.new('>= 2.
|
12
|
+
s.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
|
13
13
|
s.licenses = ['Ruby', 'BSD-2-Clause']
|
14
14
|
s.add_development_dependency 'bundler'
|
15
15
|
s.add_development_dependency 'rake'
|
data/ext/curses/curses.c
CHANGED
@@ -620,6 +620,20 @@ curses_nonl(VALUE obj)
|
|
620
620
|
return Qnil;
|
621
621
|
}
|
622
622
|
|
623
|
+
/*
|
624
|
+
* Document-method: Curses.flushinp
|
625
|
+
*
|
626
|
+
* The flushinp routine throws away any typeahead that has been
|
627
|
+
* typed by the user and has not yet been read by the program.
|
628
|
+
*/
|
629
|
+
static VALUE
|
630
|
+
curses_flushinp(VALUE obj)
|
631
|
+
{
|
632
|
+
curses_stdscr();
|
633
|
+
flushinp();
|
634
|
+
return Qnil;
|
635
|
+
}
|
636
|
+
|
623
637
|
/*
|
624
638
|
* Document-method: Curses.beep
|
625
639
|
*
|
@@ -1352,9 +1366,9 @@ curses_can_change_color(VALUE obj)
|
|
1352
1366
|
return can_change_color() ? Qtrue : Qfalse;
|
1353
1367
|
}
|
1354
1368
|
|
1355
|
-
#if defined(HAVE_COLORS)
|
1369
|
+
#if defined(HAVE_COLORS) || defined(COLORS)
|
1356
1370
|
/*
|
1357
|
-
* Document-method: Curses.
|
1371
|
+
* Document-method: Curses.colors
|
1358
1372
|
*
|
1359
1373
|
* returns COLORS
|
1360
1374
|
*/
|
@@ -1384,7 +1398,7 @@ curses_color_content(VALUE obj, VALUE color)
|
|
1384
1398
|
}
|
1385
1399
|
|
1386
1400
|
|
1387
|
-
#if defined(HAVE_COLOR_PAIRS)
|
1401
|
+
#if defined(HAVE_COLOR_PAIRS) || defined(COLOR_PAIRS)
|
1388
1402
|
/*
|
1389
1403
|
* Document-method: Curses.color_pairs
|
1390
1404
|
*
|
@@ -3618,6 +3632,121 @@ menu_set_format(VALUE obj, VALUE rows, VALUE cols)
|
|
3618
3632
|
return obj;
|
3619
3633
|
}
|
3620
3634
|
|
3635
|
+
/*
|
3636
|
+
* Document-method: Curses::Menu#mark=
|
3637
|
+
*
|
3638
|
+
* call-seq:
|
3639
|
+
* mark=(str)
|
3640
|
+
*
|
3641
|
+
* Set the mark string to distinguish the selected items
|
3642
|
+
*/
|
3643
|
+
static VALUE
|
3644
|
+
menu_set_mark(VALUE obj, VALUE mark)
|
3645
|
+
{
|
3646
|
+
struct menudata *menup;
|
3647
|
+
|
3648
|
+
GetMENU(obj, menup);
|
3649
|
+
set_menu_mark(menup->menu, StringValueCStr(mark));
|
3650
|
+
|
3651
|
+
return obj;
|
3652
|
+
}
|
3653
|
+
|
3654
|
+
/*
|
3655
|
+
* Document-method: Curses::Menu#mark
|
3656
|
+
*
|
3657
|
+
* call-seq:
|
3658
|
+
* mark
|
3659
|
+
*
|
3660
|
+
* Get the Menu's mark string
|
3661
|
+
*/
|
3662
|
+
static VALUE
|
3663
|
+
menu_get_mark(VALUE obj)
|
3664
|
+
{
|
3665
|
+
struct menudata *menup;
|
3666
|
+
const char *mark;
|
3667
|
+
|
3668
|
+
GetMENU(obj, menup);
|
3669
|
+
mark = menu_mark(menup->menu);
|
3670
|
+
|
3671
|
+
return rb_external_str_new_with_enc(mark, strlen(mark), terminal_encoding);
|
3672
|
+
}
|
3673
|
+
|
3674
|
+
/*
|
3675
|
+
* Document-method: Curses::Menu#fore=
|
3676
|
+
*
|
3677
|
+
* call-seq:
|
3678
|
+
* fore=(attr)
|
3679
|
+
*
|
3680
|
+
* Sets the foreground attribute of menu.
|
3681
|
+
* This is the highlight used for selected menu items.
|
3682
|
+
*/
|
3683
|
+
static VALUE
|
3684
|
+
menu_set_fore(VALUE obj, VALUE attr)
|
3685
|
+
{
|
3686
|
+
struct menudata *menup;
|
3687
|
+
|
3688
|
+
GetMENU(obj, menup);
|
3689
|
+
set_menu_fore(menup->menu, NUM2CHTYPE(attr));
|
3690
|
+
|
3691
|
+
return attr;
|
3692
|
+
}
|
3693
|
+
|
3694
|
+
/*
|
3695
|
+
* Document-method: Curses::Menu#fore
|
3696
|
+
*
|
3697
|
+
* call-seq:
|
3698
|
+
* fore
|
3699
|
+
*
|
3700
|
+
* Sets the foreground attribute of menu.
|
3701
|
+
* This is the highlight used for selected menu items.
|
3702
|
+
*/
|
3703
|
+
static VALUE
|
3704
|
+
menu_get_fore(VALUE obj, VALUE attr)
|
3705
|
+
{
|
3706
|
+
struct menudata *menup;
|
3707
|
+
|
3708
|
+
GetMENU(obj, menup);
|
3709
|
+
|
3710
|
+
return CHTYPE2NUM(menu_fore(menup->menu));
|
3711
|
+
}
|
3712
|
+
|
3713
|
+
/*
|
3714
|
+
* Document-method: Curses::Menu#set_back
|
3715
|
+
*
|
3716
|
+
* call-seq:
|
3717
|
+
* set_back(attr)
|
3718
|
+
*
|
3719
|
+
* Get the background attribute of menu.
|
3720
|
+
*/
|
3721
|
+
static VALUE
|
3722
|
+
menu_set_back(VALUE obj, VALUE attr)
|
3723
|
+
{
|
3724
|
+
struct menudata *menup;
|
3725
|
+
|
3726
|
+
GetMENU(obj, menup);
|
3727
|
+
CHTYPE2NUM(set_menu_back(menup->menu, NUM2CHTYPE(attr)));
|
3728
|
+
|
3729
|
+
return attr;
|
3730
|
+
}
|
3731
|
+
|
3732
|
+
/*
|
3733
|
+
* Document-method: Curses::Menu#back
|
3734
|
+
*
|
3735
|
+
* call-seq:
|
3736
|
+
* back
|
3737
|
+
*
|
3738
|
+
* Get the background attribute of menu.
|
3739
|
+
*/
|
3740
|
+
static VALUE
|
3741
|
+
menu_get_back(VALUE obj, VALUE attr)
|
3742
|
+
{
|
3743
|
+
struct menudata *menup;
|
3744
|
+
|
3745
|
+
GetMENU(obj, menup);
|
3746
|
+
|
3747
|
+
return CHTYPE2NUM(menu_back(menup->menu));
|
3748
|
+
}
|
3749
|
+
|
3621
3750
|
/*
|
3622
3751
|
* Document-method: Curses::Menu#format
|
3623
3752
|
*
|
@@ -4753,6 +4882,7 @@ Init_curses(void)
|
|
4753
4882
|
rb_define_module_function(mCurses, "nocrmode", curses_nocbreak, 0);
|
4754
4883
|
rb_define_module_function(mCurses, "nl", curses_nl, 0);
|
4755
4884
|
rb_define_module_function(mCurses, "nonl", curses_nonl, 0);
|
4885
|
+
rb_define_module_function(mCurses, "flushinp", curses_flushinp, 0);
|
4756
4886
|
rb_define_module_function(mCurses, "beep", curses_beep, 0);
|
4757
4887
|
rb_define_module_function(mCurses, "flash", curses_flash, 0);
|
4758
4888
|
rb_define_module_function(mCurses, "ungetch", curses_ungetch, 1);
|
@@ -4988,6 +5118,12 @@ Init_curses(void)
|
|
4988
5118
|
rb_define_method(cMenu, "scale", menu_scale, 0);
|
4989
5119
|
rb_define_method(cMenu, "set_format", menu_set_format, 2);
|
4990
5120
|
rb_define_method(cMenu, "format", menu_format_m, 0);
|
5121
|
+
rb_define_method(cMenu, "mark=", menu_set_mark, 1);
|
5122
|
+
rb_define_method(cMenu, "mark", menu_get_mark, 0);
|
5123
|
+
rb_define_method(cMenu, "fore=", menu_set_fore, 1);
|
5124
|
+
rb_define_method(cMenu, "fore", menu_get_fore, 0);
|
5125
|
+
rb_define_method(cMenu, "back=", menu_set_back, 1);
|
5126
|
+
rb_define_method(cMenu, "back", menu_get_back, 0);
|
4991
5127
|
rb_define_method(cMenu, "set_opts", menu_set_opts, 1);
|
4992
5128
|
rb_define_method(cMenu, "opts_on", menu_opts_on_m, 1);
|
4993
5129
|
rb_define_method(cMenu, "opts_off", menu_opts_off_m, 1);
|
data/sample/addch.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# require_relative "../lib/curses"
|
3
|
+
require 'curses'
|
4
|
+
|
5
|
+
include Curses
|
6
|
+
|
7
|
+
init_screen
|
8
|
+
begin
|
9
|
+
addstr("The following letter A should be BOLD and UNDERLINED by using addch:\n")
|
10
|
+
addch('A'.ord | A_BOLD | A_UNDERLINE)
|
11
|
+
|
12
|
+
addstr("\nIt should look the same as when using attron and addstr:\n")
|
13
|
+
attron(A_BOLD | A_UNDERLINE)
|
14
|
+
addstr("A")
|
15
|
+
getch
|
16
|
+
|
17
|
+
ensure
|
18
|
+
close_screen
|
19
|
+
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.4
|
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:
|
12
|
+
date: 2022-02-02 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
|
@@ -328,14 +332,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
328
332
|
requirements:
|
329
333
|
- - ">="
|
330
334
|
- !ruby/object:Gem::Version
|
331
|
-
version: 2.
|
335
|
+
version: 2.6.0
|
332
336
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
333
337
|
requirements:
|
334
338
|
- - ">="
|
335
339
|
- !ruby/object:Gem::Version
|
336
340
|
version: '0'
|
337
341
|
requirements: []
|
338
|
-
rubygems_version: 3.
|
342
|
+
rubygems_version: 3.4.0.dev
|
339
343
|
signing_key:
|
340
344
|
specification_version: 4
|
341
345
|
summary: A Ruby binding for curses, ncurses, and PDCurses. curses is an extension
|