Files
Ebitor/Ebitor_private.h
T
Brian Holman 53bf6abdd5 Import Ebitor 0.1.1 upstream source snapshot
Original author: Pierre Sarrazin.
Source: http://sarrazip.com/dev/ebitor-0.1.1.tar.gz
Archive SHA-256: 6911a9d2ee80925622f1d82db1b77710a1f896865e63d29a04dc16489b150e83
2026-11-09 23:45:41 -07:00

106 lines
3.8 KiB
C

/* Ebitor_private.h
Copyright (C) 2021-2025 Pierre Sarrazin <http://sarrazip.com/>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _H_Ebitor_private
#define _H_Ebitor_private
#include "Ebitor.h"
#include <assert.h>
#define min(a, b) ((a) < (b) ? (a) : (b))
extern Ebitor Ebitor_instance;
void Ebitor_startCommandMode(void);
// key: Must be a printable character in 32..255.
//
void Ebitor_processPrintableChar(word key, byte cursorCol, byte cursorRow);
// Prints the edit buffer starting from firstLogicalCharOffsetToPrint and stopping
// when the end of the edit buffer or the end of the window has been reached.
// The printing starts at column 0 of firstRowToFill.
//
void Ebitor_fillTerminalToBottom(size_t firstLogicalCharOffsetToPrint, byte firstRowToFill);
// Does not move the logical cursor.
//
void Ebitor_insertChar(char c);
// Determines if the region of the text at 'regionOffset' and of the given 'regionLength'
// is entirely visible in the terminal, assuming that the cursor offset is at (cursorCol, cursorRow)
// on the terminal.
// Assumes that the region specification is valid, i.e., it is within the filled buffer.
// Assumes that the insert buffer is empty.
//
// *homeOffset gets filled by Ebitor_getLogicalOffsetAtHome().
// Returns -1 if region is (entirely or partly) before displayed text (*firstOffWindowOffset does NOT get filled).
// Returns +1 if region is (entirely or partly) after displayed text (*firstOffWindowOffset gets filled).
// Returns 0 if region is entirely in the displayed text (*firstOffWindowOffset gets filled).
//
char Ebitor_isRegionVisible(size_t regionOffset, size_t regionLength, byte cursorCol, byte cursorRow,
size_t *homeOffset, size_t *firstOffWindowOffset);
// firstOffWindowOffset: Must designate a position that would be displayed at the start of a window row.
//
size_t Ebitor_countRowsToScrollUp(size_t logicalOffsetToShow, size_t firstOffWindowOffset);
// Stores in *logicalOffsetAtStartOfTermRow the number rows by which the terminal
// must be scrolled down to show the given logical offset (logicalOffsetToShow) in the first row.
// homeOffset: Value obtained from Ebitor_getLogicalOffsetAtHome().
//
size_t Ebitor_countRowsToScrollDown(size_t logicalOffsetToShow, size_t homeOffset,
size_t *logicalOffsetAtStartOfTermRow);
void Ebitor_processBackspace(byte cursorCol, byte cursorRow);
// solOffset: Must be the start of the edit buffer or be preceded by an EOL terminator.
// Returns solOffset itself if no previous line.
//
size_t Ebitor_findPreviousSOL(size_t solOffset);
// firstLogicalCharOffsetToPrint: Must designate a character that is to appear at the start of a terminal row.
//
void Ebitor_fillWindowFromHomeToRow(size_t firstLogicalCharOffsetToPrint, byte numRowsToFill);
// startOfRowOffset: Logical offset of a character that is in column 0.
// Returns the logical offset of another character down the text that is also in column 0.
// If there are not enough rows, stops at the last row.
//
size_t Ebitor_goDownRows(size_t startOfRowOffset, size_t numRows);
void Ebitor_locateAndSavePos(byte col, byte row);
#endif /* _H_Ebitor_private */