More notcurses fun. Not stable! (0.39.4)
This commit is contained in:
parent
69b9b87dd4
commit
18ac230c21
19 changed files with 715 additions and 15 deletions
33
examples/extra/notcurses_menu.fun
Normal file
33
examples/extra/notcurses_menu.fun
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
include <ui/notcurses.fun>
|
||||
|
||||
n = Notcurses()
|
||||
if n.init() == 0
|
||||
print("Notcurses not available. Build with -DFUN_WITH_NOTCURSES=ON.")
|
||||
exit(1)
|
||||
|
||||
items = ["First", "Second", "Third", "Fourth"]
|
||||
sel = 0
|
||||
while true
|
||||
n.clear()
|
||||
// Title
|
||||
n.set_style(0xFFFF00, 0x000000, 1) // bold yellow
|
||||
n.draw_text(1, 2, "Demo Menu (j/k to move, Enter to select, ESC to quit)")
|
||||
|
||||
// Render menu list
|
||||
n.menu(3, 4, items, sel, 30, 0, 32)
|
||||
|
||||
key = n.getch(0)
|
||||
if key == 27 // ESC
|
||||
break
|
||||
if key == 106 // 'j'
|
||||
sel = (sel + 1) % len(items)
|
||||
if key == 107 // 'k'
|
||||
sel = (sel - 1 + len(items)) % len(items)
|
||||
if key == 10 // Enter
|
||||
n.status_bar("Selected: " + items[sel], 32)
|
||||
// brief wait
|
||||
sleep_ms(300)
|
||||
|
||||
n.shutdown()
|
||||
38
examples/extra/notcurses_progress.fun
Normal file
38
examples/extra/notcurses_progress.fun
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
include <ui/notcurses.fun>
|
||||
|
||||
n = Notcurses()
|
||||
if n.init() == 0
|
||||
print("Notcurses not available. Build with -DFUN_WITH_NOTCURSES=ON.")
|
||||
exit(1)
|
||||
|
||||
n.clear()
|
||||
sz = n.size()
|
||||
rows = 24
|
||||
cols = 80
|
||||
if typeof(sz) == "array"
|
||||
if len(sz) >= 2
|
||||
rows = sz[0]
|
||||
cols = sz[1]
|
||||
|
||||
y = to_number(rows) / 2
|
||||
w = cols - 10
|
||||
if w < 20
|
||||
w = 20
|
||||
|
||||
i = 0
|
||||
while i <= 100
|
||||
// styles handled inside progress(); keep plane sane
|
||||
rc = n.set_style(0x00FF00, 0x000000, 1)
|
||||
frac = to_number(i) / 100
|
||||
rc = n.progress(y, 5, w, frac, 0)
|
||||
k = n.getch(10)
|
||||
i = i + 1
|
||||
|
||||
// final message
|
||||
rc = n.set_style(0xFFFFFF, 0x000000, 1)
|
||||
rc = n.draw_text(y + 2, 5, "Done!")
|
||||
rc = n.render()
|
||||
|
||||
rc = n.shutdown()
|
||||
Loading…
Add table
Add a link
Reference in a new issue