mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-20 15:12:37 +00:00
resize_screen_buffers() moves the storage of the source history buffer into the result, both when reusing unchanged lines and in the same size fast path. Replace the global used to opt out of this with an explicit HistoryResizeMode argument so callers that must keep their history (HistoryBuf.rewrap) state it, and make the same size fast path copy rather than steal in that mode. Document that nothing may fail after the history has been consumed.
37 lines
1.1 KiB
C
37 lines
1.1 KiB
C
/*
|
|
* resize.h
|
|
* Copyright (C) 2024 Kovid Goyal <kovid at kovidgoyal.net>
|
|
*
|
|
* Distributed under terms of the GPL3 license.
|
|
*/
|
|
|
|
#pragma once
|
|
#include "line-buf.h"
|
|
#include "history.h"
|
|
|
|
typedef struct TrackCursor {
|
|
index_type x, y;
|
|
index_type dest_x, dest_y;
|
|
bool is_sentinel;
|
|
} TrackCursor;
|
|
|
|
typedef struct ResizeResult {
|
|
LineBuf *lb;
|
|
HistoryBuf *hb;
|
|
bool ok;
|
|
index_type num_content_lines_before, num_content_lines_after;
|
|
} ResizeResult;
|
|
|
|
typedef enum HistoryResizeMode {
|
|
// hb is never modified
|
|
HISTORY_PRESERVE,
|
|
// on success the storage of hb may be moved into the result, leaving hb
|
|
// empty, so hb must be discarded. On failure hb is left untouched.
|
|
HISTORY_CONSUME,
|
|
// as HISTORY_CONSUME but never reuse unchanged lines, used in tests
|
|
HISTORY_CONSUME_NO_REUSE,
|
|
} HistoryResizeMode;
|
|
|
|
ResizeResult
|
|
resize_screen_buffers(LineBuf *lb, HistoryBuf *hb, HistoryResizeMode hb_mode, index_type lines, index_type columns, ANSIBuf *as_ansi_buf, TrackCursor *cursors);
|
|
ResizeResult resize_screen_buffer_without_rewrap(LineBuf *lb, index_type lines, index_type columns, TrackCursor *cursors);
|