Skip to content

Commit

Permalink
FIX: [TUI] set /rate for window face doesn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
qtxie committed Jun 13, 2024
1 parent 4295372 commit fe8f031
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 13 deletions.
3 changes: 2 additions & 1 deletion modules/view/backends/terminal/events.reds
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,11 @@ do-events: func [
mouse-event?: no
tty/disable-mouse
]
screen/exit-alter-screen
tty/restore
tty/read-input no ;-- clear stdin queue
tty/show-cursor
screen/reset
tty/show-cursor

msg?
]
7 changes: 4 additions & 3 deletions modules/view/backends/terminal/gui.reds
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,9 @@ OS-make-view: func [
screen/update-bounding-box widget
screen/update-editable-widget widget
screen/update-focus-widget widget

if TYPE_OF(rate) <> TYPE_NONE [change-rate widget rate]
if TYPE_OF(image) = TYPE_IMAGE [change-image widget image]
]
if TYPE_OF(rate) <> TYPE_NONE [change-rate widget rate]

stack/unwind
as-integer widget
Expand Down Expand Up @@ -780,8 +779,10 @@ OS-destroy-view: func [
empty? [logic!]
][
free-faces face
if zero? screen/windows-cnt [
either zero? screen/windows-cnt [
post-quit-msg
][
screen/redraw null
]
]

Expand Down
36 changes: 29 additions & 7 deletions modules/view/backends/terminal/screen.reds
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ screen: context [
offset-x: 0
offset-y: 0
alternate-screen?: no
in-alter-mode?: no

init: func [][
win-list: array/make 4 size? int-ptr!
Expand All @@ -37,8 +38,16 @@ screen: context [
]

enter-alter-screen: does [
if alternate-screen? [
if all [alternate-screen? not in-alter-mode?][
tty/enter-alter-screen
in-alter-mode?: yes
]
]

exit-alter-screen: does [
if in-alter-mode? [
tty/exit-alter-screen
in-alter-mode?: no
]
]

Expand All @@ -65,6 +74,16 @@ screen: context [
]
i: i + 1
]
if in-alter-mode? [
render
]
]

clear: does [
if in-alter-mode? [
tty/write as byte-ptr! "^[[2J" 4
fflush 0
]
]

reset: does [
Expand All @@ -89,10 +108,6 @@ screen: context [
last-mouse-evt: 0
mouse-click-delta: 0
mouse-event?: no
if alternate-screen? [
tty/exit-alter-screen
alternate-screen?: no
]
]

windows-cnt: func [
Expand Down Expand Up @@ -160,14 +175,18 @@ screen: context [
p [red-block!]
obj [red-object!]
end [red-object!]
h [handle!]
][
if w/ui <> null [collector/keep w/ui]
p: CHILD_WIDGET(w)
if TYPE_OF(p) = TYPE_BLOCK [
obj: as red-object! block/rs-head p
end: as red-object! block/rs-tail p
while [obj < end][
_mark-widget as widget! get-face-handle obj
h: face-handle? obj
if h <> null [
_mark-widget as widget! h
]
obj: obj + 1
]
]
Expand Down Expand Up @@ -389,14 +408,17 @@ screen: context [
i [integer!]
w [widget!]
wm [window-manager!]
wins [node!]
][
wins: array/copy win-list
cnt: windows-cnt
i: 1
while [i <= cnt][
wm: as window-manager! array/pick-ptr win-list i
wm: as window-manager! array/pick-ptr wins i
free-faces get-face-obj wm/window
i: i + 1
]
array/clear wins
]

#define ADD_BYTE(byte) [array/append-byte esc-sequences byte]
Expand Down
4 changes: 2 additions & 2 deletions modules/view/backends/terminal/tty.reds
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ tty: context [
sz/x: columns
sz/y: rows
]
screen/on-resize columns rows
if raw-mode? [screen/on-resize columns rows]
]

init: does [
Expand All @@ -130,7 +130,7 @@ tty: context [
get-window-size
raw-mode?: yes
]
report-cursor-position
unless screen/alternate-screen? [report-cursor-position]
]

restore: does [
Expand Down

0 comments on commit fe8f031

Please sign in to comment.