texteditor: refactor + fixes

This commit is contained in:
Marco Kirchner 2016-09-10 11:37:48 +02:00
parent 4ce165384d
commit dd5df9e341
5 changed files with 580 additions and 311 deletions

View File

@ -226,10 +226,10 @@ void contextMenuCtrl(ContextMenu *ctx) {
if (pressed_buttons & SCE_CTRL_ENTER || pressed_buttons & SCE_CTRL_RIGHT) {
if (ctx_menu_mode == CONTEXT_MENU_OPENED) {
if (ctx->menuEnterCallback)
ctx_menu_mode = ctx->menuEnterCallback(ctx_menu_pos);
ctx_menu_mode = ctx->menuEnterCallback(ctx_menu_pos, ctx->context);
} else if (ctx_menu_mode == CONTEXT_MENU_MORE_OPENED) {
if (ctx->menuMoreEnterCallback)
ctx_menu_mode = ctx->menuMoreEnterCallback(ctx_menu_more_pos);
ctx_menu_mode = ctx->menuMoreEnterCallback(ctx_menu_more_pos, ctx->context);
}
}
}

View File

@ -41,8 +41,9 @@ typedef struct {
float menu_max_width;
float menu_more_max_width;
int more_pos;
int (* menuEnterCallback)(int pos);
int (* menuMoreEnterCallback)(int pos);
int (* menuEnterCallback)(int pos, void* context);
int (* menuMoreEnterCallback)(int pos, void* context);
void *context;
} ContextMenu;
enum ContextMenuModes {

4
main.c
View File

@ -581,7 +581,7 @@ void setContextMenuMoreVisibilities() {
setContextMenuMorePos(-1);
}
int contextMenuEnterCallback(int pos) {
int contextMenuEnterCallback(int pos, void* context) {
switch (pos) {
case MENU_ENTRY_MARK_UNMARK_ALL:
{
@ -764,7 +764,7 @@ int contextMenuEnterCallback(int pos) {
return CONTEXT_MENU_CLOSING;
}
int contextMenuMoreEnterCallback(int pos) {
int contextMenuMoreEnterCallback(int pos, void* context) {
switch (pos) {
case MENU_MORE_ENTRY_INSTALL_ALL:
{

867
text.c

File diff suppressed because it is too large Load Diff

11
text.h
View File

@ -23,6 +23,8 @@
#define MAX_LINE_CHARACTERS 1024
#define MAX_COPY_BUFFER_SIZE 1024
#define MAX_SELECTION 1024
#define TEXT_START_X 97.0f
#define MAX_SEARCH_RESULTS 1024 * 1024
@ -32,6 +34,7 @@ typedef struct TextListEntry {
struct TextListEntry *next;
struct TextListEntry *previous;
int line_number;
int selected;
char line[MAX_LINE_CHARACTERS];
} TextListEntry;
@ -47,14 +50,6 @@ typedef struct CopyEntry {
void initTextContextMenuWidth();
typedef struct SearchParams {
char search_term[MAX_LINE_CHARACTERS];
int *search_result_offsets;
char *buffer;
int size;
} SearchParams;
int textViewer(char *file);
#endif