Skip to content

Commit

Permalink
Changes to work with pragtical luajit
Browse files Browse the repository at this point in the history
  • Loading branch information
jgmdev committed Aug 10, 2023
1 parent c13d382 commit 0c2f4df
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 28 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ jobs:
git tag -f continuous
git push -f origin refs/tags/continuous
gh release delete -y continuous || true; gh release create -p -t 'Continuous Release' continuous *.so *.dll
if [[ `git tag --points-at HEAD | head -c 1` == "v" ]]; then
if git tag --points-at HEAD | tail -n1 | grep "^v"; then
gh release delete -y v$VERSION || true;
gh release create -t v$VERSION v$VERSION *.so *.dll
gh release delete -y latest || true;
gh release create -t latest latest *.so *.dll
fi
build_macos:
permissions: write-all
needs: build_linux_windows
runs-on: macos-11
env:
Expand All @@ -55,7 +56,7 @@ jobs:
BIN=libterminal.x86_64-darwin.so ./build.sh -DLIBTERMINAL_VERSION='"'$VERSION-x86_64-darwin'"'
BIN=libterminal.aarch64-darwin.so CC=clang CFLAGS="-arch arm64" ./build.sh -DLIBTERMINAL_VERSION='"'$VERSION-x86_64-darwin'"'
gh release upload continuous *.so
if [[ `git tag --points-at HEAD | head -c 1` == "v" ]]; then
if git tag --points-at HEAD | tail -n1 | grep "^v"; then
gh release upload v$VERSION *.so
gh release upload latest *.so
git branch -f latest HEAD
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (c) 2023 lite-xl Team
Copyright (c) 2023 Pragtical Team

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand All @@ -17,4 +18,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# lite-xl-terminal
# pragtical-terminal

`lite-xl-terminal` is a (mostly) fully-featured terminal emulator designed to slot into lite-xl as a plugin for windows (Windows 10+ only), mac and linux.
`pragtical-terminal` is a (mostly) fully-featured terminal emulator designed to slot into pragtical as a plugin for windows (Windows 10+ only), mac and linux.

![image](https://github.com/adamharrison/lite-xl-terminal/assets/1034518/6b8003da-d4c1-4227-8fc9-3d2b1ae89bf2)


## Installation

The easiest way to install `lite-xl-terminal` is to use [`lpm`](https://github.com/lite-xl/lite-xl-plugin-manager), and
The easiest way to install `pragtical-terminal` is to use [`ppm`](https://github.com/pragtical/plugin-manager), and
then run the following command:

```
lpm add https://github.com/adamharrison/lite-xl-terminal.git && lpm install terminal
ppm add https://github.com/pragtical/terminal.git && ppm install terminal
```

If you want to simply try it out, you can use `lpm`'s `run` command:
If you want to simply try it out, you can use `ppm`'s `run` command:

```
lpm run https://github.com/adamharrison/lite-xl-terminal.git terminal
ppm run https://github.com/pragtical/terminal.git terminal
```

If you want to grab it directly, and build it from the repo, you can do:

```
git clone --depth=1 https://github.com/adamharrison/lite-xl-terminal.git --recurse-submodules --shallow-submodules
cd lite-xl-terminal && ./build.sh && cp -R plugins/terminal ~/.config/lite-xl/plugins && cp libterminal.so ~/.config/lite-xl/plugins/terminal
git clone --depth=1 https://github.com/pragtical/terminal.git --recurse-submodules --shallow-submodules
cd terminal && ./build.sh && cp -R plugins/terminal ~/.config/pragtical/plugins && cp libterminal.so ~/.config/pragtical/plugins/terminal
```

Until we're released.
Expand Down
10 changes: 5 additions & 5 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"addons": [{
"id": "terminal",
"description": "An integrated terminal for lite-xl.",
"description": "An integrated terminal for pragtical.",
"version": "0.9",
"path": "plugins/terminal",
"files": [{
"url": "https://github.com/adamharrison/lite-xl-terminal/releases/download/latest/libterminal.x86_64-linux.so",
"url": "https://github.com/pragtical/terminal/releases/download/latest/libterminal.x86_64-linux.so",
"arch": "x86_64-linux",
"checksum": "SKIP"
}, {
"url": "https://github.com/adamharrison/lite-xl-terminal/releases/download/latest/libterminal.x86_64-darwin.so",
"url": "https://github.com/pragtical/terminal/releases/download/latest/libterminal.x86_64-darwin.so",
"arch": "x86_64-darwin",
"checksum": "SKIP"
}, {
"url": "https://github.com/adamharrison/lite-xl-terminal/releases/download/latest/libterminal.aarch64-darwin.so",
"url": "https://github.com/pragtical/terminal/releases/download/latest/libterminal.aarch64-darwin.so",
"arch": "aarch64-darwin",
"checksum": "SKIP"
}, {
"url": "https://github.com/adamharrison/lite-xl-terminal/releases/download/latest/libterminal.x86_64-windows.dll",
"url": "https://github.com/pragtical/terminal/releases/download/latest/libterminal.x86_64-windows.dll",
"arch": "x86_64-windows",
"checksum": "SKIP"
}]
Expand Down
27 changes: 16 additions & 11 deletions plugins/terminal/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,24 @@ function TerminalView:set_target_size(axis, value)
end

function TerminalView:convert_color(int, target)
local attributes = int >> 24
local type = (attributes & 0x7)
local attributes = bit.rshift(int, 24)
local type = bit.band(attributes, 0x7)
if type == 0 then
if target == "foreground" then return self.options.text, attributes end
return self.options.background, attributes
elseif type == 1 then
if target == "foreground" then return self.options.background, attributes end
return self.options.text, attributes
elseif type == 2 then
local index = (int >> 16) & 0xFF
return self.options.colors[index], attributes
local index = bit.band(bit.rshift(int, 16), 0xFF)
return self.options.colors[tonumber(index)], attributes
elseif type == 3 then
return { ((int >> 16) & 0xFF), ((int >> 8) & 0xFF), ((int >> 0) & 0xFF), 255 }, attributes
return {
tonumber(bit.band(bit.rshift(int, 16), 0xFF)),
tonumber(bit.band(bit.rshift(int, 8), 0xFF)),
tonumber(bit.band(bit.rshift(int, 0), 0xFF)),
255
}, attributes
end
return nil
end
Expand Down Expand Up @@ -199,9 +204,10 @@ function TerminalView:draw()
end
local offset = 0
for i = 1, #line, 2 do
local background, style = self:convert_color(line[i] & 0xFFFFFFFF, "background")
line[i] = math.tointeger(line[i])
local background, style = self:convert_color(bit.band(line[i], 0xFFFFFFFF), "background")
local text = line[i+1]
local font = (((style >> 3) & 0x1) ~= 0) and self.options.bold_font or self.options.font
local font = (bit.band(bit.rshift(style, 3), 0x1) ~= 0) and self.options.bold_font or self.options.font
local width = font:get_width(text)
if background and background ~= self.options.background then
renderer.draw_rect(x, y, width, lh, background)
Expand Down Expand Up @@ -230,9 +236,9 @@ function TerminalView:draw()
end
end
for i = 1, #line, 2 do
local foreground, style = self:convert_color(line[i] >> 32, "foreground")
local foreground, style = self:convert_color(bit.rshift(line[i], 32), "foreground")
local text = line[i+1]
local font = (((style >> 3) & 0x1) ~= 0) and self.options.bold_font or self.options.font
local font = (bit.band(bit.rshift(style, 3), 0x1) ~= 0) and self.options.bold_font or self.options.font
local length = text:ulen()
x = renderer.draw_text(font, text, x, y, foreground)
offset = offset + length
Expand Down Expand Up @@ -464,6 +470,7 @@ end, {
command.add(nil, {
["terminal:toggle"] = function()
if not view then
system.chdir(core.root_project().path)
view = TerminalView(config.plugins.terminal)
core.terminal_view = view
local node = core.root_view:get_active_node()
Expand Down Expand Up @@ -591,5 +598,3 @@ keymap.add {
return {
class = TerminalView
}


4 changes: 3 additions & 1 deletion src/libterminal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,9 @@ static void output_line(lua_State* L, buffer_char_t* start, buffer_char_t* end)
((uint64_t)style.background.g << 8) |
((uint64_t)style.background.b << 0)
);
lua_pushinteger(L, packed);
char hex_string[24];
sprintf(hex_string, "%lu", packed);
lua_pushstring(L, hex_string);
lua_rawseti(L, -2, ++group);
lua_pushlstring(L, text_buffer, block_size);
lua_rawseti(L, -2, ++group);
Expand Down

0 comments on commit 0c2f4df

Please sign in to comment.