--- lbbs/include/editor.h 2025/06/09 15:41:09 1.2 +++ lbbs/include/editor.h 2025/11/05 02:06:50 1.11 @@ -1,33 +1,27 @@ -/*************************************************************************** - editor.h - description - ------------------- - copyright : (C) 2004-2025 by Leaflet - email : leaflet@leafok.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. * - * * - ***************************************************************************/ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * editor + * - user interactive full-screen text editor + * + * Copyright (C) 2004-2025 Leaflet + */ #ifndef _EDITOR_H_ #define _EDITOR_H_ #include "screen.h" -#define MAX_EDITOR_DATA_LINES 65536 -#define MAX_EDITOR_DATA_LINE_LENGTH 1024 +enum editor_constant_t +{ + MAX_EDITOR_DATA_LINES = 65536, + MAX_EDITOR_DATA_LINE_LENGTH = 1024, +}; struct editor_data_t { - char *p_data_lines[MAX_EDITOR_DATA_LINES]; - long data_line_total; char *p_display_lines[MAX_EDITOR_DATA_LINES]; - long display_line_lengths[MAX_EDITOR_DATA_LINES]; + long display_line_lengths[MAX_EDITOR_DATA_LINES]; // string length of display line + int display_line_widths[MAX_EDITOR_DATA_LINES]; // display width of display line long display_line_total; }; typedef struct editor_data_t EDITOR_DATA; @@ -41,16 +35,19 @@ struct editor_ctx_t }; typedef struct editor_ctx_t EDITOR_CTX; +extern int editor_memory_pool_init(void); +extern void editor_memory_pool_cleanup(void); + extern EDITOR_DATA *editor_data_load(const char *p_data); extern long editor_data_save(const EDITOR_DATA *p_editor_data, char *p_data, size_t buf_len); extern void editor_data_cleanup(EDITOR_DATA *p_editor_data); extern int editor_display(EDITOR_DATA *p_editor_data); -extern int editor_data_insert(EDITOR_DATA *p_editor_data, long display_line, long offset, +extern int editor_data_insert(EDITOR_DATA *p_editor_data, long *p_display_line, long *p_offset, const char *str, int str_len, long *p_last_updated_line); -extern int editor_data_delete(EDITOR_DATA *p_editor_data, long display_line, long offset, - long *p_last_updated_line); +extern int editor_data_delete(EDITOR_DATA *p_editor_data, long *p_display_line, long *p_offset, + long *p_last_updated_line, int del_line); #endif //_EDITOR_H_