Skip to content

Commit

Permalink
Merge branch 'main' into feat-command-line-editing-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesmithgh committed Aug 20, 2024
2 parents 4b92b1c + 3f430ff commit 565171f
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 92 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- 'stable' # v0.10.0
- 'nightly'
kitty_version:
- 'stable' # 0.34.1
- 'stable' # 0.36.+
- 'nightly'
# update __branch-protection-rules.json and run __update_branch_protection_rules.sh when modified
# test all version of nvim released as of v0.9.0
Expand All @@ -52,6 +52,10 @@ jobs:
kitty_version: '0.32.2'
- nvim_version: 'stable'
kitty_version: '0.33.1'
- nvim_version: 'stable'
kitty_version: '0.34.1'
- nvim_version: 'stable'
kitty_version: '0.35.2'
fail-fast: false
runs-on: ubuntu-22.04
steps:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [5.0.1](https://github.com/mikesmithgh/kitty-scrollback.nvim/compare/v5.0.0...v5.0.1) (2024-08-20)


### Bug Fixes

* defer setting 'columns' to hardwrap at 300 columns ([#267](https://github.com/mikesmithgh/kitty-scrollback.nvim/issues/267)) ([2f267c3](https://github.com/mikesmithgh/kitty-scrollback.nvim/commit/2f267c315bea50cd67ea3fd23f78e586fb2915c5))

# [5.0.0](https://github.com/mikesmithgh/kitty-scrollback.nvim/compare/v4.3.6...v5.0.0) (2024-06-07)


Expand Down
2 changes: 1 addition & 1 deletion lua/kitty-scrollback/backport/backport-sha.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"runtime/lua/vim/_system.lua": "691140fdecfa0c3dd28bd68505a47941c26fdf7efb9bfcd72d338e0cb59fe466",
"runtime/lua/vim/version.lua": "a5308820de020cb21e23109a5c03a338547660f9b677509f5129b337079bd453"
"runtime/lua/vim/version.lua": "6d5b925c8af9ad769c6a19e89319a8ad12def13a4184135f490a3b0cb0add4ef"
}
4 changes: 2 additions & 2 deletions lua/kitty-scrollback/backport/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local M = {}
local function backport_version()
if type(vim.version().__tostring) ~= 'function' then
-- NOTE: copied __tostring from
-- https://github.com/neovim/neovim/blob/8ba552bd59b0ed9f316ad1473126b603f35c912a/runtime/lua/vim/version.lua#L125
-- https://github.com/neovim/neovim/blob/0d3f2c4904d552635da07a6e2b4e75520b514940/runtime/lua/vim/version.lua#L125

local Version = {}
function Version:__tostring()
Expand All @@ -27,7 +27,7 @@ local function backport_version()
end

-- NOTE: copied setmetatable from
-- https://github.com/neovim/neovim/blob/8ba552bd59b0ed9f316ad1473126b603f35c912a/runtime/lua/vim/version.lua#L451
-- https://github.com/neovim/neovim/blob/0d3f2c4904d552635da07a6e2b4e75520b514940/runtime/lua/vim/version.lua#L455
setmetatable(vim.version, {
--- Returns the current Nvim version.
---@return vim.Version
Expand Down
23 changes: 22 additions & 1 deletion lua/kitty-scrollback/kitty_commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ local function get_scrollback_cmd(get_text_args)
return scrollback_cmd, full_cmd
end

local function defer_resize_term(min_cols)
local orig_columns = vim.o.columns
if vim.o.columns < min_cols then
vim.defer_fn(function()
vim.o.columns = min_cols
vim.api.nvim_set_option_value('columns', min_cols, { scope = 'global' })
end, 0)
end
return orig_columns
end

---@param get_text_opts KsbKittyGetTextArguments
---@param on_exit_cb function
M.get_text_term = function(get_text_opts, on_exit_cb)
Expand All @@ -60,9 +71,14 @@ M.get_text_term = function(get_text_opts, on_exit_cb)
local stderr
local tail_max = 10

-- increase the number of columns temporary so that the width is used during the
-- terminal command kitty @ get-text. this avoids hard wrapping lines to the
-- current window size. Note: a larger min_cols appears to impact performance
-- defer is used as a timing workaround because this is expected to be called right before termopen
p.orig_columns = defer_resize_term(300)

-- set the shell used for termopen to sh to avoid imcompatabiliies with other shells (e.g., nushell, fish, etc)
vim.o.shell = 'sh'

local success, error = pcall(vim.fn.termopen, full_cmd, {
stdout_buffered = true,
stderr_buffered = true,
Expand All @@ -73,6 +89,11 @@ M.get_text_term = function(get_text_opts, on_exit_cb)
stderr = data
end,
on_exit = function(id, exit_code, event)
-- NOTE(#58): nvim v0.9 support
-- vim.o.columns is resized automatically in nvim v0.9.1 when we trigger kitty so send a SIGWINCH signal
-- vim.o.columns is explicitly set to resize appropriatley on v0.9.0
-- see https://github.com/neovim/neovim/pull/23503
vim.o.columns = p.orig_columns
if exit_code == 0 then
-- no need to check allow_remote_control or dev/tty because earlier commands would have reported the error
if #stdout >= 2 then
Expand Down
14 changes: 0 additions & 14 deletions lua/kitty-scrollback/launch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -389,22 +389,8 @@ M.launch = function()

ksb_autocmds.load_autocmds()

-- increase the number of columns temporary so that the width is used during the
-- terminal command kitty @ get-text. this avoids hard wrapping lines to the
-- current window size. Note: a larger min_cols appears to impact performance
local min_cols = 300
p.orig_columns = vim.o.columns
if vim.o.columns < min_cols then
vim.o.columns = min_cols
end
vim.schedule(function()
ksb_kitty_cmds.get_text_term(get_text_opts(), function()
-- NOTE(#58): nvim v0.9 support
-- vim.o.columns is resized automatically in nvim v0.9.1 when we trigger kitty so send a SIGWINCH signal
-- vim.o.columns is explicitly set to resize appropriatley on v0.9.0
-- see https://github.com/neovim/neovim/pull/23503
vim.o.columns = p.orig_columns

ksb_kitty_cmds.signal_winchanged_to_kitty_child_process()
if opts.kitty_get_text.extent == 'screen' or opts.kitty_get_text.extent == 'all' then
set_cursor_position(p.kitty_data)
Expand Down
4 changes: 3 additions & 1 deletion scripts/internal/__branch-protection-rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"plenary (v0.9.0, stable)",
"plenary (v0.9.5, stable)",
"plenary (stable, 0.32.2)",
"plenary (stable, 0.33.1)"
"plenary (stable, 0.33.1)",
"plenary (stable, 0.34.1)",
"plenary (stable, 0.35.2)"
]
},
"enforce_admins": false,
Expand Down
44 changes: 22 additions & 22 deletions tests/bashrc
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# thanks https://github.com/kalgynirae/dotfiles/blob/1203030bd44448088c4c1a42155a254171a31c4b/bashrc#L59
# Test the terminal's text/color capabilities
colortest() {
local color escapes intensity style
echo "NORMAL bold dim itali under rever strik BRIGHT bold dim itali under rever strik"
for color in $(seq 0 7); do
for intensity in 3 9; do # normal, bright
escapes="${intensity}${color}"
printf '\e[%sm\\e[%sm\e[0m ' "$escapes" "$escapes" # normal
for style in 1 2 3 4 7 9; do # bold, dim, italic, underline, reverse, strikethrough
escapes="${intensity}${color};${style}"
printf '\e[%sm\\e[%sm\e[0m ' "$escapes" "$style"
done
echo -n " "
done
echo
done
echo -n "TRUECOLOR "
awk 'BEGIN{
local color escapes intensity style
echo "NORMAL bold dim itali under rever strik BRIGHT bold dim itali under rever strik"
for color in $(seq 0 7); do
for intensity in 3 9; do # normal, bright
escapes="${intensity}${color}"
printf '\e[%sm\\e[%sm\e[0m ' "$escapes" "$escapes" # normal
for style in 1 2 3 4 7 9; do # bold, dim, italic, underline, reverse, strikethrough
escapes="${intensity}${color};${style}"
printf '\e[%sm\\e[%sm\e[0m ' "$escapes" "$style"
done
echo -n " "
done
echo
done
echo -n "TRUECOLOR "
awk 'BEGIN{
columns = 78;
step = columns / 6;
for (hue = 0; hue<columns; hue++) {
Expand All @@ -43,17 +43,17 @@ colortest() {
}

banner() {
printf "\\033[0m\\033[38;2;167;192;128m"
cat <<EOF
printf "\\033[0m\\033[38;2;167;192;128m"
cat <<EOF
_ _ _____ _______ _______ __ __ _______ _______ ______ _____ ______ _______ _______ _ _ __ _ _ _ _____ _______
|____/ | | | \_/ ___ |______ | |_____/ | | | | |_____] |_____| | |____/ | \ | \ / | | | |
| \_ __|__ | | | ______| |_____ | \_ |_____| |_____ |_____ |_____] | | |_____ | \_ . | \_| \/ __|__ | | |
EOF
printf "\\033[0m\\n"
printf "\\033[0m\\n"
}

lolbanner() {
cat <<'EOF'
cat <<'EOF'
        _     _ _____ _______ _______ __   __     _______ _______  ______  _____                ______  _______ _______ _     _   __   _ _    _ _____ _______
        |____/    |      |       |      \_/   ___ |______ |       |_____/ |     | |      |      |_____] |_____| |       |____/    | \  |  \  /    |   |  |  |
        |    \_ __|__    |       |       |        ______| |_____  |    \_ |_____| |_____ |_____ |_____] |     | |_____  |    \_ . |  \_|   \/   __|__ |  |  |
Expand All @@ -62,7 +62,7 @@ EOF
}

ksb_tree() {
cat <<'EOF'
cat <<'EOF'
../kitty-scrollback.nvim/lua
└── kitty-scrollback
 ├── api.lua
Expand All @@ -88,7 +88,7 @@ EOF
}

loldino() {
cat <<'EOF'
cat <<'EOF'
 ______ 
( nice )
 ------ 
Expand Down
Loading

0 comments on commit 565171f

Please sign in to comment.