(defn string-ref-content [str-ref]
(let [positions (atom [])]
(proxy [AbstractDocument$Content] []
(createPosition [offset]
(let [p (atom offset)]
(swap! positions conj p)
(proxy [Position] []
(getOffset [] @p))))
(getChars [where len txt]
(let [s (max 0 (min where len))
e (max 0 (min where len (.length @str-ref)))]
(println "A:" @str-ref where len)
(set! (. txt array) (into-array Character/TYPE (seq (subs @str-ref s e))))
(println "B")
(prn (seq (. txt array)))))
(getString [where len]
(let [s (max 0 (min where len))
e (max 0 (min where len (.length @str-ref)))]
(subs @str-ref s e)))
(length []
(.length @str-ref))
(insertString [where str]
(swap! positions update-positions where (.length str))
(dosync
(alter str-ref str-insert where str))
nil)
(remove [where nitems]
(swap! positions update-positions where (- 0 nitems))
(dosync
(alter str-ref str-remove where nitems))
nil))))
Used in 0 other vars
Comments top
No comments for string-ref-content. Log in to add a comment.