Skip to content

Commit

Permalink
Removing some reflections
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmonettas committed Oct 18, 2023
1 parent b3cd39f commit 3a9366c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
21 changes: 12 additions & 9 deletions src-dbg/flow_storm/debugger/ui/flows/code.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
[javafx.scene.layout Priority VBox HBox]
[javafx.scene.text Font]
[javafx.scene.input KeyCode MouseButton ScrollEvent]
[org.fxmisc.richtext.model StyleSpansBuilder]))
[org.fxmisc.richtext CodeArea]
[org.fxmisc.richtext.model StyleSpansBuilder]
[javafx.scene.input MouseEvent]
[org.fxmisc.flowless VirtualizedScrollPane]))

(declare jump-to-coord)
(declare find-and-jump-same-val)
Expand Down Expand Up @@ -85,7 +88,7 @@
will repaint and arm the form-code-area with the interesting and currently executing tokens.
All interesting tokens will be clickable."

[flow-id thread-id form-code-area print-tokens]
[flow-id thread-id ^CodeArea form-code-area print-tokens]
(fn [expr-executions curr-coord]
(let [interesting-coords (group-by :coord expr-executions)
spans (->> print-tokens
Expand All @@ -108,7 +111,7 @@

(.setOnMouseClicked form-code-area
(event-handler
[mev]
[^MouseEvent mev]
(let [char-hit (-> mev .getSource (.hit (.getX mev) (.getY mev)))
opt-char-idx (.getCharacterIndex char-hit)]
(when (.isPresent opt-char-idx)
Expand Down Expand Up @@ -167,12 +170,12 @@
form-header (doto (h-box [ns-label])
(.setAlignment (Pos/TOP_RIGHT)))

form-code-area (ui-utils/code-area {:editable? false
^CodeArea form-code-area (ui-utils/code-area {:editable? false
:text code-text})

form-scroll (ui-utils/virtualized-scroll-pane
form-code-area
{:max-height 800})
^VirtualizedScrollPane form-scroll (ui-utils/virtualized-scroll-pane
form-code-area
{:max-height 800})

form-pane (v-box [form-header form-scroll] "form-pane")

Expand All @@ -185,7 +188,7 @@
(.addEventFilter form-code-area
ScrollEvent/ANY
(event-handler
[sev]
[^ScrollEvent sev]
(let [current-absolute-pos (.getEstimatedScrollY form-code-area)
view-port-height (.getHeight form-scroll)
total-estimated-height (or (-> form-scroll .totalHeightEstimateProperty .getValue) 1.0)
Expand All @@ -196,7 +199,7 @@
(and at-bottom? (neg? (.getDeltaY sev)))
(<= total-estimated-height view-port-height)
(or (.isAltDown sev) (.isControlDown sev)))
(.fireEvent forms-box (.copyFor sev form-code-area forms-box))
(.fireEvent ^Node forms-box (.copyFor sev form-code-area ^Node forms-box))
(.consume sev)))))

(ui-utils/add-class form-code-area "form-pane")
Expand Down
11 changes: 7 additions & 4 deletions src-dbg/flow_storm/debugger/ui/utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
[org.kordamp.ikonli.javafx FontIcon]
[javafx.collections FXCollections ObservableList]
[org.fxmisc.richtext CodeArea]
[org.fxmisc.flowless VirtualizedScrollPane]))
[org.fxmisc.flowless VirtualFlow VirtualizedScrollPane]))

(defn run-later*
[f]
Expand Down Expand Up @@ -580,13 +580,16 @@
(let [^CodeArea this this
ih (+ (-> this .getInsets .getTop)
(-> this .getInsets .getBottom))
childs (.getChildren this)
^ObservableList childs (.getChildren this)
p-cnt (.size (.getParagraphs this))]
(if (and (pos? (.size childs))
(pos? p-cnt))
(let [c (.get childs 0)]
(let [^VirtualFlow c (.get childs 0)]
(+ ih (->> (range p-cnt)
(map (fn [i] (-> c (.getCell i) .getNode (.prefHeight w))))
(map (fn [i] (-> c
(.getCell i)
.getNode
(.prefHeight w))))
(reduce + 0))))

;; else
Expand Down

0 comments on commit 3a9366c

Please sign in to comment.