-
Notifications
You must be signed in to change notification settings - Fork 3
/
avalonedit.clj
30 lines (23 loc) · 1.01 KB
/
avalonedit.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
(ns avalonedit
(:import
[ICSharpCode.Scripting CommandLineHistory]
[ICSharpCode.SharpDevelop.Gui BeginReadOnlySectionProvider]
[System.Windows.Input KeyEventHandler Key Keyboard])
(:require
[clojure.tools.logging :as log]))
(defn get-entered-text [edit]
(let [offset (-> edit .TextArea .ReadOnlySectionProvider .EndOffset)
length (-> edit .Document .TextLength)]
(-> edit .Document (.GetText offset (- length offset)))))
(defn set-entered-readonly [edit]
(set! (-> edit .TextArea .ReadOnlySectionProvider .EndOffset) (-> edit .Document .TextLength)))
(defn set-current-text! [edit text]
(let [offset (-> edit .TextArea .ReadOnlySectionProvider .EndOffset)
end (-> edit .Document .TextLength)
lenght (- end offset)]
(-> edit .Document (.Replace offset lenght text))))
(defn scroll-to-end [edit]
(.ScrollToEnd edit))
(defn set-caret-to-readonly-offset [edit]
(let [offset (-> edit .TextArea .ReadOnlySectionProvider .EndOffset)]
(.set_CaretOffset edit offset)))