jugyo-termtter 0.7.5 → 0.7.6
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.
- data/lib/plugin/group.rb +6 -0
- data/lib/plugin/sl.rb +29 -1
- data/lib/plugin/stdout.rb +41 -12
- data/lib/plugin/yhara.rb +19 -4
- data/lib/termtter.rb +2 -1
- metadata +1 -1
data/lib/plugin/group.rb
CHANGED
@@ -4,6 +4,12 @@ module Termtter::Client
|
|
4
4
|
if public_storage[:log]
|
5
5
|
add_help 'group,g GROUPNAME', 'Filter by group members'
|
6
6
|
|
7
|
+
add_command /^(?:group|g)\s*$/ do |m, t|
|
8
|
+
configatron.plugins.group.groups.each_pair do |key, value|
|
9
|
+
puts "#{key}: #{value.join(',')}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
7
13
|
add_command /^(?:group|g)\s+(.+)/ do |m, t|
|
8
14
|
group_name = m[1].to_sym
|
9
15
|
group = configatron.plugins.group.groups[group_name]
|
data/lib/plugin/sl.rb
CHANGED
@@ -1,3 +1,31 @@
|
|
1
1
|
module Termtter::Client
|
2
|
-
|
2
|
+
public_storage[:current] = ''
|
3
|
+
|
4
|
+
add_macro /^sl\s*$/, 'eval system "sl"'
|
5
|
+
|
6
|
+
add_help 'pwd', 'Show current direcroty'
|
7
|
+
add_macro /^pwd\s*$/, 'eval public_storage[:current]'
|
8
|
+
|
9
|
+
add_help 'ls', 'Show list in current directory'
|
10
|
+
add_command /^ls\s*$/ do |m, t|
|
11
|
+
call_commands "list #{public_storage[:current]}", t
|
12
|
+
end
|
13
|
+
|
14
|
+
add_help 'cd USER', 'Change current directory'
|
15
|
+
add_command /^cd\s+(.*)/ do |m, t|
|
16
|
+
directory = m[1].strip
|
17
|
+
direcroty = '' if /~/ =~ direcroty
|
18
|
+
public_storage[:current] = direcroty
|
19
|
+
puts "=> #{direcroty}"
|
20
|
+
end
|
21
|
+
add_macro /^cd$/, 'eval public_storage[:current] = ""'
|
22
|
+
|
23
|
+
add_completion do |input|
|
24
|
+
case input
|
25
|
+
when /^(cd)\s+(.*)/
|
26
|
+
find_user_candidates $2, "#{$1} %s"
|
27
|
+
else
|
28
|
+
%w[ sl ls cd pwd ].grep(/^#{Regexp.quote input}/)
|
29
|
+
end
|
30
|
+
end
|
3
31
|
end
|
data/lib/plugin/stdout.rb
CHANGED
@@ -12,20 +12,49 @@ $highline = HighLine.new
|
|
12
12
|
|
13
13
|
if win?
|
14
14
|
require 'kconv'
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
require 'Win32API'
|
16
|
+
STD_OUTPUT_HANDLE = 0xFFFFFFF5
|
17
|
+
$wSetConsoleTextAttribute = Win32API.new('kernel32','SetConsoleTextAttribute','II','I')
|
18
|
+
$wGetConsoleScreenBufferInfo = Win32API.new("kernel32", "GetConsoleScreenBufferInfo", ['l', 'p'], 'i')
|
19
|
+
$wGetStdHandle = Win32API.new('kernel32','GetStdHandle','I','I')
|
20
|
+
|
21
|
+
$hStdOut = $wGetStdHandle.call(STD_OUTPUT_HANDLE)
|
22
|
+
lpBuffer = ' ' * 22
|
23
|
+
$wGetConsoleScreenBufferInfo.call($hStdOut, lpBuffer)
|
24
|
+
$oldColor = lpBuffer.unpack('SSSSSssssSS')[4]
|
25
|
+
|
26
|
+
$colorMap = {
|
27
|
+
0 => 7, # black/white
|
28
|
+
37 => 8, # white/intensity
|
29
|
+
31 => 4 + 8, # red/red
|
30
|
+
32 => 2 + 8, # green/green
|
31
|
+
33 => 6 + 8, # yellow/yellow
|
32
|
+
34 => 1 + 8, # blue/blue
|
33
|
+
35 => 5 + 8, # magenta/purple
|
34
|
+
36 => 3 + 8, # cyan/aqua
|
35
|
+
90 => 7, # erase/white
|
36
|
+
}
|
18
37
|
def puts(str)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
"\e[#{value}m#{str}\e[0m"
|
38
|
+
str = str.tosjis
|
39
|
+
tokens = str.split(/(\e\[\d+m)/)
|
40
|
+
tokens.each do |token|
|
41
|
+
if token =~ /\e\[(\d+)m/
|
42
|
+
$wSetConsoleTextAttribute.call $hStdOut, $colorMap[$1.to_i].to_i
|
43
|
+
else
|
44
|
+
STDOUT.print token
|
45
|
+
end
|
28
46
|
end
|
47
|
+
$wSetConsoleTextAttribute.call $hStdOut, $oldColor
|
48
|
+
STDOUT.puts
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def color(str, value)
|
53
|
+
case value
|
54
|
+
when String, Symbol
|
55
|
+
$highline.color(str, value)
|
56
|
+
else
|
57
|
+
"\e[#{value}m#{str}\e[0m"
|
29
58
|
end
|
30
59
|
end
|
31
60
|
|
data/lib/plugin/yhara.rb
CHANGED
@@ -125,14 +125,29 @@ end
|
|
125
125
|
module Termtter::Client
|
126
126
|
|
127
127
|
add_help 'yhara', 'Post a new Yharian sentence'
|
128
|
+
add_help 'yhara USER', 'Speak to the user in Yharian'
|
128
129
|
|
129
|
-
add_command /^(yhara
|
130
|
+
add_command /^(yhara)\s*$/ do |m, t|
|
130
131
|
text = Yharian::text
|
131
|
-
|
132
|
-
|
133
|
-
|
132
|
+
t.update_status(text)
|
133
|
+
puts "=> #{text}"
|
134
|
+
end
|
135
|
+
|
136
|
+
add_command /^(yhara)\s+(\w+)/ do |m, t|
|
137
|
+
text = "@#{m[2]} #{Yharian::text}"
|
138
|
+
t.update_status(text)
|
139
|
+
puts "=> #{text}"
|
140
|
+
end
|
141
|
+
|
142
|
+
add_completion do |input|
|
143
|
+
case input
|
144
|
+
when /^(yhara)\s+(.*)/
|
145
|
+
find_user_candidates $2, "#{$1} %s"
|
146
|
+
else
|
147
|
+
%w[ yhara ].grep(/^#{Regexp.quote input}/)
|
134
148
|
end
|
135
149
|
end
|
150
|
+
|
136
151
|
end
|
137
152
|
|
138
153
|
# yhara.rb
|
data/lib/termtter.rb
CHANGED
@@ -74,7 +74,7 @@ unless defined? original_require
|
|
74
74
|
end
|
75
75
|
|
76
76
|
module Termtter
|
77
|
-
VERSION = '0.7.
|
77
|
+
VERSION = '0.7.6'
|
78
78
|
APP_NAME = 'termtter'
|
79
79
|
|
80
80
|
class Connection
|
@@ -425,6 +425,7 @@ module Termtter
|
|
425
425
|
puts e.backtrace.join("\n")
|
426
426
|
end
|
427
427
|
end
|
428
|
+
exit # exit when press Control-D
|
428
429
|
end
|
429
430
|
end
|
430
431
|
end
|