rcurses 2.0 → 2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +24 -0
- data/{rcurses_example.rb → examples/basic_panes.rb} +1 -1
- data/lib/rcurses/cursor.rb +79 -0
- data/lib/rcurses/input.rb +83 -0
- data/lib/rcurses/pane.rb +494 -0
- data/lib/rcurses.rb +5 -699
- data/lib/string_extensions.rb +34 -0
- metadata +11 -8
- data/extconf.rb +0 -33
@@ -0,0 +1,34 @@
|
|
1
|
+
class String
|
2
|
+
# Add coloring to strings (with escaping for Readline)
|
3
|
+
def fg(fg) ; color(self, "\e[38;5;#{fg}m", "\e[0m") ; end
|
4
|
+
def bg(bg) ; color(self, "\e[48;5;#{bg}m", "\e[0m") ; end
|
5
|
+
def fb(fg, bg); color(self, "\e[38;5;#{fg};48;5;#{bg}m"); end
|
6
|
+
def b ; color(self, "\e[1m", "\e[22m") ; end
|
7
|
+
def i ; color(self, "\e[3m", "\e[23m") ; end
|
8
|
+
def u ; color(self, "\e[4m", "\e[24m") ; end
|
9
|
+
def l ; color(self, "\e[5m", "\e[25m") ; end
|
10
|
+
def r ; color(self, "\e[7m", "\e[27m") ; end
|
11
|
+
# Internal function
|
12
|
+
def color(text, sp, ep = "\e[0m"); "#{sp}#{text}#{ep}"; end
|
13
|
+
|
14
|
+
# Use format "TEST".c("204,45,bui") to print "TEST" in bold, underline italic, fg=204 and bg=45
|
15
|
+
def c(code)
|
16
|
+
prop = "\e["
|
17
|
+
prop += "38;5;#{code.match(/^\d+/).to_s};" if code.match(/^\d+/)
|
18
|
+
prop += "48;5;#{code.match(/(?<=,)\d+/).to_s};" if code.match(/(?<=,)\d+/)
|
19
|
+
prop += "1;" if code.include?('b')
|
20
|
+
prop += "3;" if code.include?('i')
|
21
|
+
prop += "4;" if code.include?('u')
|
22
|
+
prop += "5;" if code.include?('l')
|
23
|
+
prop += "7;" if code.include?('r')
|
24
|
+
prop.chop! if prop[-1] == ";"
|
25
|
+
prop += "m"
|
26
|
+
prop += self
|
27
|
+
prop += "\e[0m"
|
28
|
+
prop
|
29
|
+
end
|
30
|
+
|
31
|
+
def pure
|
32
|
+
self.gsub(/\e\[\d+(?:;\d+)*m/, '')
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rcurses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '2.
|
4
|
+
version: '2.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geir Isene
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clipboard
|
@@ -28,18 +28,21 @@ description: 'Create panes (with the colors and(or border), manipulate the panes
|
|
28
28
|
add content. Dress up text (in panes or anywhere in the terminal) in bold, italic,
|
29
29
|
underline, reverse color, blink and in any 256 terminal colors for foreground and
|
30
30
|
background. Use a simple editor to let users edit text in panes. Left, right or
|
31
|
-
center align text in panes. Cursor movement around the terminal. New in 2.
|
32
|
-
|
31
|
+
center align text in panes. Cursor movement around the terminal. New in 2.1: New
|
32
|
+
gem structure.'
|
33
33
|
email: g@isene.com
|
34
34
|
executables: []
|
35
|
-
extensions:
|
36
|
-
- extconf.rb
|
35
|
+
extensions: []
|
37
36
|
extra_rdoc_files: []
|
38
37
|
files:
|
38
|
+
- LICENSE
|
39
39
|
- README.md
|
40
|
-
-
|
40
|
+
- examples/basic_panes.rb
|
41
41
|
- lib/rcurses.rb
|
42
|
-
-
|
42
|
+
- lib/rcurses/cursor.rb
|
43
|
+
- lib/rcurses/input.rb
|
44
|
+
- lib/rcurses/pane.rb
|
45
|
+
- lib/string_extensions.rb
|
43
46
|
homepage: https://isene.com/
|
44
47
|
licenses:
|
45
48
|
- Unlicense
|
data/extconf.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
# Define the source file and the target directory
|
4
|
-
source_file = File.join(File.dirname(__FILE__), 'lib/rcurses.rb')
|
5
|
-
target_dir = '/usr/lib/ruby/vendor_ruby'
|
6
|
-
|
7
|
-
# Check if we have write permission to the target directory
|
8
|
-
unless File.writable?(target_dir)
|
9
|
-
abort("You need root permissions to install to #{target_dir}. Please run as root or use sudo.")
|
10
|
-
end
|
11
|
-
|
12
|
-
# Create the target directory if it doesn't exist
|
13
|
-
FileUtils.mkdir_p(target_dir)
|
14
|
-
|
15
|
-
# Copy the file
|
16
|
-
FileUtils.cp(source_file, target_dir)
|
17
|
-
|
18
|
-
puts "Installed #{source_file} to #{target_dir}"
|
19
|
-
|
20
|
-
# Create a dummy Makefile to satisfy Ruby's gem installation process
|
21
|
-
File.open('Makefile', 'w') do |f|
|
22
|
-
f.puts <<-MAKEFILE
|
23
|
-
all:
|
24
|
-
\t@echo "Nothing to build"
|
25
|
-
|
26
|
-
clean:
|
27
|
-
\t@echo "Nothing to clean"
|
28
|
-
|
29
|
-
install:
|
30
|
-
\t@echo "Installation handled by extconf.rb"
|
31
|
-
MAKEFILE
|
32
|
-
end
|
33
|
-
|