Compute glyphLayout after text rendering. Implement correct cursor
movement.
This commit is contained in:
+9
-7
@@ -37,6 +37,8 @@ func run(w *app.Window) error {
|
||||
renderer := ui.New(ui.Theme{FontSize: 14}, shaper, logic.State())
|
||||
var mu sync.Mutex
|
||||
var elems []ui.Element
|
||||
var curScale, newScale float32
|
||||
|
||||
log.Printf("run: starting frameReceiver")
|
||||
go frameReceiver(w, &mu, &elems, logic.FrameChan())
|
||||
log.Printf("run: starting logic.Run")
|
||||
@@ -55,16 +57,13 @@ func run(w *app.Window) error {
|
||||
case app.FrameEvent:
|
||||
log.Printf("run: FrameEvent")
|
||||
gtx := app.NewContext(&ops, e)
|
||||
newScale := gtx.Metric.PxPerDp
|
||||
curScale := logic.State().Scale()
|
||||
if newScale != curScale {
|
||||
logic.ConfigChan() <- editor.ScaleEvent{newScale}
|
||||
}
|
||||
newScale = gtx.Metric.PxPerDp
|
||||
curScale = logic.State().Scale()
|
||||
// Deadlock risk: ensure no channel sends while lock is held
|
||||
mu.Lock()
|
||||
currentElems := elems
|
||||
renderer.Draw(gtx, currentElems)
|
||||
lastLineY := int(renderer.LastLineY())
|
||||
glyphLayout := renderer.GlyphLayout()
|
||||
// Send search query update to the logic goroutine when it changes.
|
||||
// The logic goroutine handles filtering and triggers a new frame.
|
||||
newQuery := logic.State().Browser.SearchEditor.Text()
|
||||
@@ -112,13 +111,16 @@ func run(w *app.Window) error {
|
||||
}
|
||||
e.Frame(&ops)
|
||||
mu.Unlock()
|
||||
if newScale != curScale {
|
||||
logic.ConfigChan() <- editor.ScaleEvent{newScale}
|
||||
}
|
||||
if len(events) > 0 {
|
||||
logic.InputChan() <- events
|
||||
}
|
||||
if sendQuery {
|
||||
logic.SearchQueryChan() <- newQuery
|
||||
}
|
||||
logic.DisplayLineChan() <- lastLineY
|
||||
logic.LayoutChan() <- glyphLayout
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user