-
Notifications
You must be signed in to change notification settings - Fork 3
/
editor.clj
76 lines (68 loc) · 2.27 KB
/
editor.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
(ns editor
(:import
[Clode.Extensions BraceFoldingStrategy]
[ICSharpCode.AvalonEdit.Folding FoldingManager]
[AvalonDock.Layout LayoutDocument]
[ICSharpCode.AvalonEdit TextEditor]
[Clode.Extensions ImageElementGenerator]
[System.IO Path]
[System.Windows.Media FontFamily]
)
(:require
[theming]
[bracefolding]
))
(defn init [& args]
(prn "editor init"))
(defn set-folding [editor]
(let [foldingManager (FoldingManager/Install (.TextArea editor))
foldingStrategy (BraceFoldingStrategy.)
; not ready yet
; foldingStrategy (bracefolding/create \( \) )
]
(. foldingStrategy UpdateFoldings foldingManager (. editor Document))))
(defn open-file [filename]
(let [win (wpf/get-app-main-window)
dockingManager (.FindName win "dockingManager")
docs (.FindName win "documentPane")
doc (LayoutDocument.)
editor (TextEditor.)
filename-without(Path/GetFileNameWithoutExtension filename)
component-name (str "editor_" filename-without)]
(doto editor
(theming/highlight-by-extension (Path/GetExtension filename))
(.Load filename)
(.set_Name component-name)
(.set_FontFamily (FontFamily. "Consolas"))
(.set_FontSize 17)
)
(set-folding editor)
(.RegisterName dockingManager component-name editor)
(doto doc
(.set_Content editor)
(.set_Title filename))
; (theming/highlight editor)
(-> docs .Children (.Add doc))))
(defn create-file [filename]
(let [win (wpf/get-app-main-window)
dockingManager (.FindName win "dockingManager")
docs (.FindName win "documentPane")
doc (LayoutDocument.)
editor (TextEditor.)
filename-without(Path/GetFileNameWithoutExtension filename)
component-name (str "editor_" filename-without)]
(doto editor
(.set_Name component-name)
(theming/highlight-by-extension (Path/GetExtension filename))
(.set_FontFamily (FontFamily. "Consolas"))
(.set_FontSize 17)
)
(set-folding editor)
(.RegisterName dockingManager component-name editor)
(doto doc
(.set_Content editor)
(.set_Title filename))
; (theming/highlight editor)
(-> docs .Children (.Add doc))
editor))
(prn "editor loaded")