textbringer 24 → 25
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/exe/txtb +1 -0
- data/lib/textbringer/buffer.rb +19 -11
- data/lib/textbringer/commands/misc.rb +19 -0
- data/lib/textbringer/commands/windows.rb +14 -0
- data/lib/textbringer/config.rb +2 -1
- data/lib/textbringer/face.rb +71 -15
- data/lib/textbringer/gamegrid.rb +2 -6
- data/lib/textbringer/highlight_context.rb +21 -0
- data/lib/textbringer/mode.rb +25 -0
- data/lib/textbringer/modes/gamegrid_mode.rb +6 -1
- data/lib/textbringer/modes/ruby_mode.rb +298 -181
- data/lib/textbringer/theme.rb +180 -0
- data/lib/textbringer/themes/catppuccin.rb +105 -0
- data/lib/textbringer/themes/github.rb +89 -0
- data/lib/textbringer/themes/gruvbox.rb +84 -0
- data/lib/textbringer/themes/molokai.rb +67 -0
- data/lib/textbringer/themes/sonokai.rb +63 -0
- data/lib/textbringer/themes/tokyonight.rb +70 -0
- data/lib/textbringer/version.rb +1 -1
- data/lib/textbringer/window.rb +28 -41
- data/lib/textbringer.rb +2 -0
- data/textbringer.gemspec +1 -0
- metadata +23 -5
- data/lib/textbringer/faces/basic.rb +0 -8
- data/lib/textbringer/faces/completion.rb +0 -4
- data/lib/textbringer/faces/dired.rb +0 -6
- data/lib/textbringer/faces/programming.rb +0 -6
data/lib/textbringer/window.rb
CHANGED
|
@@ -33,6 +33,8 @@ module Textbringer
|
|
|
33
33
|
@@minibuffer_selected = nil
|
|
34
34
|
@@echo_area = nil
|
|
35
35
|
@@has_colors = false
|
|
36
|
+
@@default_fg = "default"
|
|
37
|
+
@@default_bg = "default"
|
|
36
38
|
|
|
37
39
|
def self.list(include_echo_area: false)
|
|
38
40
|
if include_echo_area
|
|
@@ -133,15 +135,16 @@ module Textbringer
|
|
|
133
135
|
end
|
|
134
136
|
|
|
135
137
|
def self.set_default_colors(fg, bg)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
new_fg = fg || @@default_fg
|
|
139
|
+
new_bg = bg || @@default_bg
|
|
140
|
+
Curses.assume_default_colors(Color[new_fg], Color[new_bg])
|
|
141
|
+
@@default_fg = new_fg
|
|
142
|
+
@@default_bg = new_bg
|
|
143
|
+
Face.define(:default, foreground: new_fg, background: new_bg)
|
|
144
|
+
Window.redraw if @@started
|
|
138
145
|
end
|
|
139
146
|
|
|
140
147
|
def self.load_faces
|
|
141
|
-
require_relative "faces/basic"
|
|
142
|
-
require_relative "faces/programming"
|
|
143
|
-
require_relative "faces/completion"
|
|
144
|
-
require_relative "faces/dired"
|
|
145
148
|
require_relative "faces/gamegrid"
|
|
146
149
|
end
|
|
147
150
|
|
|
@@ -149,6 +152,7 @@ module Textbringer
|
|
|
149
152
|
if @@started
|
|
150
153
|
raise EditorError, "Already started"
|
|
151
154
|
end
|
|
155
|
+
Theme.detect_background
|
|
152
156
|
Curses.init_screen
|
|
153
157
|
Curses.noecho
|
|
154
158
|
Curses.raw
|
|
@@ -404,39 +408,18 @@ module Textbringer
|
|
|
404
408
|
def highlight
|
|
405
409
|
@highlight_on = {}
|
|
406
410
|
@highlight_off = {}
|
|
407
|
-
if (override = @buffer[:highlight_override])
|
|
408
|
-
@highlight_on, @highlight_off = override.call
|
|
409
|
-
return
|
|
410
|
-
end
|
|
411
411
|
return if !@@has_colors || !CONFIG[:syntax_highlight] || @buffer.binary?
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
"(?<#{name}>#{re})"
|
|
424
|
-
}.join("|")
|
|
425
|
-
re = Regexp.new(re_str)
|
|
426
|
-
names = syntax_table.keys
|
|
427
|
-
s.scan(re) do
|
|
428
|
-
b = base_pos + $`.bytesize
|
|
429
|
-
e = b + $&.bytesize
|
|
430
|
-
if b < @buffer.point && @buffer.point < e
|
|
431
|
-
b = @buffer.point
|
|
432
|
-
end
|
|
433
|
-
name = names.find { |n| $~[n] }
|
|
434
|
-
face = Face[name]
|
|
435
|
-
if face
|
|
436
|
-
@highlight_on[b] = face
|
|
437
|
-
@highlight_off[e] = true
|
|
438
|
-
end
|
|
439
|
-
end
|
|
412
|
+
ctx = HighlightContext.new(
|
|
413
|
+
buffer: @buffer,
|
|
414
|
+
highlight_start: @buffer.point,
|
|
415
|
+
# Use * 4 (max UTF-8 bytes per character) to ensure multi-byte
|
|
416
|
+
# characters near the bottom of the window are fully covered.
|
|
417
|
+
highlight_end: [@buffer.point + columns * (lines - 1) * 4,
|
|
418
|
+
@buffer.point_max].min,
|
|
419
|
+
highlight_on: @highlight_on,
|
|
420
|
+
highlight_off: @highlight_off
|
|
421
|
+
)
|
|
422
|
+
@buffer.mode.highlight(ctx)
|
|
440
423
|
end
|
|
441
424
|
|
|
442
425
|
def redisplay
|
|
@@ -732,7 +715,8 @@ module Textbringer
|
|
|
732
715
|
@mode_line.addstr(" #{line},#{column}")
|
|
733
716
|
@mode_line.addstr(" (#{@buffer.mode_names.join(' ')})")
|
|
734
717
|
@mode_line.addstr(" " * (columns - @mode_line.curx))
|
|
735
|
-
|
|
718
|
+
default = Face[:default]
|
|
719
|
+
@mode_line.attr_set(default&.text_attrs || 0, default&.color_pair || 0)
|
|
736
720
|
@mode_line.noutrefresh
|
|
737
721
|
end
|
|
738
722
|
|
|
@@ -972,6 +956,7 @@ module Textbringer
|
|
|
972
956
|
end
|
|
973
957
|
|
|
974
958
|
def apply_face_attrs(win, face)
|
|
959
|
+
face ||= Face[:default]
|
|
975
960
|
win.attr_set(face&.text_attrs || 0, face&.color_pair || 0)
|
|
976
961
|
end
|
|
977
962
|
|
|
@@ -991,7 +976,8 @@ module Textbringer
|
|
|
991
976
|
end
|
|
992
977
|
win.attr_set(text_attrs, face.color_pair)
|
|
993
978
|
else
|
|
994
|
-
|
|
979
|
+
default = Face[:default]
|
|
980
|
+
win.attr_set(default&.text_attrs || 0, default&.color_pair || 0)
|
|
995
981
|
end
|
|
996
982
|
end
|
|
997
983
|
end
|
|
@@ -1040,7 +1026,8 @@ module Textbringer
|
|
|
1040
1026
|
@window.addstr(@buffer.input_method_status)
|
|
1041
1027
|
end
|
|
1042
1028
|
@window.setpos(0, 0)
|
|
1043
|
-
|
|
1029
|
+
default = Face[:default]
|
|
1030
|
+
@window.attr_set(default&.text_attrs || 0, default&.color_pair || 0)
|
|
1044
1031
|
@in_region = false
|
|
1045
1032
|
@in_isearch = false
|
|
1046
1033
|
@current_hl_face = nil
|
data/lib/textbringer.rb
CHANGED
|
@@ -9,6 +9,8 @@ require_relative "textbringer/keymap"
|
|
|
9
9
|
require_relative "textbringer/utils"
|
|
10
10
|
require_relative "textbringer/color"
|
|
11
11
|
require_relative "textbringer/face"
|
|
12
|
+
require_relative "textbringer/highlight_context"
|
|
13
|
+
require_relative "textbringer/theme"
|
|
12
14
|
require_relative "textbringer/completion_popup"
|
|
13
15
|
require_relative "textbringer/lsp/client"
|
|
14
16
|
require_relative "textbringer/lsp/server_registry"
|
data/textbringer.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: textbringer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '
|
|
4
|
+
version: '25'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shugo Maeda
|
|
@@ -9,6 +9,20 @@ bindir: exe
|
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: prism
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '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'
|
|
12
26
|
- !ruby/object:Gem::Dependency
|
|
13
27
|
name: rdoc
|
|
14
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -387,14 +401,11 @@ files:
|
|
|
387
401
|
- lib/textbringer/default_output.rb
|
|
388
402
|
- lib/textbringer/errors.rb
|
|
389
403
|
- lib/textbringer/face.rb
|
|
390
|
-
- lib/textbringer/faces/basic.rb
|
|
391
|
-
- lib/textbringer/faces/completion.rb
|
|
392
|
-
- lib/textbringer/faces/dired.rb
|
|
393
404
|
- lib/textbringer/faces/gamegrid.rb
|
|
394
|
-
- lib/textbringer/faces/programming.rb
|
|
395
405
|
- lib/textbringer/floating_window.rb
|
|
396
406
|
- lib/textbringer/gamegrid.rb
|
|
397
407
|
- lib/textbringer/global_minor_mode.rb
|
|
408
|
+
- lib/textbringer/highlight_context.rb
|
|
398
409
|
- lib/textbringer/input_method.rb
|
|
399
410
|
- lib/textbringer/input_methods/hangul_input_method.rb
|
|
400
411
|
- lib/textbringer/input_methods/hiragana_input_method.rb
|
|
@@ -421,6 +432,13 @@ files:
|
|
|
421
432
|
- lib/textbringer/modes/transient_mark_mode.rb
|
|
422
433
|
- lib/textbringer/plugin.rb
|
|
423
434
|
- lib/textbringer/ring.rb
|
|
435
|
+
- lib/textbringer/theme.rb
|
|
436
|
+
- lib/textbringer/themes/catppuccin.rb
|
|
437
|
+
- lib/textbringer/themes/github.rb
|
|
438
|
+
- lib/textbringer/themes/gruvbox.rb
|
|
439
|
+
- lib/textbringer/themes/molokai.rb
|
|
440
|
+
- lib/textbringer/themes/sonokai.rb
|
|
441
|
+
- lib/textbringer/themes/tokyonight.rb
|
|
424
442
|
- lib/textbringer/utils.rb
|
|
425
443
|
- lib/textbringer/version.rb
|
|
426
444
|
- lib/textbringer/window.rb
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
module Textbringer
|
|
2
|
-
Face.define :mode_line, reverse: true
|
|
3
|
-
Face.define :link, foreground: "blue", bold: true
|
|
4
|
-
Face.define :control
|
|
5
|
-
Face.define :region, background: "blue", foreground: "white"
|
|
6
|
-
Face.define :isearch, background: "yellow", foreground: "black"
|
|
7
|
-
Face.define :floating_window, background: "cyan", foreground: "black"
|
|
8
|
-
end
|