diff --git a/CMakeLists.txt b/CMakeLists.txt index 249aada..dbee8cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10) -project(fun VERSION 0.40.2 LANGUAGES C) +project(fun VERSION 0.40.3 LANGUAGES C) set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED ON) diff --git a/cmake/Extensions/Extensions.cmake b/cmake/Extensions/Extensions.cmake index b16333b..98c3805 100644 --- a/cmake/Extensions/Extensions.cmake +++ b/cmake/Extensions/Extensions.cmake @@ -20,7 +20,6 @@ include(${CMAKE_SOURCE_DIR}/cmake/Extensions/XML2.cmake) include(${CMAKE_SOURCE_DIR}/cmake/Extensions/LIBSQL.cmake) include(${CMAKE_SOURCE_DIR}/cmake/Extensions/PCRE2.cmake) include(${CMAKE_SOURCE_DIR}/cmake/Extensions/CURL.cmake) -include(${CMAKE_SOURCE_DIR}/cmake/Extensions/NOTCURSES.cmake) include(${CMAKE_SOURCE_DIR}/cmake/Extensions/REPL.cmake) include(${CMAKE_SOURCE_DIR}/cmake/Extensions/OPENSSL.cmake) @@ -35,7 +34,6 @@ _fun_print_feature("libxml2 (FUN_WITH_XML2)" FUN_WITH_XML2) _fun_print_feature("libsql (FUN_WITH_LIBSQL)" FUN_WITH_LIBSQL) _fun_print_feature("PCRE2 (FUN_WITH_PCRE2)" FUN_WITH_PCRE2) _fun_print_feature("libcurl (FUN_WITH_CURL)" FUN_WITH_CURL) -_fun_print_feature("Notcurses (FUN_WITH_NOTCURSES)" FUN_WITH_NOTCURSES) _fun_print_feature("REPL (FUN_WITH_REPL)" FUN_WITH_REPL) _fun_print_feature("OpenSSL (FUN_WITH_OPENSSL)" FUN_WITH_OPENSSL) message(STATUS "--------------------------------") diff --git a/cmake/Targets.cmake b/cmake/Targets.cmake index 4a73e0b..16c57cd 100644 --- a/cmake/Targets.cmake +++ b/cmake/Targets.cmake @@ -36,7 +36,6 @@ foreach(var_pair LIBSQL LIBXML2 TCL - NOTCURSES OPENSSL) if(${var_pair}_INCLUDE_DIRS) target_include_directories(fun_core PRIVATE ${${var_pair}_INCLUDE_DIRS}) @@ -78,9 +77,6 @@ if(FUN_WITH_CURL) target_compile_definitions(fun_core PUBLIC FUN_WITH_CURL=1) endif() -if(FUN_WITH_NOTCURSES) - target_compile_definitions(fun_core PUBLIC FUN_WITH_NOTCURSES=1) -endif() if(FUN_WITH_SQLITE) target_compile_definitions(fun_core PUBLIC FUN_WITH_SQLITE=1) diff --git a/examples/external/notcurses/notcurses_hello.fun b/examples/external/notcurses/notcurses_hello.fun deleted file mode 100755 index ba0c493..0000000 --- a/examples/external/notcurses/notcurses_hello.fun +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env fun - -/* - * This file is part of the Fun programming language. - * https://fun-lang.xyz/ - * - * Copyright 2025 Johannes Findeisen - * 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 - -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%) -*/ diff --git a/examples/external/notcurses/notcurses_menu.fun b/examples/external/notcurses/notcurses_menu.fun deleted file mode 100755 index 8c17449..0000000 --- a/examples/external/notcurses/notcurses_menu.fun +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env fun - -include - -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() diff --git a/examples/external/notcurses/notcurses_progress.fun b/examples/external/notcurses/notcurses_progress.fun deleted file mode 100755 index 8176685..0000000 --- a/examples/external/notcurses/notcurses_progress.fun +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env fun - -include - -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() diff --git a/lib/ui/notcurses.fun b/lib/ui/notcurses.fun deleted file mode 100644 index e4b352c..0000000 --- a/lib/ui/notcurses.fun +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env fun - -/* - * This file is part of the Fun programming language. - * https://fun-lang.xyz/ - * - * Copyright 2025 Johannes Findeisen - * Licensed under the terms of the Apache-2.0 license. - * https://opensource.org/license/apache-2-0 - * - * Added: 2026-01-03 - */ - -// Notcurses stdlib abstraction wrapping VM NC_* builtins. -// Provides a tiny OO-style helper around nc_init/nc_clear/nc_draw_text/nc_getch/nc_shutdown. -// If Fun was built without Notcurses support, init() returns 0 and methods are no-ops. - -class Notcurses() - // Initialize Notcurses core. Returns 1 on success, 0 on failure. - fun init(this) - return nc_init() - - // Clear the screen and render. Returns 0 on success, -1 on error. - fun clear(this) - return nc_clear() - - // Draw text at y, x and render. Returns 0 on success, -1 on error. - fun draw_text(this, y, x, text) - // allow flexible types - return nc_draw_text(to_number(y), to_number(x), to_string(text)) - - // Get a Unicode codepoint (int). timeout_ms<=0 blocks; >0 returns -1 if no key ready. - fun getch(this, timeout_ms) - if timeout_ms == nil - timeout_ms = 0 - return nc_getch(to_number(timeout_ms)) - - // Shut down Notcurses, restoring the terminal. - fun shutdown(this) - return nc_shutdown() - - // (banner helper removed temporarily due to parser limitations) - - // --- Extended primitives --- - fun size(this) - return nc_get_size() - - fun render(this) - return nc_render() - - // fg/bg are 0xRRGGBB, style bitmask: bold(1), dim(2), italic(4), underline(8), strike(16), reverse(32) - fun set_style(this, fg, bg, style) - // parser order for builtin is (style,bg,fg) - return nc_set_style(to_number(style), to_number(bg), to_number(fg)) - - fun draw_char(this, y, x, ch) - return nc_draw_char(to_number(y), to_number(x), to_number(ch)) - - fun hline(this, y, x, len, ch) - return nc_draw_hline(to_number(y), to_number(x), to_number(len), to_number(ch)) - - fun vline(this, y, x, len, ch) - return nc_draw_vline(to_number(y), to_number(x), to_number(len), to_number(ch)) - - fun box(this, y, x, h, w, style) - // builtin expects (x,y,w,h,style) - return nc_box(to_number(x), to_number(y), to_number(w), to_number(h), to_number(style)) - - fun fill(this, y, x, h, w, ch) - // builtin expects (x,y,w,h,ch) - return nc_fill(to_number(x), to_number(y), to_number(w), to_number(h), to_number(ch)) - - // --- Widgets as methods --- - // Status bar on the last row - fun status_bar(this, text, style) - sz = this.size() - if style == nil - style = 32 - rc = this.set_style(0x000000, 0xFFFFFF, style) - rc = this.fill(sz[0] - 1, 0, 1, sz[1], 32) - rc = this.draw_text(sz[0] - 1, 1, text) - rc = this.render() - return 0 - - // Draw styled label - fun label(this, y, x, text, style) - if style != nil - rc = this.set_style(0xFFFFFF, 0x000000, style) - rc = this.draw_text(y, x, text) - rc = this.render() - return 0 - - // Panel with optional title - fun box_panel(this, y, x, h, w, title, style) - if style == nil - style = 0 - rc = this.box(y, x, h, w, style) - if title != nil - rc = this.draw_text(y, x + 2, to_string(title)) - rc = this.render() - return 0 - - // Progress bar (frac in 0..1) - fun progress(this, y, x, w, frac, style) - if style == nil - style = 0 - if frac < 0 - frac = 0 - if frac > 1 - frac = 1 - // frame and title - rc = nc_box(to_number(x - 2), to_number(y - 1), to_number(w + 4), 3, to_number(style)) - // background in dim gray - rc = this.set_style(0x606060, 0x000000, 2) - rc = nc_fill(to_number(y), to_number(x), to_number(w), 1, 46) // '.' - // filled portion in bold green - rc = this.set_style(0x00FF00, 0x000000, 1) - fw = to_number(frac) * w - if fw < 0 - fw = 0 - if fw > w - fw = w - if fw > 0 - rc = nc_fill(to_number(y), to_number(x), to_number(fw), 1, 35) // '#' - rc = nc_draw_text(to_number(y - 1), to_number(x), "Progress") - rc = nc_render() - return 0 - - // Simple vertical menu, highlight selected index - fun menu(this, y, x, items, selected_idx, w, style, sel_style) - if style == nil - style = 0 - if sel_style == nil - sel_style = 32 - i = 0 - while i < len(items) - if i == selected_idx - rc = this.set_style(0x000000, 0xFFFFFF, sel_style) - else - rc = this.set_style(0xFFFFFF, 0x000000, style) - if w != nil - if len(to_string(items[i])) > w - rc = this.draw_text(y + i, x, substr(to_string(items[i]), 0, w)) - else - rc = this.draw_text(y + i, x, to_string(items[i])) - else - rc = this.draw_text(y + i, x, to_string(items[i])) - i = i + 1 - rc = this.render() - return 0 - - // Input line echo with cursor - fun input_line(this, y, x, prompt, buffer, cursor_idx, w, style) - if style == nil - style = 0 - if w == nil - w = len(buffer) + len(prompt) + 2 - rc = this.set_style(0xFFFFFF, 0x000000, style) - rc = this.draw_text(y, x, to_string(prompt)) - rc = this.fill(y, x + len(prompt), 1, w, 32) - rc = this.draw_text(y, x + len(prompt), to_string(buffer)) - this.set_style(0x000000, 0xFFFFFF, 32) - ci = cursor_idx - if ci < 0 - ci = 0 - if ci > len(buffer) - ci = len(buffer) - rc = this.draw_char(y, x + len(prompt) + ci, 32) - rc = this.render() - return 0 - -// --- End of class Notcurses --- diff --git a/src/vm.c b/src/vm.c index 416f252..5b31213 100644 --- a/src/vm.c +++ b/src/vm.c @@ -53,12 +53,7 @@ #include "value.h" #include "vm.h" -/* Shared Notcurses state (optional) */ -#ifdef FUN_WITH_NOTCURSES -#include -#include /* ensure wcwidth/wcswidth prototypes present before notcurses.h on some systems */ -#endif -#include "vm/notcurses/common.h" +/* Notcurses support removed */ // Optional by extensions commonly used code. #ifdef's are in each single file. #include "external/curl.c" @@ -863,22 +858,7 @@ void vm_run(VM *vm, Bytecode *entry) { #include "vm/tk/wm_title.c" #endif -/* Notcurses TUI ops (optional) */ -#ifdef FUN_WITH_NOTCURSES -#include "vm/notcurses/clear.c" -#include "vm/notcurses/draw_text.c" -#include "vm/notcurses/getch.c" -#include "vm/notcurses/init.c" -#include "vm/notcurses/shutdown.c" -#include "vm/notcurses/get_size.c" -#include "vm/notcurses/set_style.c" -#include "vm/notcurses/draw_char.c" -#include "vm/notcurses/hline.c" -#include "vm/notcurses/vline.c" -#include "vm/notcurses/box.c" -#include "vm/notcurses/fill.c" -#include "vm/notcurses/render.c" -#endif +/* Notcurses TUI ops removed */ /* SQLite ops */ #ifdef FUN_WITH_SQLITE