1
1
module GtkMarkdownTextView
2
2
3
- using Gtk
4
- import Gtk. GtkTextIter
3
+ using Gtk4
4
+ import Gtk4: _GtkTextIter, create_tag, apply_tag
5
+ import Gtk4. GLib: gobject_move_ref, GObject
5
6
6
7
using Markdown
7
8
@@ -18,15 +19,14 @@ module GtkMarkdownTextView
18
19
MarkdownColors () = MarkdownColors (13 , " #000" , " #fff" , " #111" , " #eee" )
19
20
20
21
mutable struct MarkdownTextView <: GtkTextView
21
-
22
- handle:: Ptr{Gtk.GObject}
22
+ handle:: Ptr{GObject}
23
23
view:: GtkTextView
24
24
buffer:: GtkTextBuffer
25
25
26
26
function MarkdownTextView (m:: Markdown.MD , prelude:: String , mc:: MarkdownColors = MarkdownColors ())
27
27
28
28
buffer = GtkTextBuffer ()
29
- buffer. text[String] = prelude
29
+ buffer. text = prelude
30
30
view = GtkTextView (buffer)
31
31
32
32
style_css (view,
@@ -39,28 +39,28 @@ module GtkMarkdownTextView
39
39
)
40
40
41
41
# set_gtk_property!(view, :margin_left, 1)
42
- view. monospace[Bool] = true
43
- view. wrap_mode[Bool] = true
42
+ view. monospace = true
43
+ view. wrap_mode = true
44
44
45
45
fs = mc. font_size
46
46
47
- Gtk . create_tag (buffer, " normal" , font = " $fs " )
48
- Gtk . create_tag (buffer, " h1" , font = " bold $(fs+ 3 ) " )
49
- Gtk . create_tag (buffer, " h2" , font = " bold $(fs+ 2 ) " )
50
- Gtk . create_tag (buffer, " h3" , font = " bold $(fs+ 1 ) " )
51
- Gtk . create_tag (buffer, " h4" , font = " bold $(fs) " )
52
- Gtk . create_tag (buffer, " h5" , font = " $(fs) " )
53
- Gtk . create_tag (buffer, " h6" , font = " $(fs- 1 ) " )
54
- Gtk . create_tag (buffer, " bold" , font = " bold $(fs) " )
55
- Gtk . create_tag (buffer, " italic" , font = " italic $fs " )
56
- Gtk . create_tag (buffer, " code" , font = " bold $fs " ,
47
+ create_tag (buffer, " normal" , font = " $fs " )
48
+ create_tag (buffer, " h1" , font = " bold $(fs+ 3 ) " )
49
+ create_tag (buffer, " h2" , font = " bold $(fs+ 2 ) " )
50
+ create_tag (buffer, " h3" , font = " bold $(fs+ 1 ) " )
51
+ create_tag (buffer, " h4" , font = " bold $(fs) " )
52
+ create_tag (buffer, " h5" , font = " $(fs) " )
53
+ create_tag (buffer, " h6" , font = " $(fs- 1 ) " )
54
+ create_tag (buffer, " bold" , font = " bold $(fs) " )
55
+ create_tag (buffer, " italic" , font = " italic $fs " )
56
+ create_tag (buffer, " code" , font = " bold $fs " ,
57
57
foreground= mc. highlight_color, background= mc. highlight_background)
58
58
59
59
insert_MD! (buffer, m)
60
60
# tag(buffer, "normal", 1, length(buffer))
61
61
62
62
n = new (view. handle, view, buffer)
63
- Gtk . gobject_move_ref (n, view)
63
+ gobject_move_ref (n, view)
64
64
end
65
65
66
66
MarkdownTextView (m:: String ) = MarkdownTextView (Markdown. parse (m), " " )
@@ -70,14 +70,14 @@ module GtkMarkdownTextView
70
70
end
71
71
72
72
function tag (buffer, what, i, j)
73
- Gtk . apply_tag (buffer, what,
74
- GtkTextIter (buffer, i), GtkTextIter (buffer, j)
73
+ apply_tag (buffer, what,
74
+ _GtkTextIter (buffer, i), _GtkTextIter (buffer, j)
75
75
)
76
76
end
77
77
78
- function style_css (w:: Gtk. GtkWidget , css:: String )
79
- sc = Gtk . G_ . style_context (w)
80
- push! (sc, GtkCssProvider (data = css), 600 )
78
+ function style_css (w:: GtkWidget , css:: String )
79
+ sc = Gtk4 . style_context (w)
80
+ push! (sc, GtkCssProvider (css), 600 )
81
81
end
82
82
83
83
function insert_MD! (buffer, m:: Markdown.Header{N} , i) where N
@@ -177,4 +177,4 @@ module GtkMarkdownTextView
177
177
178
178
179
179
end
180
-
180
+
0 commit comments