Skip to content

Commit

Permalink
huetnoa
Browse files Browse the repository at this point in the history
  • Loading branch information
saikyun committed Aug 11, 2021
1 parent 71b3df3 commit a4e6787
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 9 deletions.
29 changes: 20 additions & 9 deletions freja/new_gap_buffer.janet
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,15 @@ Used e.g. when loading a file."

### insertion

(defn min*
"`min` treating `nil` as a high number"
[a b]
(if a
(if b
(min a b)
a)
b))

(varfn insert-char-at-caret
"Inserts char `c` at the index of the caret."
[gb c]
Expand All @@ -756,15 +765,17 @@ Used e.g. when loading a file."
(buffer/push-byte gap c)
(buffer/push-string gap to-the-right))))
(update :caret inc))]
(update gb
:actions
array/push
{:kind :insert
:caret-before caret-before
:content (c->s c)
:caret-after (gb :caret)
:start caret-before
:stop (gb :caret)})))
(-> gb
(update :lowest-changed-at min* (gb :caret))
(update
:actions
array/push
{:kind :insert
:caret-before caret-before
:content (c->s c)
:caret-after (gb :caret)
:start caret-before
:stop (gb :caret)}))))

(varfn insert-string-at-caret*
"Inserts string `s` at the position of the caret, without updating the caret or adding to the history.
Expand Down
3 changes: 3 additions & 0 deletions freja/render_new_gap_buffer.janet
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,7 @@ This function is pretty expensive since it redoes all word wrapping."
:colors colors
:scroll scroll
:changed changed
:lowest-changed-at change-pos
:changed-x-pos changed-x-pos
:changed-nav changed-nav
:changed-selection changed-selection
Expand Down Expand Up @@ -969,6 +970,8 @@ This function is pretty expensive since it redoes all word wrapping."

(def sizes (a/glyph-sizes (gb :text/font) (gb :text/size)))

(when change-pos (print "CHANGE POS: " change-pos))

(var lines (if (or changed changed-scroll)
(timeit "word wrap" (let [sizes sizes]
(word-wrap-gap-buffer
Expand Down
11 changes: 11 additions & 0 deletions measure-stuff.janet
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(use profiling/profile)

(print-results)

(+ 1 1)

(comment
(reset-profiling!)

#
)
37 changes: 37 additions & 0 deletions test_stuff.janet
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
(import freja/frp)
(import ./freja/render_new_gap_buffer :as r)
(use freja/defonce)
(use freja/theme)

(defonce thing @{})

(use freja-jaylib)

(defn draw
[_ _]
(comment
(r/gb-draw-text
@{:text/font "MplusCode"
:text/size 20
:text/spacing 0.5}
"that's crazy dude. whaaaaaat\n
whtaaaaaaaaaaaaaaaaaaaaaaat" [20 30]
#:white
(rgba 71 93 101)))

(r/gb-draw-text
@{:text/font "MplusCode"
:text/size 20
:text/spacing 0.5}
"that's crazy dude. whaaaaaat\n
whtaaaaaaaaaaaaaaaaaaaaaaat" [20 30]
:white
#(rgba 71 93 101)
)
(print)
(print))

(put thing :on-event draw)

(frp/subscribe-finally! frp/frame-chan thing)
(frp/subscribe-finally! frp/frame-chan pp)

0 comments on commit a4e6787

Please sign in to comment.