aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt31
-rw-r--r--TODO.org4
-rw-r--r--flake.lock19
-rw-r--r--flake.nix16
-rw-r--r--spec/main.cpp2
-rw-r--r--src/LuaRuntime.cpp41
6 files changed, 101 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 66a1bdf..c4edca2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,11 +11,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(AUTOMOC ON)
find_package(PkgConfig REQUIRED)
+# Source
file(GLOB_RECURSE SOURCE_FILES src/*.cpp)
list(FILTER SOURCE_FILES EXCLUDE REGEX "src/main.cpp$")
file(GLOB_RECURSE HEADER_FILES include/*.hpp)
file(GLOB_RECURSE SPEC_FILES spec/*.cpp)
+# project
add_executable(${PROJECT})
target_sources(${PROJECT} PRIVATE src/main.cpp ${SOURCE_FILES})
target_include_directories(${PROJECT} PRIVATE include/)
@@ -35,22 +37,35 @@ pkg_check_modules(LuaJIT REQUIRED luajit)
target_include_directories(${PROJECT} PRIVATE ${LuaJIT_INCLUDE_DIRS})
target_link_libraries(${PROJECT} ${LuaJIT_LINK_LIBRARIES})
-# CEF (experiment)
-# set(CEF_PACKAGE_PATH "$ENV{CEF_PACKAGE_PATH}")
-# message(STATUS "CEF path: ${CEF_PACKAGE_PATH}")
-# include_directories(${CEF_PACKAGE_PATH} ${CEF_PACKAGE_PATH}/include)
-# link_directories(${CEF_PACKAGE_PATH}/lib)
+# LibUV
+pkg_check_modules(LibUV REQUIRED libuv)
+target_include_directories(${PROJECT} PRIVATE ${LibUV_INCLUDE_DIRS})
+target_link_libraries(${PROJECT} ${LibUV_LINK_LIBRARIES})
+# Lua.LUV
+pkg_check_modules(LuaLUV REQUIRED libluv)
+target_include_directories(${PROJECT} PRIVATE ${LuaLUV_INCLUDE_DIRS})
+target_link_libraries(${PROJECT} ${LuaLUV_LINK_LIBRARIES})
+
+
+# Testing
enable_testing()
add_executable(tests)
target_sources(tests PRIVATE ${SOURCE_FILES} ${MOC_SRCS} ${SPEC_FILES})
-target_include_directories(tests PRIVATE include/ spec/ ${LuaJIT_INCLUDE_DIRS})
+target_include_directories(tests PRIVATE
+ include/
+ spec/
+ ${LuaJIT_INCLUDE_DIRS}
+ ${LibUV_INCLUDE_DIRS}
+ ${LuaLUV_INCLUDE_DIRS})
target_link_libraries(tests PRIVATE
Qt6::Core
Qt6::Widgets
Qt6::WebEngineWidgets
Qt6::Test
- ${LuaJIT_LINK_LIBRARIES})
-add_test(NAME InputLineSpec COMMAND tests)
+ ${LuaJIT_LINK_LIBRARIES}
+ ${LibUV_LINK_LIBRARIES}
+ ${LuaLUV_LINK_LIBRARIES})
+add_test(NAME MyTests COMMAND tests)
install(TARGETS ${PROJECT} RUNTIME DESTINATION bin)
diff --git a/TODO.org b/TODO.org
index f91163e..b282cc7 100644
--- a/TODO.org
+++ b/TODO.org
@@ -1,10 +1,12 @@
** Current
-- [ ] Process spawning lua (+ stdio)
+- [X] Process spawning lua (+ stdio)
- [ ] Keybindings (lua api)
- [ ] Tab history navigation
- [ ] Press tab for fill highlighted item in completion
- [ ] Assign ID to each tab (reference in lua api)
- [ ] Multi-window
+- [ ] Fix segfault on quit
+- [ ] event loop for async work
** Next
- [ ] Modal keys
diff --git a/flake.lock b/flake.lock
index 68e20ed..69ba234 100644
--- a/flake.lock
+++ b/flake.lock
@@ -18,6 +18,24 @@
"type": "github"
}
},
+ "lua-luv-source": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1738768796,
+ "narHash": "sha256-E75DkNBmyLTq9vw3o6CxiTBATMLJmBvTGPTt+bvbloA=",
+ "ref": "refs/heads/master",
+ "rev": "ec4185f98209d5e5cf96885ab126d4c2a26dfaa9",
+ "revCount": 1390,
+ "submodules": true,
+ "type": "git",
+ "url": "https://github.com/luvit/luv"
+ },
+ "original": {
+ "submodules": true,
+ "type": "git",
+ "url": "https://github.com/luvit/luv"
+ }
+ },
"nixpkgs": {
"locked": {
"lastModified": 1741037377,
@@ -37,6 +55,7 @@
"root": {
"inputs": {
"flake-utils": "flake-utils",
+ "lua-luv-source": "lua-luv-source",
"nixpkgs": "nixpkgs"
}
},
diff --git a/flake.nix b/flake.nix
index 3d3f774..c972857 100644
--- a/flake.nix
+++ b/flake.nix
@@ -2,17 +2,25 @@
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
+
+ lua-luv-source = {
+ url = "git+https://github.com/luvit/luv?submodules=1";
+ flake = false;
+ };
};
- outputs = { self, nixpkgs, flake-utils, ... }:
+ outputs = { self, nixpkgs, flake-utils, lua-luv-source, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
+
dependencies = with pkgs; [
- pkg-config
qt6.full
qt6.qtbase
luajit
+ libuv
+ luajitPackages.libluv
+ luajitPackages.luv
# libcef
# nss
];
@@ -23,7 +31,7 @@
src = ./.;
buildInputs = dependencies;
- nativeBuildInputs = with pkgs; [ cmake qt6.wrapQtAppsHook ];
+ nativeBuildInputs = with pkgs; [ cmake qt6.wrapQtAppsHook pkg-config ];
};
devShells.default = pkgs.mkShell rec {
@@ -31,6 +39,8 @@
cmake
gnumake
clang-tools
+ pkg-config
+ # vcpkg
] ++ dependencies;
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath buildInputs}";
diff --git a/spec/main.cpp b/spec/main.cpp
index 352ecba..f238e70 100644
--- a/spec/main.cpp
+++ b/spec/main.cpp
@@ -4,5 +4,7 @@
int main(int argc, char **argv) {
QApplication app(argc, argv);
+ printf("foobar");
+
return runAllTests();
}
diff --git a/src/LuaRuntime.cpp b/src/LuaRuntime.cpp
index e4a5289..e66c591 100644
--- a/src/LuaRuntime.cpp
+++ b/src/LuaRuntime.cpp
@@ -2,9 +2,22 @@
#include "LuaRuntime.hpp"
+extern "C" {
+#include <luv.h>
+// Forward declare luv registration function
+// LUALIB_API int luaopen_luv(lua_State *L);
+}
+
LuaRuntime::LuaRuntime() {
state = luaL_newstate();
luaL_openlibs(state);
+ luaopen_luv(state);
+
+ if (luaL_dostring(state, "_G.uv = require'luv'")) {
+ qDebug() << "Unable to load luv: " << lua_tostring(state, -1);
+ } else {
+ qDebug() << "succ";
+ }
luaL_Reg weblib[] = {
{"open", &LuaRuntime::lua_onUrlOpen},
@@ -13,6 +26,34 @@ LuaRuntime::LuaRuntime() {
};
luaL_newlib(state, weblib);
lua_setglobal(state, "web");
+
+ // auto pp = R"(
+ // print('Hello -- ');
+ // local h = uv.fs_open('foobar', 'w', tonumber('644', 8), function(err, h)
+ // assert(not err, err);
+ // print('inside');
+ // print(h);
+ // print(err);
+ // uv.fs_write(h, 'Hello world');
+ // end);
+ // print(h);
+ // uv.run();
+ // print('-- end');
+ // )";
+ // auto pp = R"(
+ // print('Hello -- ');
+ // local t = uv.new_timer();
+ // uv.timer_start(t, 7000, 0, function()
+ // print('after time')
+ // end);
+ // uv.run();
+ // print('-- end');
+ // )";
+ // if (luaL_dostring(state, pp)) {
+ // qDebug() << "Lua Error: " << lua_tostring(state, -1);
+ // } else {
+ // qDebug() << "succ";
+ // }
}
void LuaRuntime::evaluate(QString code) {