| 1 |
sysadm |
1.9 |
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
| 2 |
|
|
/*
|
| 3 |
|
|
* editor
|
| 4 |
|
|
* - user interactive full-screen text editor
|
| 5 |
|
|
*
|
| 6 |
sysadm |
1.10 |
* Copyright (C) 2004-2025 Leaflet <leaflet@leafok.com>
|
| 7 |
sysadm |
1.9 |
*/
|
| 8 |
sysadm |
1.1 |
|
| 9 |
|
|
#ifndef _EDITOR_H_
|
| 10 |
|
|
#define _EDITOR_H_
|
| 11 |
|
|
|
| 12 |
|
|
#include "screen.h"
|
| 13 |
|
|
|
| 14 |
|
|
#define MAX_EDITOR_DATA_LINES 65536
|
| 15 |
|
|
#define MAX_EDITOR_DATA_LINE_LENGTH 1024
|
| 16 |
|
|
|
| 17 |
|
|
struct editor_data_t
|
| 18 |
|
|
{
|
| 19 |
|
|
char *p_display_lines[MAX_EDITOR_DATA_LINES];
|
| 20 |
sysadm |
1.7 |
long display_line_lengths[MAX_EDITOR_DATA_LINES]; // string length of display line
|
| 21 |
sysadm |
1.9 |
int display_line_widths[MAX_EDITOR_DATA_LINES]; // display width of display line
|
| 22 |
sysadm |
1.1 |
long display_line_total;
|
| 23 |
|
|
};
|
| 24 |
|
|
typedef struct editor_data_t EDITOR_DATA;
|
| 25 |
|
|
|
| 26 |
sysadm |
1.2 |
struct editor_ctx_t
|
| 27 |
|
|
{
|
| 28 |
|
|
int reach_begin;
|
| 29 |
|
|
int reach_end;
|
| 30 |
|
|
long line_cursor;
|
| 31 |
|
|
char msg[MSG_EXT_MAX_LEN];
|
| 32 |
|
|
};
|
| 33 |
|
|
typedef struct editor_ctx_t EDITOR_CTX;
|
| 34 |
|
|
|
| 35 |
sysadm |
1.5 |
extern int editor_memory_pool_init(void);
|
| 36 |
|
|
extern void editor_memory_pool_cleanup(void);
|
| 37 |
|
|
|
| 38 |
sysadm |
1.1 |
extern EDITOR_DATA *editor_data_load(const char *p_data);
|
| 39 |
|
|
extern long editor_data_save(const EDITOR_DATA *p_editor_data, char *p_data, size_t buf_len);
|
| 40 |
|
|
extern void editor_data_cleanup(EDITOR_DATA *p_editor_data);
|
| 41 |
|
|
|
| 42 |
|
|
extern int editor_display(EDITOR_DATA *p_editor_data);
|
| 43 |
|
|
|
| 44 |
sysadm |
1.3 |
extern int editor_data_insert(EDITOR_DATA *p_editor_data, long *p_display_line, long *p_offset,
|
| 45 |
sysadm |
1.2 |
const char *str, int str_len, long *p_last_updated_line);
|
| 46 |
|
|
|
| 47 |
sysadm |
1.6 |
extern int editor_data_delete(EDITOR_DATA *p_editor_data, long *p_display_line, long *p_offset,
|
| 48 |
sysadm |
1.8 |
long *p_last_updated_line, int del_line);
|
| 49 |
sysadm |
1.2 |
|
| 50 |
sysadm |
1.1 |
#endif //_EDITOR_H_
|