mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-02 20:53:37 +02:00
Compare commits
7 Commits
copilot/ad
...
nightly
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1d507dbe8 | ||
|
|
2b38afabce | ||
|
|
2ead860607 | ||
|
|
691a971a70 | ||
|
|
9cd2c60064 | ||
|
|
4e0f7faef8 | ||
|
|
207b22aa80 |
28
.github/workflows/ci.yml
vendored
28
.github/workflows/ci.yml
vendored
@@ -45,18 +45,18 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v6.0.3
|
||||
uses: actions/checkout@v7.0.0
|
||||
with:
|
||||
fetch-depth: 10
|
||||
persist-credentials: false
|
||||
|
||||
- name: Set up Python ${{ matrix.pyver }}
|
||||
uses: actions/setup-python@v6
|
||||
uses: actions/setup-python@v6.2.0
|
||||
with:
|
||||
python-version: ${{ matrix.pyver }}
|
||||
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v6
|
||||
uses: actions/setup-go@v6.4.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
|
||||
@@ -73,7 +73,7 @@ jobs:
|
||||
CFLAGS: -funsigned-char
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v6.0.3
|
||||
uses: actions/checkout@v7.0.0
|
||||
with:
|
||||
fetch-depth: 0 # needed for :commit: docs role
|
||||
persist-credentials: false
|
||||
@@ -85,18 +85,18 @@ jobs:
|
||||
run: if grep -Inr ':code:`\s' kitty kitty_tests kittens docs *.py *.asciidoc *.rst *.go .gitattributes .gitignore; then echo Space at code block start found, aborting.; exit 1; fi
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v6
|
||||
uses: actions/setup-python@v6.2.0
|
||||
with:
|
||||
python-version: "3.14"
|
||||
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v6
|
||||
uses: actions/setup-go@v6.4.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: false
|
||||
|
||||
- name: Cache Go build artifacts separately
|
||||
uses: actions/cache@v5
|
||||
uses: actions/cache@v5.0.5
|
||||
with:
|
||||
path: |
|
||||
~/.cache/go-build
|
||||
@@ -143,13 +143,13 @@ jobs:
|
||||
KITTY_SANITIZE: 1
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v6.0.3
|
||||
uses: actions/checkout@v7.0.0
|
||||
with:
|
||||
fetch-depth: 10
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v6
|
||||
uses: actions/setup-go@v6.4.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
|
||||
@@ -164,18 +164,18 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v6.0.3
|
||||
uses: actions/checkout@v7.0.0
|
||||
with:
|
||||
fetch-depth: 0 # needed for :commit: docs role
|
||||
persist-credentials: false
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v6
|
||||
uses: actions/setup-python@v6.2.0
|
||||
with:
|
||||
python-version: "3.14"
|
||||
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v6
|
||||
uses: actions/setup-go@v6.4.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
|
||||
@@ -202,7 +202,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v6.0.3
|
||||
uses: actions/checkout@v7.0.0
|
||||
with:
|
||||
fetch-depth: 10
|
||||
persist-credentials: false
|
||||
@@ -211,7 +211,7 @@ jobs:
|
||||
run: sudo apt-get update && sudo apt-get install -y curl xz-utils build-essential git pkg-config libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl1-mesa-dev libxkbcommon-x11-dev libfontconfig-dev libx11-xcb-dev libdbus-1-dev
|
||||
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v6
|
||||
uses: actions/setup-go@v6.4.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
|
||||
|
||||
4
.github/workflows/codeql-analysis.yml
vendored
4
.github/workflows/codeql-analysis.yml
vendored
@@ -39,7 +39,7 @@ jobs:
|
||||
steps:
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6.0.3
|
||||
uses: actions/checkout@v7.0.0
|
||||
with:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
|
||||
- name: Install Go
|
||||
if: matrix.language == 'c' || matrix.language == 'go'
|
||||
uses: actions/setup-go@v6
|
||||
uses: actions/setup-go@v6.4.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
|
||||
|
||||
4
.github/workflows/depscan.yml
vendored
4
.github/workflows/depscan.yml
vendored
@@ -22,13 +22,13 @@ jobs:
|
||||
KITTY_BUNDLE: 1
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v6.0.3
|
||||
uses: actions/checkout@v7.0.0
|
||||
with:
|
||||
fetch-depth: 10
|
||||
persist-credentials: false
|
||||
|
||||
- name: Checkout bypy
|
||||
uses: actions/checkout@v6.0.3
|
||||
uses: actions/checkout@v7.0.0
|
||||
with:
|
||||
fetch-depth: 1
|
||||
persist-credentials: false
|
||||
|
||||
@@ -196,6 +196,8 @@ Detailed list of changes
|
||||
|
||||
- ``edit-in-kitty``: Return exit code from underlying editor process on exit (:iss:`10198`)
|
||||
|
||||
- Make erasing last command robust against commands with no output and commands in the scrollback (:pull:`10201`)
|
||||
|
||||
|
||||
0.47.4 [2026-06-15]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
4
go.mod
4
go.mod
@@ -6,7 +6,7 @@ toolchain go1.26.4
|
||||
|
||||
require (
|
||||
github.com/ALTree/bigfloat v0.2.0
|
||||
github.com/alecthomas/chroma/v2 v2.26.1
|
||||
github.com/alecthomas/chroma/v2 v2.27.0
|
||||
github.com/bmatcuk/doublestar/v4 v4.10.0
|
||||
github.com/dlclark/regexp2 v1.12.0
|
||||
github.com/ebitengine/purego v0.10.1
|
||||
@@ -39,7 +39,7 @@ require (
|
||||
// replace github.com/kovidgoyal/imaging => ../imaging
|
||||
|
||||
require (
|
||||
github.com/dlclark/regexp2/v2 v2.1.1 // indirect
|
||||
github.com/dlclark/regexp2/v2 v2.2.1 // indirect
|
||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
|
||||
github.com/lufia/plan9stats v0.0.0-20230326075908-cb1d2100619a // indirect
|
||||
|
||||
8
go.sum
8
go.sum
@@ -2,8 +2,8 @@ github.com/ALTree/bigfloat v0.2.0 h1:AwNzawrpFuw55/YDVlcPw0F0cmmXrmngBHhVrvdXPvM
|
||||
github.com/ALTree/bigfloat v0.2.0/go.mod h1:+NaH2gLeY6RPBPPQf4aRotPPStg+eXc8f9ZaE4vRfD4=
|
||||
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
|
||||
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
|
||||
github.com/alecthomas/chroma/v2 v2.26.1 h1:2X21EdxGZNv5GF9mG5u+uzc02GCFyGxbcBm3Grd9A78=
|
||||
github.com/alecthomas/chroma/v2 v2.26.1/go.mod h1:lxhRRa9H4hPmRLOOdYga4zkQIQjq3dtrrdwQeCfu78Y=
|
||||
github.com/alecthomas/chroma/v2 v2.27.0 h1:FodwmyOBgJULFYmDqibcp9pvfDLWdtPRh9v/r5BXYZs=
|
||||
github.com/alecthomas/chroma/v2 v2.27.0/go.mod h1:NjJ3ciIgrqBNeIkWZ4e46nseoLDslxU1LmfCoL+wcY8=
|
||||
github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs=
|
||||
github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
|
||||
github.com/bmatcuk/doublestar/v4 v4.10.0 h1:zU9WiOla1YA122oLM6i4EXvGW62DvKZVxIe6TYWexEs=
|
||||
@@ -12,8 +12,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dlclark/regexp2 v1.12.0 h1:0j4c5qQmnC6XOWNjP3PIXURXN2gWx76rd3KvgdPkCz8=
|
||||
github.com/dlclark/regexp2 v1.12.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||
github.com/dlclark/regexp2/v2 v2.1.1 h1:LCUGyd9Wf+r+VVOl8Ny38JTpWJcAsdVnCIuhhtthmKw=
|
||||
github.com/dlclark/regexp2/v2 v2.1.1/go.mod h1:avUrQvPaLz2DrFNHJF0taWAFFX2C1GMSSoeiqFjcBmU=
|
||||
github.com/dlclark/regexp2/v2 v2.2.1 h1:mf4KkFUj0gJuarK8P+LgiS+Lit7m9N1yAwEfPbee7R0=
|
||||
github.com/dlclark/regexp2/v2 v2.2.1/go.mod h1:avUrQvPaLz2DrFNHJF0taWAFFX2C1GMSSoeiqFjcBmU=
|
||||
github.com/ebitengine/purego v0.10.1 h1:dewVBCBT2GaMu1SrNTYxQhgQBethzfhiwvZiLGP/qyY=
|
||||
github.com/ebitengine/purego v0.10.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
|
||||
github.com/emmansun/base64 v0.9.0 h1:92dLrE7iro6g/yWuPsd7M9TzJpe9fEeqKH0H7MApDtE=
|
||||
|
||||
@@ -1261,7 +1261,7 @@ class Screen:
|
||||
def test_commit_write_buffer(self, inp: memoryview, output: memoryview) -> int: ...
|
||||
def test_parse_written_data(self, dump_callback: None = None) -> None: ...
|
||||
def hyperlink_for_id(self, hyperlink_id: int) -> str: ...
|
||||
def erase_last_command(self, include_prompt: bool = True) -> bool: ...
|
||||
def erase_last_command(self) -> bool: ...
|
||||
def set_progress(self, state: int, percent: int) -> None: ...
|
||||
def mark_potential_url_drag(self) -> bool: ...
|
||||
|
||||
|
||||
@@ -4599,27 +4599,47 @@ find_cmd_output(Screen *self, OutputOffset *oo, index_type start_screen_y, unsig
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
erase_last_command(Screen *self, PyObject *args) {
|
||||
int include_prompt = 1;
|
||||
if (!PyArg_ParseTuple(args, "|p", &include_prompt)) return NULL;
|
||||
OutputOffset oo = {.screen=self};
|
||||
if (self->linebuf != self->main_linebuf || !find_cmd_output(self, &oo, self->cursor->y + self->scrolled_by, self->scrolled_by, -1, false)) Py_RETURN_FALSE;
|
||||
if (include_prompt) {
|
||||
int y = oo.start - 1; Line *line;
|
||||
while ((line = checked_range_line(self, y))) {
|
||||
oo.start--; oo.num_lines++; y--;
|
||||
if (line->attrs.prompt_kind == PROMPT_START) break;
|
||||
}
|
||||
erase_last_command(Screen *self, PyObject *args UNUSED) {
|
||||
if (self->linebuf != self->main_linebuf) Py_RETURN_FALSE;
|
||||
Line *line;
|
||||
// Erase the most recent command: the prompt block immediately above the
|
||||
// current (live) prompt, regardless of whether that command produced any
|
||||
// output. Commands without output (an empty Enter, a comment, cd, export,
|
||||
// ...) emit no OSC 133;C, so a search anchored on OUTPUT_START would skip
|
||||
// them and erase an older command instead. Selecting by prompt marks makes
|
||||
// every submitted command one unit, removed newest-first.
|
||||
int y = self->cursor->y + self->scrolled_by;
|
||||
bool found = false;
|
||||
for (; (line = checked_range_line(self, y)); y--) {
|
||||
if (line->attrs.prompt_kind == PROMPT_START) { found = true; break; }
|
||||
}
|
||||
index_type num_lines_to_erase_in_screen = oo.start >= 0 ? oo.num_lines : oo.num_lines + oo.start;
|
||||
if (!found) Py_RETURN_FALSE;
|
||||
const int live_prompt_start = y;
|
||||
found = false;
|
||||
for (y = live_prompt_start - 1; (line = checked_range_line(self, y)); y--) {
|
||||
if (line->attrs.prompt_kind == PROMPT_START) { found = true; break; }
|
||||
}
|
||||
if (!found) Py_RETURN_FALSE; // nothing above the current prompt to erase
|
||||
const int start = y;
|
||||
const index_type num_lines = (index_type)(live_prompt_start - start);
|
||||
index_type num_lines_to_erase_in_screen = start >= 0 ? num_lines : num_lines + start;
|
||||
num_lines_to_erase_in_screen = MIN(self->cursor->y, num_lines_to_erase_in_screen);
|
||||
if (num_lines_to_erase_in_screen) {
|
||||
screen_delete_lines_impl(self, self->cursor->y - num_lines_to_erase_in_screen, num_lines_to_erase_in_screen, 0, self->lines - 1);
|
||||
// Anchor the on-screen deletion at the top of the region, not at
|
||||
// cursor->y - count: a multi-line prompt or rows skipped above would
|
||||
// otherwise shift the deletion and leave residual lines on screen.
|
||||
index_type screen_erase_start = start >= 0 ? (index_type)start : 0;
|
||||
screen_delete_lines_impl(self, screen_erase_start, num_lines_to_erase_in_screen, 0, self->lines - 1);
|
||||
self->cursor->y -= num_lines_to_erase_in_screen;
|
||||
}
|
||||
if (oo.num_lines > num_lines_to_erase_in_screen) {
|
||||
index_type num_of_lines_to_erase_from_history = oo.num_lines - num_lines_to_erase_in_screen;
|
||||
historybuf_delete_newest_lines(self->historybuf, num_of_lines_to_erase_from_history);
|
||||
if (num_lines > num_lines_to_erase_in_screen) {
|
||||
historybuf_delete_newest_lines(self->historybuf, num_lines - num_lines_to_erase_in_screen);
|
||||
// The scrollback shrank: clamp the scroll position and signal a redraw,
|
||||
// otherwise the deletion of off-screen lines is not reflected until the
|
||||
// next scroll event forces the history viewport to be recomputed.
|
||||
self->scrolled_by = MIN(self->scrolled_by, self->historybuf->count);
|
||||
self->is_dirty = true;
|
||||
dirty_scroll(self);
|
||||
}
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
@@ -6221,7 +6241,7 @@ static PyMethodDef methods[] = {
|
||||
MND(draw, METH_O)
|
||||
MND(apply_sgr, METH_O)
|
||||
MND(cursor_position, METH_VARARGS)
|
||||
MND(erase_last_command, METH_VARARGS)
|
||||
MND(erase_last_command, METH_NOARGS)
|
||||
MND(set_window_char, METH_VARARGS)
|
||||
MND(set_progress, METH_VARARGS)
|
||||
MND(set_mode, METH_VARARGS)
|
||||
|
||||
@@ -1627,8 +1627,8 @@ class TestScreen(BaseTest):
|
||||
s.draw('before\r\n')
|
||||
draw_prompt('p1'), draw_output(2), mark_prompt(), s.draw('partial')
|
||||
x = s.cursor.x
|
||||
s.erase_last_command(False)
|
||||
self.ae('before\n$ p1\npartial', at().rstrip())
|
||||
s.erase_last_command()
|
||||
self.ae('before\npartial', at().rstrip())
|
||||
for scroll in (8, 9, 10):
|
||||
s.reset()
|
||||
s.draw('before'), s.carriage_return(), s.linefeed()
|
||||
@@ -1641,6 +1641,33 @@ class TestScreen(BaseTest):
|
||||
s.erase_last_command()
|
||||
self.ae(at().rstrip(), ' a b\npartial')
|
||||
|
||||
# the most recent command is erased even when it produced no output (an
|
||||
# empty Enter, a comment, cd, ...): such commands emit no OSC 133;C and
|
||||
# must not be skipped in favour of an older command-with-output.
|
||||
s = self.create_screen(cols=10, lines=12, scrollback=30)
|
||||
s.draw('before\r\n')
|
||||
draw_prompt('p1'), draw_output(2), draw_prompt('# note'), mark_prompt(), s.draw('partial')
|
||||
s.erase_last_command()
|
||||
self.ae('before\n$ p1\n0\n1\npartial', at().rstrip()) # the output-less command goes first
|
||||
s.erase_last_command()
|
||||
self.ae('before\npartial', at().rstrip()) # then the command with output
|
||||
# consecutive output-less commands are removed newest-first, one per call
|
||||
s.reset()
|
||||
s.draw('before\r\n')
|
||||
draw_prompt('p1'), draw_output(1), draw_prompt('e1'), draw_prompt('e2'), mark_prompt(), s.draw('partial')
|
||||
s.erase_last_command()
|
||||
self.ae('before\n$ p1\n0\n$ e1\npartial', at().rstrip())
|
||||
s.erase_last_command()
|
||||
self.ae('before\n$ p1\n0\npartial', at().rstrip())
|
||||
s.erase_last_command()
|
||||
self.ae('before\npartial', at().rstrip())
|
||||
# multi-line live prompt: the command region is erased with no residual
|
||||
s.reset()
|
||||
s.draw('before\r\n')
|
||||
draw_prompt('p1'), draw_output(9), mark_prompt(), s.draw('l1'), s.carriage_return(), s.index(), s.draw('partial')
|
||||
s.erase_last_command()
|
||||
self.ae('before\nl1\npartial', at().rstrip())
|
||||
|
||||
def test_pointer_shapes(self):
|
||||
from kitty.window import set_pointer_shape
|
||||
s = self.create_screen()
|
||||
|
||||
Reference in New Issue
Block a user