Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 12 additions & 28 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@ jobs:
include:
- name: linux
os: ubuntu-latest
archive: nslite-linux.tar.gz
- name: macos
os: macos-latest
archive: nslite-macos.tar.gz
- name: windows
os: windows-latest
archive: nslite-windows.zip

steps:
- uses: actions/checkout@v6
Expand All @@ -49,8 +46,7 @@ jobs:
libxkbcommon-dev \
libxrandr-dev \
libxss-dev \
libxtst-dev \
patchelf
libxtst-dev

- name: Configure
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
Expand All @@ -66,11 +62,6 @@ jobs:
mkdir -p "$app_dir"
cp build/nsl "$app_dir/"
cp -a data "$app_dir/data"
sdl_library="$(find build -type f -name 'libSDL3.so*' -print -quit)"
test -n "$sdl_library"
cp -a "$(dirname "$sdl_library")"/libSDL3.so* "$app_dir/"
patchelf --set-rpath '$ORIGIN' "$app_dir/nsl"
tar -C dist -czf nslite-linux.tar.gz nslite-linux

- name: Package macOS artifact
if: matrix.name == 'macos'
Expand All @@ -79,16 +70,9 @@ jobs:
app_dir="dist/nslite-macos"
mkdir -p "$app_dir"
binary="$(find build -type f -name nsl -perm -111 -print -quit)"
sdl_library="$(find build -type f -name 'libSDL3*.dylib' -print -quit)"
test -n "$binary"
test -n "$sdl_library"
cp "$binary" "$app_dir/nsl"
cp "$sdl_library" "$app_dir/"
cp -R data "$app_dir/data"
sdl_reference="$(otool -L "$app_dir/nsl" | awk '/SDL3/{print $1; exit}')"
install_name_tool -change "$sdl_reference" "@rpath/$(basename "$sdl_library")" "$app_dir/nsl"
install_name_tool -add_rpath '@loader_path' "$app_dir/nsl"
tar -C dist -czf nslite-macos.tar.gz nslite-macos

- name: Package Windows artifact
if: matrix.name == 'windows'
Expand All @@ -97,18 +81,15 @@ jobs:
$appDir = 'dist/nslite-windows'
New-Item -ItemType Directory -Force -Path $appDir | Out-Null
$binary = Get-ChildItem -Path build -Filter nsl.exe -Recurse | Select-Object -First 1
$sdlLibrary = Get-ChildItem -Path build -Filter SDL3.dll -Recurse | Select-Object -First 1
if (-not $binary -or -not $sdlLibrary) { throw 'Built executable or SDL3 runtime was not found.' }
if (-not $binary) { throw 'Built executable was not found.' }
Copy-Item $binary.FullName $appDir
Copy-Item $sdlLibrary.FullName $appDir
Copy-Item -Recurse data "$appDir/data"
Compress-Archive -Path "$appDir/*" -DestinationPath nslite-windows.zip

- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: nslite-${{ matrix.name }}
path: ${{ matrix.archive }}
path: dist/nslite-${{ matrix.name }}
if-no-files-found: error

verify-tag-on-main:
Expand Down Expand Up @@ -145,20 +126,23 @@ jobs:
uses: actions/download-artifact@v5
with:
pattern: nslite-*
merge-multiple: true
path: release-assets

- name: Add version to asset names
- name: Create release archives
env:
TAG: ${{ needs.verify-tag-on-main.outputs.tag }}
run: |
mv release-assets/nslite-linux.tar.gz "release-assets/nslite-${TAG}-linux.tar.gz"
mv release-assets/nslite-macos.tar.gz "release-assets/nslite-${TAG}-macos.tar.gz"
mv release-assets/nslite-windows.zip "release-assets/nslite-${TAG}-windows.zip"
mkdir -p dist
# artifacts travel as zips, which carry no unix permissions, so the
# executable bit has to be put back before we repack for release
chmod +x release-assets/nslite-linux/nsl release-assets/nslite-macos/nsl
tar -C release-assets -czf "dist/nslite-${TAG}-linux.tar.gz" nslite-linux
tar -C release-assets -czf "dist/nslite-${TAG}-macos.tar.gz" nslite-macos
(cd release-assets && zip -qr "../dist/nslite-${TAG}-windows.zip" nslite-windows)

- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
TAG: ${{ needs.verify-tag-on-main.outputs.tag }}
run: gh release create "$TAG" release-assets/* --title "$TAG" --generate-notes
run: gh release create "$TAG" dist/* --title "$TAG" --generate-notes
47 changes: 35 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,35 @@ if(NSLITE_USE_SYSTEM_LIBS)
set(NSLITE_GIT_INCLUDE_DIRS "")
else()
include(FetchContent)

FetchContent_Declare(
SDL3
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
GIT_TAG main
GIT_SHALLOW TRUE
)

set(SDL_SHARED ON CACHE BOOL "" FORCE)
set(SDL_STATIC OFF CACHE BOOL "" FORCE)

set(SDL_SHARED OFF CACHE BOOL "" FORCE)
set(SDL_STATIC ON CACHE BOOL "" FORCE)
set(SDL_LEAN_AND_MEAN ON CACHE BOOL "" FORCE)
set(SDL_TEST_LIBRARY OFF CACHE BOOL "" FORCE)


set(SDL_AUDIO OFF CACHE BOOL "" FORCE)
set(SDL_RENDER OFF CACHE BOOL "" FORCE)
set(SDL_GPU OFF CACHE BOOL "" FORCE)
set(SDL_CAMERA OFF CACHE BOOL "" FORCE)
set(SDL_JOYSTICK OFF CACHE BOOL "" FORCE)
set(SDL_HAPTIC OFF CACHE BOOL "" FORCE)
set(SDL_HIDAPI OFF CACHE BOOL "" FORCE)
set(SDL_SENSOR OFF CACHE BOOL "" FORCE)
# Only to compile in X11's visual selection; without GLX it forces the
# default depth-24 visual (XRGB8888, no alpha). Rendering stays software.
set(SDL_OPENGL ON CACHE BOOL "" FORCE)
set(SDL_OPENGLES OFF CACHE BOOL "" FORCE)
set(SDL_VULKAN OFF CACHE BOOL "" FORCE)
set(SDL_DBUS OFF CACHE BOOL "" FORCE)
set(SDL_LIBUDEV OFF CACHE BOOL "" FORCE)

FetchContent_MakeAvailable(SDL3)

set(BUILD_STATIC_LIBS ON CACHE BOOL "" FORCE)
Expand All @@ -60,32 +77,32 @@ else()
set(PCRE2_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(PCRE2_SUPPORT_JIT OFF CACHE BOOL "" FORCE)
set(PCRE2_SHOW_REPORT OFF CACHE BOOL "" FORCE)

FetchContent_Declare(
PCRE2
GIT_REPOSITORY https://github.com/PCRE2Project/pcre2.git
GIT_TAG pcre2-10.47
GIT_SHALLOW TRUE
)

FetchContent_MakeAvailable(PCRE2)

FetchContent_Declare(
lua
URL https://www.lua.org/ftp/lua-5.5.0.tar.gz
URL_HASH SHA256=57ccc32bbbd005cab75bcc52444052535af691789dba2b9016d5c50640d68b3d
)

FetchContent_MakeAvailable(lua)

file(GLOB LUA_SOURCES ${lua_SOURCE_DIR}/src/*.c)
list(FILTER LUA_SOURCES EXCLUDE REGEX "lua\\.c$")
list(FILTER LUA_SOURCES EXCLUDE REGEX "luac\\.c$")

add_library(lua STATIC ${LUA_SOURCES})
target_include_directories(lua PUBLIC ${lua_SOURCE_DIR}/src)
set_target_properties(lua PROPERTIES POSITION_INDEPENDENT_CODE ON)

if(UNIX AND NOT APPLE)
target_compile_definitions(lua PRIVATE LUA_USE_POSIX)
elseif(WIN32)
Expand Down Expand Up @@ -184,6 +201,12 @@ target_link_libraries(nsl PRIVATE
if(APPLE)
find_library(APPKIT_FRAMEWORK AppKit REQUIRED)
target_link_libraries(nsl PRIVATE ${APPKIT_FRAMEWORK})

# SDL_cocoamouse.m always references GCMouse, but SDL only links
# GameController when SDL_JOYSTICK is on, which we disable.
# So enjoyable to support cross OS builds :'D
find_library(GAMECONTROLLER_FRAMEWORK GameController REQUIRED)
target_link_libraries(nsl PRIVATE ${GAMECONTROLLER_FRAMEWORK})
endif()

if(UNIX)
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ all: build

build:
@mkdir -p build
@cd build && cmake $(CMAKE_FLAGS) -DCMAKE_BUILD_TYPE=Debug .. && cmake --build . --parallel 2
@cd build && cmake $(CMAKE_FLAGS) -DCMAKE_BUILD_TYPE=Debug .. && cmake --build . -j

release:
@mkdir -p build
@cd build && cmake $(CMAKE_FLAGS) -DCMAKE_BUILD_TYPE=Release .. && cmake --build . --parallel 2
@cd build && cmake $(CMAKE_FLAGS) -DCMAKE_BUILD_TYPE=Release .. && cmake --build . -j

clean:
@rm -rf build
Expand Down
27 changes: 26 additions & 1 deletion data/core/commands/core.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
local core = require "core"
local common = require "core.common"
local command = require "core.command"
local config = require "core.config"
local keymap = require "core.keymap"
local LogView = require "core.logview"
local style = require "core.style"
local LogView = require "core.presentations.log"
local TitleBarView = require "core.presentations.titlebar"
local renderer = require "renderer"


local fullscreen = false
local debug_enabled = false

command.add(nil, {
["core:quit"] = function()
Expand Down Expand Up @@ -88,6 +93,11 @@ command.add(nil, {
core.open_file(USERDIR .. PATHSEP .. "init.lua")
end,

["core:toggle-debug"] = function()
debug_enabled = not debug_enabled
renderer.show_debug(debug_enabled)
end,

["core:open-project-module"] = function()
local filename = core.project_path(".nslite_project.lua")
if system.get_file_info(filename) then
Expand All @@ -98,4 +108,19 @@ command.add(nil, {
doc:save(filename)
end
end,

["core:toggle-native-titlebar"] = function()
config.native_title_bar = not config.native_title_bar
if config.native_title_bar then
system.configure_titlebar(0, 0)
core.root_view.titlebar = nil
else
local th = style.font:get_height() + style.padding.y * 2
local bm = 30 * 3 + style.padding.x
system.configure_titlebar(th, bm)
core.root_view.titlebar = TitleBarView()
core.root_view.titlebar:set_title(core.window_title or "nslite")
end
core.redraw = true
end,
})
28 changes: 14 additions & 14 deletions data/core/commands/root.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,49 @@ local t = {
local node = core.root_view:get_active_node()
local idx = node:get_view_idx(core.active_view)
idx = idx - 1
if idx < 1 then idx = #node.views end
node:set_active_view(node.views[idx])
if idx < 1 then idx = #node.nodes end
node:set_active_view(node.nodes[idx])
end,

["root:switch-to-next-tab"] = function()
local node = core.root_view:get_active_node()
local idx = node:get_view_idx(core.active_view)
idx = idx + 1
if idx > #node.views then idx = 1 end
node:set_active_view(node.views[idx])
if idx > #node.nodes then idx = 1 end
node:set_active_view(node.nodes[idx])
end,

["root:move-tab-left"] = function()
local node = core.root_view:get_active_node()
local idx = node:get_view_idx(core.active_view)
if idx > 1 then
table.remove(node.views, idx)
table.insert(node.views, idx - 1, core.active_view)
node:del_child(idx)
node:add_child(core.active_view, idx - 1)
node:scroll_tab_into_view(core.active_view)
end
end,

["root:move-tab-right"] = function()
local node = core.root_view:get_active_node()
local idx = node:get_view_idx(core.active_view)
if idx < #node.views then
table.remove(node.views, idx)
table.insert(node.views, idx + 1, core.active_view)
if idx < #node.nodes then
node:del_child(idx)
node:add_child(core.active_view, idx + 1)
node:scroll_tab_into_view(core.active_view)
end
end,

["root:shrink"] = function()
local node = core.root_view:get_active_node()
local parent = node:get_parent_node(core.root_view.root_node)
local n = (parent.a == node) and -0.1 or 0.1
local parent = node:get_parent(core.root_view.root_node)
local n = (parent.nodes[node.LEFT] == node) and -0.1 or 0.1
parent.divider = common.clamp(parent.divider + n, 0.1, 0.9)
end,

["root:grow"] = function()
local node = core.root_view:get_active_node()
local parent = node:get_parent_node(core.root_view.root_node)
local n = (parent.a == node) and 0.1 or -0.1
local parent = node:get_parent(core.root_view.root_node)
local n = (parent.nodes[node.LEFT] == node) and 0.1 or -0.1
parent.divider = common.clamp(parent.divider + n, 0.1, 0.9)
end,
}
Expand All @@ -66,7 +66,7 @@ local t = {
for i = 1, 9 do
t["root:switch-to-tab-" .. i] = function()
local node = core.root_view:get_active_node()
local view = node.views[i]
local view = node.nodes[i]
if view then
node:set_active_view(view)
end
Expand Down
5 changes: 5 additions & 0 deletions data/core/common.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
local common = {}


function common.primary_modifier()
return PLATFORM == "macOS" and "cmd" or "ctrl"
end


function common.is_utf8_cont(char)
local byte = char:byte()
return byte >= 0x80 and byte < 0xc0
Expand Down
2 changes: 2 additions & 0 deletions data/core/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ config.indent_size = 2
config.tab_type = "soft"
config.line_limit = 80

config.native_title_bar = false

-- Language servers start lazily, the first time mod is held over a matching
-- document. Add or replace entries from user/init.lua as needed.
config.lsp = {
Expand Down
2 changes: 1 addition & 1 deletion data/core/doc/init.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local Object = require "core.object"
local Object = require "core.utils.object"
local syntax = require "core.syntax"
local config = require "core.config"

Expand Down
10 changes: 10 additions & 0 deletions data/core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ function core.init()
core.find_view = FindView()
core.status_view = StatusView()

-- apply borderless window when using own title bar
if not config.native_title_bar then
local th = style.font:get_height() + style.padding.y * 2
local bm = 30 * 3 + style.padding.x
system.configure_titlebar(th, bm)
end

core.root_view.root_node:split("down", core.status_view, true)
core.root_view:add_floating_view(core.command_view)
core.root_view:add_floating_view(core.find_view)
Expand Down Expand Up @@ -428,6 +435,9 @@ function core.step()
if title ~= core.window_title then
system.set_window_title(title)
core.window_title = title
if core.root_view.titlebar then
core.root_view.titlebar:set_title(title)
end
end

-- draw
Expand Down
Loading