irb-theme-rk2025 0.1.0
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 +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +36 -0
- data/Rakefile +4 -0
- data/lib/irb/theme/rk2025.rb +175 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ce4447e376bb7ab8a4227ec50220cd19696d6ff10d148ac5c9a221a13a2c7d72
|
4
|
+
data.tar.gz: f596661156701fcd665d0e35f6d19f77cf016f810b462dc1f1d93d94bcc24d90
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 85044d05d327adc8192953816011b09bf1e77aa6d5cddc241c4fa8c26e920909fcae0b301e3efb6470d7dd9bed30a7d7378bc04d5bc58654a39a2c727e2ff049
|
7
|
+
data.tar.gz: 820e455b357ed85c540ac0df0cff8a180476841a24aeabea2e9a1a80840c90abf89aafa89604bb32697638938ebbb1aa675da9268e66a7c6139e8381ac55fd48
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2025 tompng
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# IRB Theme RK2025
|
2
|
+
|
3
|
+
IRB Theme with 2025 mikan orange
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
`gem install irb-theme-rk2025`
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Write the code below to `~/.irbrc`
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
require 'irb/theme/rk2025'
|
15
|
+
```
|
16
|
+
|
17
|
+
Or write this if you want to use from a project using bundler
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
# To see the installed path: `gem which irb/theme/rk2025`
|
21
|
+
require '/full/path/to/installed/irb-theme-rk2025-x.y.z/lib/irb/theme/rk2025.rb'
|
22
|
+
```
|
23
|
+
|
24
|
+
## Development
|
25
|
+
|
26
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
27
|
+
|
28
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/irb-theme-rk2025.
|
33
|
+
|
34
|
+
## License
|
35
|
+
|
36
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
require 'reline'
|
2
|
+
module IRB2025Mikan
|
3
|
+
class Canvas
|
4
|
+
CHARS = ' ▘▝▀▖▌▞▛▗▚▐▜▄▙▟█'
|
5
|
+
attr_reader :w, :h, :masks, :colors
|
6
|
+
attr_accessor :lines, :focus_line
|
7
|
+
def initialize(w, h)
|
8
|
+
@w = w
|
9
|
+
@h = h
|
10
|
+
clear
|
11
|
+
# TODO: delete this
|
12
|
+
@lines = (@h/2).times.map do
|
13
|
+
rand(2..40).times.map{rand(33..126).chr}.join
|
14
|
+
end
|
15
|
+
@focus_line = rand(@lines.size)
|
16
|
+
end
|
17
|
+
|
18
|
+
def clear
|
19
|
+
@masks = @h.times.map{[]}
|
20
|
+
@colors = @h.times.map{[]}
|
21
|
+
end
|
22
|
+
|
23
|
+
def render_to_lines
|
24
|
+
output_lines = []
|
25
|
+
@h.times do |y|
|
26
|
+
color = nil
|
27
|
+
default_background = 16+36*5+6*5+4
|
28
|
+
text_color = 16+36*0+6*2+0
|
29
|
+
line = @lines[y]
|
30
|
+
if y == @focus_line
|
31
|
+
default_background = 16+36*5+6*5+3
|
32
|
+
line = line.sub(' ', '🍊')
|
33
|
+
text_color = "#{16+36*0+6*1+0};1"
|
34
|
+
end
|
35
|
+
output = +''
|
36
|
+
background = color = nil
|
37
|
+
x = 0
|
38
|
+
while x < @w do
|
39
|
+
m = @masks[y][x] || 0
|
40
|
+
t = line&.[](x)
|
41
|
+
t = nil if t == ' '
|
42
|
+
if t
|
43
|
+
w = Reline::Unicode.get_mbchar_width(t)
|
44
|
+
line = "\0" + line if w == 2
|
45
|
+
tlen = w
|
46
|
+
end
|
47
|
+
c = @colors[y][x]
|
48
|
+
bg = default_background
|
49
|
+
if t && x + tlen <= @w
|
50
|
+
bg = m == 0 ? default_background : c || default_background
|
51
|
+
c = text_color
|
52
|
+
x += tlen
|
53
|
+
else
|
54
|
+
x += 1
|
55
|
+
end
|
56
|
+
if color != c
|
57
|
+
output << "\e[38;5;#{color = c}m"
|
58
|
+
end
|
59
|
+
if background != bg
|
60
|
+
output << "\e[48;5;#{background = bg}m"
|
61
|
+
end
|
62
|
+
output << (t || CHARS[m])
|
63
|
+
end
|
64
|
+
output << "\e[m"
|
65
|
+
output_lines << output
|
66
|
+
end
|
67
|
+
output_lines
|
68
|
+
end
|
69
|
+
|
70
|
+
def draw(cx, cy, r, color)
|
71
|
+
offset = 2
|
72
|
+
plot = ->x, y, v, color {
|
73
|
+
val = @masks[y/2][x/2] || 0
|
74
|
+
bit = 1 << (y % 2 * 2 + x % 2)
|
75
|
+
@masks[y/2][x/2] = (val & ~bit) | (v * bit)
|
76
|
+
@colors[y/2][x/2] = color if color
|
77
|
+
}
|
78
|
+
xrange = ([2 * (cx - r - offset), 0].max.ceil..[2 * (cx + r + offset), 2 * @w - 1].min)
|
79
|
+
yrange = ([2 * cy - r - offset, 0].max.ceil..[2 * cy + r + offset, 2 * @h - 1].min)
|
80
|
+
yrange.each do |iy|
|
81
|
+
xrange.each do |ix|
|
82
|
+
x = ix - 2 * cx
|
83
|
+
y = (iy - 2 * cy) * 2.0
|
84
|
+
r2 = x ** 2 + y ** 2
|
85
|
+
next if r2 > 4 * (r + offset)**2
|
86
|
+
if r2 > 4 * (r + 0.5) ** 2
|
87
|
+
plot[ix, iy, 0, nil]
|
88
|
+
else
|
89
|
+
plot[ix, iy, yield(x / 2.0 / r, y / 2.0 / r) ? 1 : 0, color]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
prev_color = nil
|
97
|
+
PARAMS = 100.times.map do |i|
|
98
|
+
bi = rand(0.02..0.05)
|
99
|
+
bo = rand(0.05..0.1)
|
100
|
+
bm = bo * rand(1.0..2.0)
|
101
|
+
color = prev_color
|
102
|
+
color = 16+36*5+6*rand(3..5)+rand(1..2) while color == prev_color
|
103
|
+
prev_color = color
|
104
|
+
{
|
105
|
+
cx: rand,
|
106
|
+
cy: 15 * i + rand(10),
|
107
|
+
segments: rand(7..9),
|
108
|
+
theta: 2 * Math::PI * rand,
|
109
|
+
rot: (0.2 + 0.4 * rand) * (rand > 0.5 ? 1 : -1),
|
110
|
+
bi:, bm:, bo:,
|
111
|
+
radius: rand(12..24),
|
112
|
+
color:
|
113
|
+
}
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.start
|
117
|
+
Reline::LineEditor.prepend Module.new {
|
118
|
+
def colorize_completion_dialog
|
119
|
+
dialog = @dialogs[0]
|
120
|
+
return unless dialog&.contents
|
121
|
+
|
122
|
+
canvas = Canvas.new(dialog.width, dialog.contents.size)
|
123
|
+
y = dialog.scroll_top
|
124
|
+
face = Reline::Face[:completion_dialog]
|
125
|
+
time = Time.now.to_f
|
126
|
+
original_contents = dialog.contents.instance_eval { @original ||= dup }
|
127
|
+
canvas.focus_line = original_contents.find_index { |line| line.include?(face[:enhanced]) }
|
128
|
+
uncolored_lines = original_contents.map do |line|
|
129
|
+
line.gsub(/\e\[[\d;]*m/, '')
|
130
|
+
end
|
131
|
+
canvas.lines = uncolored_lines
|
132
|
+
t = Time.now.to_f
|
133
|
+
PARAMS.each do |param|
|
134
|
+
param in { cx:, cy:, segments:, theta:, rot:, bo:, bi:, bm:, radius:, color: }
|
135
|
+
cy = (cy - dialog.scroll_top) % 1500 - 100
|
136
|
+
theta += t * rot
|
137
|
+
canvas.draw(5 + (canvas.w - 5)*cx, cy, radius+0.5, color){|x,y|
|
138
|
+
z = x+y.i
|
139
|
+
a = z.arg
|
140
|
+
a2 = ((a-theta)/2/Math::PI*segments).round*2*Math::PI/segments+theta
|
141
|
+
(z*Complex.polar(1, -a2)).imag.abs > bi + 10**(10*(z.abs2 - 1 + bo + bm)) || (z.abs<1&&z.abs>1-bo)
|
142
|
+
}
|
143
|
+
end
|
144
|
+
|
145
|
+
dialog.contents[0..] = canvas.render_to_lines
|
146
|
+
end
|
147
|
+
|
148
|
+
def update_dialogs(...)
|
149
|
+
@_updating_dialogs = true
|
150
|
+
super(...)
|
151
|
+
colorize_completion_dialog
|
152
|
+
ensure
|
153
|
+
@_updating_dialogs = false
|
154
|
+
end
|
155
|
+
|
156
|
+
def _updating_dialogs?
|
157
|
+
@_updating_dialogs
|
158
|
+
end
|
159
|
+
|
160
|
+
def rerender
|
161
|
+
(@mutex ||= Mutex.new).synchronize { super }
|
162
|
+
end
|
163
|
+
}
|
164
|
+
Thread.new do
|
165
|
+
Reline.line_editor.instance_eval do
|
166
|
+
loop do
|
167
|
+
sleep 0.1
|
168
|
+
colorize_completion_dialog && rerender unless _updating_dialogs?
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
IRB2025Mikan.start
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: irb-theme-rk2025
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tompng
|
8
|
+
bindir: exe
|
9
|
+
cert_chain: []
|
10
|
+
date: 2025-03-08 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: reline
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 0.5.0
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 0.5.0
|
26
|
+
description: IRB color theme for 2025
|
27
|
+
email:
|
28
|
+
- tomoyapenguin@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- LICENSE.txt
|
34
|
+
- README.md
|
35
|
+
- Rakefile
|
36
|
+
- lib/irb/theme/rk2025.rb
|
37
|
+
homepage: https://github.com/tompng/irb-theme-rk2025
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata:
|
41
|
+
homepage_uri: https://github.com/tompng/irb-theme-rk2025
|
42
|
+
source_code_uri: https://github.com/tompng/irb-theme-rk2025
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 3.0.0
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubygems_version: 3.6.3
|
58
|
+
specification_version: 4
|
59
|
+
summary: IRB color theme
|
60
|
+
test_files: []
|