1
0
Fork 0
forked from fun/fun

Removed all tcltk support. (0.40.5)

This commit is contained in:
Johannes Findeisen 2026-04-03 19:51:08 +02:00
commit 4365546327
14 changed files with 5 additions and 328 deletions

View file

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.10)
project(fun VERSION 0.40.4 LANGUAGES C)
project(fun VERSION 0.40.5 LANGUAGES C)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)

View file

@ -95,7 +95,6 @@ See [./lib/](https://git.xw3.org/fun/fun/src/branch/main/lib) for what the stand
- [PCSC (smart cards)](./docs/external/pcsc.md) (optional) ☑
- [OpenSSL](./docs/external/openssl.md) (optional) ☑
- [SQLite](./docs/external/sqlite.md) (optional) ☑
- [Tk (Tcl/Tk GUI)](./docs/external/tcltk.md) (optional) ☑
- [XML (libxml2)](./docs/external/xml2.md) (optional) ☑
☑ = Done / ☐ = Planned or in progress.

View file

@ -10,8 +10,7 @@ function(_fun_print_feature name flag)
endif()
endfunction()
# Include each extension module
include(${CMAKE_SOURCE_DIR}/cmake/Extensions/TCLTK.cmake)
# Include each extension module (Tcl/Tk removed)
include(${CMAKE_SOURCE_DIR}/cmake/Extensions/SQLITE.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/Extensions/PCSC.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/Extensions/JSON.cmake)
@ -24,7 +23,6 @@ include(${CMAKE_SOURCE_DIR}/cmake/Extensions/OPENSSL.cmake)
# Summary of extension toggles
message(STATUS "---- Fun extension summary ----")
_fun_print_feature("Tcl/Tk (FUN_WITH_TCLTK)" FUN_WITH_TCLTK)
_fun_print_feature("SQLite (FUN_WITH_SQLITE)" FUN_WITH_SQLITE)
_fun_print_feature("PCSC (FUN_WITH_PCSC)" FUN_WITH_PCSC)
_fun_print_feature("JSON-C (FUN_WITH_JSON)" FUN_WITH_JSON)

View file

@ -35,7 +35,6 @@ foreach(var_pair
INIPARSER
LIBSQL
LIBXML2
TCL
OPENSSL)
if(${var_pair}_INCLUDE_DIRS)
target_include_directories(fun_core PRIVATE ${${var_pair}_INCLUDE_DIRS})
@ -82,9 +81,6 @@ if(FUN_WITH_SQLITE)
target_compile_definitions(fun_core PUBLIC FUN_WITH_SQLITE=1)
endif()
if(FUN_WITH_TCLTK)
target_compile_definitions(fun_core PUBLIC FUN_WITH_TCLTK=1)
endif()
if(FUN_WITH_OPENSSL)
target_compile_definitions(fun_core PUBLIC FUN_WITH_OPENSSL=1)

View file

@ -47,7 +47,7 @@ This file serves as an index of the documents in this directory. Links are relat
Documentation for optional, build-time selectable integrations lives in [external/](./external/):
- [Index of extensions](./external/README.md)
- Highlights: [cURL](./external/curl.md), [INI](./external/ini.md), [JSON](./external/json.md), [XML (libxml2)](./external/xml2.md), [SQLite](./external/sqlite.md), [PCRE2](./external/pcre2.md), [PC/SC](./external/pcsc.md), [Tcl/Tk](./external/tcltk.md), [OpenSSL](./external/openssl.md)
- Highlights: [cURL](./external/curl.md), [INI](./external/ini.md), [JSON](./external/json.md), [XML (libxml2)](./external/xml2.md), [SQLite](./external/sqlite.md), [PCRE2](./external/pcre2.md), [PC/SC](./external/pcsc.md), [OpenSSL](./external/openssl.md)
## Tips

View file

@ -15,7 +15,6 @@ This section documents Fun's optional, build-time selectable extensions. Each pa
- [SQLite](./sqlite.md)
- [PCRE2 (Perl-compatible regex)](./pcre2.md)
- [PC/SC (Smart cards)](./pcsc.md)
- [Tcl/Tk (GUI)](./tcltk.md)
- [OpenSSL](./openssl.md)
## Notes:

View file

@ -1,21 +0,0 @@
# Tcl/Tk (GUI) extension (optional)
- CMake option: FUN_WITH_TCLTK=ON
- Purpose: Basic GUI functionality via Tcl/Tk.
- Homepage: https://www.tcl.tk/
## Opcodes:
- OP_TK_EVAL: pops script string; pushes rc (0=OK)
- OP_TK_RESULT: pushes last Tcl result string
- OP_TK_LOOP: enters main event loop; pushes Nil when done
- OP_TK_WM_TITLE: pops title string; sets window title; pushes rc
- OP_TK_LABEL: pops text, id; creates/updates label .id; pushes rc
- OP_TK_BUTTON: pops text, id; creates/updates button .id; pushes rc
- OP_TK_PACK: pops id; packs .id; pushes rc
- OP_TK_BIND: pops command, event, id; binds; pushes rc
## Notes:
- Requires Tcl/Tk development headers/libs.
- GUI behavior depends on your desktop environment/window manager.

View file

@ -93,15 +93,12 @@ Pass all options as -DNAME=VALUE. The most relevant toggles are:
- FUN_DEBUG=ON|OFF — verbose VM debug logging (default OFF)
- FUN_WITH_CURL=ON|OFF — enable CURL (libcurl) support (default OFF)
- FUN_WITH_JSON=ON|OFF — enable JSON (json-c) support (default OFF)
- FUN_WITH_LIBSQL=ON|OFF — enable libSQL (Turso) client support (default OFF)
- FUN_WITH_XML2=ON|OFF — enable XML (libxml2) support (default OFF)
- FUN_WITH_PCRE2=ON|OFF — enable PCRE2 (Perl-Compatible Regular Expressions) (default OFF)
- FUN_WITH_PCSC=ON|OFF — enable PC/SC smart card (PCSC lite) support (default OFF)
- FUN_WITH_REPL=ON|OFF — enable the interactive REPL (default OFF)
- FUN_WITH_SQLITE=ON|OFF — enable SQLite (sqlite3) support (default OFF)
- FUN_WITH_TCLTK=ON|OFF — enable Tk (GUI via Tcl/Tk) support (default OFF)
- FUN_WITH_INI=ON|OFF — enable INI (iniparser) support (default OFF)
- FUN_WITH_NOTCURSES=ON|OFF — enable Notcurses TUI support (default OFF)
You can also set the default search path for the bundled stdlib with DEFAULT_LIB_DIR:
@ -131,27 +128,6 @@ sqlite3 ./database.sqlite < ./examples/data/database.sql
FUN_LIB_DIR="$(pwd)/lib" ./build/fun ./examples/sqlite_example.fun
```
#### libSQL example (optional feature)
libSQL support is optional and disabled by default. It is implemented as an independent extension and can coexist with SQLite. To build with it and run the example:
```
cmake -S . -B build -DFUN_WITH_LIBSQL=ON
cmake --build build --target fun
# Create the sample database using the sqlite3 CLI (libSQL implements the sqlite C API)
sqlite3 ./database.sqlite < ./examples/data/database.sql
# Run the libSQL example
FUN_LIB_DIR="$(pwd)/lib" ./build/fun ./examples/libsql_example.fun
```
Available builtins when built with -DFUN_WITH_LIBSQL=ON:
- libsql_open(path_or_url) -> handle (>0) or 0 on error
- libsql_close(handle) -> Nil
- libsql_exec(handle, sql) -> rc (0 on success)
- libsql_query(handle, sql) -> array of map rows
#### XML example (optional feature)
XML support (via libxml2) is optional and disabled by default. To build with it and run the example:
@ -196,52 +172,6 @@ Notes:
- Handles are simple integers managed by the VM; nodes are owned by their document.
- This initial integration focuses on parsing and basic navigation. Attributes, children iteration, and XPath may be added later.
#### Tk GUI example (optional feature)
Tk GUI support is optional and disabled by default. It embeds a Tcl/Tk interpreter and exposes a small, Tk-only API to Fun code (no raw Tcl required).
To build with Tk and run the example:
```
cmake -S . -B build -DFUN_WITH_TCLTK=ON
cmake --build build --target fun
# Run the example
FUN_LIB_DIR="$(pwd)/lib" ./build/fun ./examples/tk_hello.fun
```
Available VM builtins when built with -DFUN_WITH_TCLTK=ON:
- tk_title(title: string) -> rc
- tk_label(id: string, text: string) -> rc
- tk_button(id: string, text: string) -> rc
- tk_pack(id: string) -> rc
- tk_loop() -> Nil (enters event loop until the window is closed)
Standard library wrapper (lib/ui/tk.fun):
- class TK
- title(title: string): int
- label(id: string, text: string): int
- button(id: string, text: string): int
- pack(id: string): int
- loop(): Nil
Example Fun code:
```
include <ui/tk.fun>
tk = TK()
tk.title("Fun + Tk GUI")
tk.label("hello", "Hello, world!")
tk.pack("hello")
tk.button("ok", "OK")
tk.pack("ok")
tk.loop()
```
Notes:
- Ensure Tcl/Tk is installed (8.6+). On Linux install tcl/tk packages; on macOS install Homebrew tcl-tk; on Windows ensure the DLLs are available.
- The Fun process terminates when the main window is closed or when the example's OK button is clicked.
### Install Fun to the OS (optional)
Not recommended during early development, but supported:
@ -534,7 +464,7 @@ Notes:
- JSON types map to Fun types: object -> map, array -> array, string -> string, number -> number/float, true/false -> 1/0, null -> nil.
- When writing, prettyFlag=1 enables pretty printing.
### CURL (optional)
### cURL (optional)
Build flag: -DFUN_WITH_CURL=ON; requires libcurl.
@ -658,28 +588,6 @@ else
ini_free(h)
```
### Notcurses (optional)
Build flag: -DFUN_WITH_NOTCURSES=ON; requires notcurses (pkg-config: notcurses or notcurses-core).
VM API:
- nc_init() -> 1/0 (initialize TUI; call once)
- nc_draw_text(x, y, text) -> 0 on success, -1 on error
- nc_clear() -> 0 on success, -1 on error
- nc_getch(timeout_ms) -> key code (int), -1 if timeout/no input
- nc_shutdown() -> 1/0 (restore terminal)
Example:
```
if (nc_init())
nc_draw_text(2, 1, "Fun + Notcurses")
print("Press any key...")
k = nc_getch(0) // 0 = blocking
nc_shutdown()
else
print("Notcurses init failed")
```
### XML (optional)
Build flag: -DFUN_WITH_XML2=ON; requires libxml2.
@ -715,22 +623,6 @@ else
Notes:
- Handles are integers managed by the VM; nodes belong to their document.
### libSQL (optional)
Build flag: -DFUN_WITH_LIBSQL=ON; requires libSQL client (compatible with sqlite3 C API).
VM API:
- libsql_open(path_or_url) -> handle (>0) or 0 on error
- libsql_close(handle) -> nil
- libsql_exec(handle, sql) -> rc (0 on success)
- libsql_query(handle, sql) -> array of row maps
Example flow:
1) h = libsql_open("./database.sqlite")
2) rows = libsql_query(h, "SELECT id, title FROM tasks;")
3) rc = libsql_exec(h, "INSERT INTO tasks (title) VALUES ('Try libSQL');")
4) libsql_close(h)
### PCRE2 / Regex (optional)
Build flag: -DFUN_WITH_PCRE2=ON; requires PCRE2 (8-bit API).
@ -748,35 +640,6 @@ Examples: regex_demo.fun, regex_procedural.fun
Notes:
- Patterns use PCRE2 syntax.
### Tcl/Tk GUI (optional)
Build flag: -DFUN_WITH_TCLTK=ON; requires Tcl/Tk (8.6+).
VM API:
- tk_title(title) -> rc
- tk_label(id, text) -> rc
- tk_button(id, text) -> rc
- tk_pack(id) -> rc
- tk_loop() -> nil (enters event loop)
Stdlib wrapper:
- class TK (lib/ui/tk.fun) mirrors the VM API.
Example:
```
include <ui/tk.fun>
tk = TK()
tk.title("Fun + Tk GUI")
tk.label("hello", "Hello, world!")
tk.pack("hello")
tk.button("ok", "OK")
tk.pack("ok")
tk.loop()
```
Notes:
- Ensure Tcl/Tk runtime libraries are available on your system.
### REPL (optional)

View file

@ -1,59 +0,0 @@
#!/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: 2025-12-23
*/
#include <ui/tk.fun>
print("Initializing Fun File Manager...")
tk = TK()
tk.title("Fun File Manager")
// Current directory
dir = env("PWD")
if (dir == "")
dir = "."
print("Current directory: " + dir)
tk.label("path", "Current Dir: " + dir)
tk.pack("path")
// Files listbox
tk.listbox("files")
tk.pack("files")
// Populate listbox
fun refresh(tk, dir)
print("Refreshing file list for: " + dir)
tk.clear("files")
files = os_list_dir(dir)
print("Found " + to_string(len(files)) + " entries.")
for f in files
tk.insert("files", "end", f)
refresh(tk, dir)
// Refresh button
// Using tk.eval for button because tk.button currently exits the app.
tk.eval("button .refresh -text {Refresh} -command {puts {Refresh requested}}")
tk.pack("refresh")
// Exit button
tk.button("exit", "Exit")
tk.pack("exit")
print("Entering Tk loop...")
tk.loop()
print("Tk loop exited.")
/* Expected output:
A GUI... ;)
*/

View file

@ -1,33 +0,0 @@
#!/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: 2025-12-09
*/
// Demonstrates the Tk stdlib wrapper class using the new Tk opcodes.
include <ui/tk.fun>
tk = TK()
tk.title("Fun + Tk GUI")
tk.label("hello", "Hello, world!")
tk.pack("hello")
tk.button("ok", "OK")
tk.pack("ok")
// Enter GUI loop (no-op if built without FUN_WITH_TCLTK)
tk.loop()
/* Expected output:
A GUI... ;)
*/

View file

@ -1,38 +0,0 @@
#!/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: 2025-12-23
*/
#include <ui/tk.fun>
print("Testing os_list_dir...")
files = os_list_dir(".")
print("Found " + to_string(len(files)) + " files.")
if len(files) > 0
print("First file: " + files[0])
print("Testing tk_bind parsing...")
// We can't easily test Tk without an X server, but we can see if it crashes.
// If built with FUN_WITH_TCLTK, it should at least initialize.
// We use tk_eval to avoid full loop.
rc = tk_eval("set x 1")
print("tk_eval rc: " + to_string(rc))
if rc == 0
print("Tcl Result: " + tk_result())
/* Expected output:
Testing os_list_dir...
Found 23 files.
First file: build
Testing tk_bind parsing...
tk_eval rc: 0
Tcl Result: 1
*/

View file

@ -320,9 +320,6 @@ using: 1
cards)](./docs/external/pcsc.md): 1
[openssl](./docs/external/openssl.md): 1
[sqlite](./docs/external/sqlite.md): 1
[tk: 1
(tcl/tk: 1
gui)](./docs/external/tcltk.md): 1
[xml: 1
(libxml2)](./docs/external/xml2.md): 1
=: 2

13
make
View file

@ -22,33 +22,26 @@ if [ "$target" = "all" ]; then
&& cmake -S . -B build \
-DFUN_WITH_PCSC=ON \
-DFUN_WITH_REPL=ON \
-DFUN_WITH_LIBSQL=ON \
-DFUN_WITH_SQLITE=ON \
-DFUN_WITH_CURL=ON \
-DFUN_WITH_PCRE2=ON \
-DFUN_WITH_XML2=ON \
-DFUN_WITH_JSON=ON \
-DFUN_WITH_TCLTK=ON \
-DFUN_WITH_INI=ON \
-DFUN_WITH_NOTCURSES=ON \
-DFUN_WITH_CPP=ON \
-DFUN_WITH_OPENSSL=ON \
-DFUN_WITH_LIBRESSL=ON \
&& cmake --build build --target fun
elif [ "$target" = "all_debug" ]; then
rm -rf build \
&& cmake -S . -B build \
-DFUN_WITH_PCSC=ON \
-DFUN_WITH_REPL=ON \
-DFUN_WITH_LIBSQL=ON \
-DFUN_WITH_SQLITE=ON \
-DFUN_WITH_CURL=ON \
-DFUN_WITH_PCRE2=ON \
-DFUN_WITH_XML2=ON \
-DFUN_WITH_JSON=ON \
-DFUN_WITH_TCLTK=ON \
-DFUN_WITH_INI=ON \
-DFUN_WITH_NOTCURSES=ON \
-DFUN_WITH_CPP=ON \
-DFUN_WITH_OPENSSL=ON \
-DFUN_DEBUG=ON \
@ -57,7 +50,6 @@ elif [ "$target" = "alpine" ]; then
rm -rf build \
&& cmake -S . -B build \
-DFUN_WITH_REPL=ON \
-DFUN_WITH_LIBSQL=ON \
-DFUN_WITH_SQLITE=ON \
-DFUN_WITH_CURL=ON \
-DFUN_WITH_PCRE2=ON \
@ -72,15 +64,12 @@ elif [ "$target" = "cpp_all" ]; then
&& cmake -S . -B build \
-DFUN_WITH_PCSC=ON \
-DFUN_WITH_REPL=ON \
-DFUN_WITH_LIBSQL=ON \
-DFUN_WITH_SQLITE=ON \
-DFUN_WITH_CURL=ON \
-DFUN_WITH_PCRE2=ON \
-DFUN_WITH_XML2=ON \
-DFUN_WITH_JSON=ON \
-DFUN_WITH_TCLTK=ON \
-DFUN_WITH_INI=ON \
-DFUN_WITH_NOTCURSES=ON \
-DFUN_WITH_CPP=ON \
-DFUN_WITH_OPENSSL=ON \
&& cmake --build build --target fun
@ -128,13 +117,11 @@ elif [ "$target" = "rust_all" ]; then
&& cmake -S . -B build \
-DFUN_WITH_PCSC=ON \
-DFUN_WITH_REPL=ON \
-DFUN_WITH_LIBSQL=ON \
-DFUN_WITH_SQLITE=ON \
-DFUN_WITH_CURL=ON \
-DFUN_WITH_PCRE2=ON \
-DFUN_WITH_XML2=ON \
-DFUN_WITH_JSON=ON \
-DFUN_WITH_TCLTK=ON \
-DFUN_WITH_INI=ON \
-DFUN_WITH_RUST=ON \
-DFUN_WITH_CPP=ON \

View file

@ -69,7 +69,6 @@
#include "external/pcre2.c"
#include "external/pcsc.c"
#include "external/sqlite.c"
#include "external/tcltk.c"
#include "external/xml2.c"
/* forward declarations for include mapping used in error reporting */
@ -845,17 +844,7 @@ void vm_run(VM *vm, Bytecode *entry) {
#endif
/* Tk (Tcl/Tk) ops */
#ifdef FUN_WITH_TCLTK
#include "vm/tk/bind.c"
#include "vm/tk/button.c"
#include "vm/tk/eval.c"
#include "vm/tk/label.c"
#include "vm/tk/loop.c"
#include "vm/tk/pack.c"
#include "vm/tk/result.c"
#include "vm/tk/wm_title.c"
#endif
/* Tcl/Tk support removed */
/* Notcurses TUI ops removed */