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