Very basic Notcurses support. There are bugs! (0.37.45)
This commit is contained in:
parent
4a6903e58a
commit
fd582f4d3a
30 changed files with 465 additions and 5 deletions
0
examples/ini_diag.fun
Normal file → Executable file
0
examples/ini_diag.fun
Normal file → Executable file
0
examples/math_ceil.fun
Normal file → Executable file
0
examples/math_ceil.fun
Normal file → Executable file
0
examples/math_cos.fun
Normal file → Executable file
0
examples/math_cos.fun
Normal file → Executable file
0
examples/math_exp_log.fun
Normal file → Executable file
0
examples/math_exp_log.fun
Normal file → Executable file
0
examples/math_floor.fun
Normal file → Executable file
0
examples/math_floor.fun
Normal file → Executable file
0
examples/math_fmin_fmax.fun
Normal file → Executable file
0
examples/math_fmin_fmax.fun
Normal file → Executable file
0
examples/math_gcd_lcm.fun
Normal file → Executable file
0
examples/math_gcd_lcm.fun
Normal file → Executable file
0
examples/math_isqrt.fun
Normal file → Executable file
0
examples/math_isqrt.fun
Normal file → Executable file
0
examples/math_round.fun
Normal file → Executable file
0
examples/math_round.fun
Normal file → Executable file
0
examples/math_sign.fun
Normal file → Executable file
0
examples/math_sign.fun
Normal file → Executable file
0
examples/math_sin.fun
Normal file → Executable file
0
examples/math_sin.fun
Normal file → Executable file
0
examples/math_sqrt.fun
Normal file → Executable file
0
examples/math_sqrt.fun
Normal file → Executable file
0
examples/math_tan.fun
Normal file → Executable file
0
examples/math_tan.fun
Normal file → Executable file
0
examples/math_trunc.fun
Normal file → Executable file
0
examples/math_trunc.fun
Normal file → Executable file
42
examples/notcurses_clock.fun
Executable file
42
examples/notcurses_clock.fun
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-03
|
||||
*/
|
||||
|
||||
// BROKEN!!!
|
||||
|
||||
/*
|
||||
* Notcurses clock demo: updates time every 200ms; any key to finish.
|
||||
*/
|
||||
|
||||
include <ui/notcurses.fun>
|
||||
|
||||
n = Notcurses()
|
||||
if n.init() == 0
|
||||
print("Notcurses not available. Rebuild with -DFUN_WITH_NOTCURSES=ON.")
|
||||
exit(0)
|
||||
|
||||
n.clear()
|
||||
n.draw_text(1, 0, "Clock demo (press any key)")
|
||||
|
||||
var done = 0
|
||||
while done == 0
|
||||
// current time string
|
||||
var ms = time_now_ms()
|
||||
var t = date_format("%Y-%m-%d %H:%M:%S", ms)
|
||||
n.draw_text(3, 0, "Time: " + t)
|
||||
|
||||
// poll without blocking too long
|
||||
var k = n.getch(200)
|
||||
if k != -1
|
||||
done = 1
|
||||
|
||||
n.shutdown()
|
||||
46
examples/notcurses_hello.fun
Executable file
46
examples/notcurses_hello.fun
Executable file
|
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-03
|
||||
*/
|
||||
|
||||
/*
|
||||
* Minimal Notcurses hello example.
|
||||
*/
|
||||
|
||||
include <ui/notcurses.fun>
|
||||
|
||||
n = Notcurses()
|
||||
|
||||
if n.init() == 0
|
||||
print("Notcurses not available. Rebuild with -DFUN_WITH_NOTCURSES=ON.")
|
||||
exit(0)
|
||||
|
||||
n.clear()
|
||||
n.draw_text(2, 0, "Fun + Notcurses")
|
||||
n.draw_text(4, 0, "Press any key to exit...")
|
||||
|
||||
// blocking until key
|
||||
_ = n.getch(0)
|
||||
n.shutdown()
|
||||
|
||||
/* Possible output:
|
||||
A TUI.
|
||||
|
||||
After exit:
|
||||
3 renders, 991,14µs (223,57µs min, 330,38µs avg, 531,91µs max)
|
||||
3 rasters, 320,76µs (106,45µs min, 106,92µs avg, 107,72µs max)
|
||||
3 writes, 198,26µs (62,54µs min, 66,09µs avg, 69,94µs max)
|
||||
59B (0B min, 19B avg, 30B max) 1 input Ghpa: 0
|
||||
0 failed renders, 0 failed rasters, 0 refreshes, 0 input errors
|
||||
RGB emits:elides: def 1:38 fg 0:0 bg 0:0
|
||||
Cell emits:elides: 39:74805 (99,95%) 97,44% 0,00% 0,00%
|
||||
Bmap emits:elides: 0:0 (0,00%) 0B (0,00%) SuM: 0 (0,00%)
|
||||
*/
|
||||
42
examples/notcurses_typing.fun
Executable file
42
examples/notcurses_typing.fun
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-03
|
||||
*/
|
||||
|
||||
// BROKEN!!!
|
||||
|
||||
/*
|
||||
* Notcurses typing demo: shows last key code; ESC quits.
|
||||
*/
|
||||
|
||||
include <ui/notcurses.fun>
|
||||
|
||||
n = Notcurses()
|
||||
if n.init() == 0
|
||||
print("Notcurses not available. Rebuild with -DFUN_WITH_NOTCURSES=ON.")
|
||||
exit(0)
|
||||
|
||||
n.clear()
|
||||
n.draw_text(1, 0, "Typing demo (ESC to quit)")
|
||||
|
||||
var running = 1
|
||||
var last = -1
|
||||
while running == 1
|
||||
// poll every 100ms
|
||||
var k = n.getch(100)
|
||||
if k != -1
|
||||
last = k
|
||||
if k == 27 // ESC
|
||||
running = 0
|
||||
// draw last key code
|
||||
n.draw_text(3, 0, "Last key code: " + to_string(last))
|
||||
|
||||
n.shutdown()
|
||||
0
examples/ripemd160_example.fun
Normal file → Executable file
0
examples/ripemd160_example.fun
Normal file → Executable file
Loading…
Add table
Add a link
Reference in a new issue