no message

This commit is contained in:
BADIM-PC\Vadim 2018-02-12 19:15:05 +03:00
parent 3233d48861
commit 29d6f8f8bb
8 changed files with 217 additions and 354 deletions

View File

@ -764,8 +764,7 @@ static void initOutlineMode(Code* code)
char filter[STUDIO_TEXT_BUFFER_WIDTH] = {0}; char filter[STUDIO_TEXT_BUFFER_WIDTH] = {0};
strncpy(filter, code->popup.text, sizeof(filter)); strncpy(filter, code->popup.text, sizeof(filter));
// TODO: uncomment this _strlwr(filter);
// SDL_strlwr(filter);
const tic_script_config* config = tic->api.get_script_config(tic); const tic_script_config* config = tic->api.get_script_config(tic);
@ -788,8 +787,7 @@ static void initOutlineMode(Code* code)
{ {
strncpy(buffer, out->name, sizeof(buffer)); strncpy(buffer, out->name, sizeof(buffer));
// TODO: uncomment this _strlwr(buffer);
// SDL_strlwr(buffer);
if(strstr(buffer, filter)) out++; if(strstr(buffer, filter)) out++;
else out->pos = NULL; else out->pos = NULL;
@ -870,55 +868,43 @@ static void commentLine(Code* code)
parseSyntaxColor(code); parseSyntaxColor(code);
} }
// static void processKeydown(Code* code, tic_keycode keycode) static void processKeyboard(Code* code)
// { {
// switch(keycode) tic_mem* tic = code->tic;
// {
// case SDLK_LCTRL:
// case SDLK_RCTRL:
// case SDLK_LSHIFT:
// case SDLK_RSHIFT:
// case SDLK_LALT:
// case SDLK_RALT:
// return;
// }
// switch(getClipboardEvent(keycode)) switch(getClipboardEvent(0))
// { {
// case TIC_CLIPBOARD_CUT: cutToClipboard(code); break; case TIC_CLIPBOARD_CUT: cutToClipboard(code); break;
// case TIC_CLIPBOARD_COPY: copyToClipboard(code); break; case TIC_CLIPBOARD_COPY: copyToClipboard(code); break;
// case TIC_CLIPBOARD_PASTE: copyFromClipboard(code); break; case TIC_CLIPBOARD_PASTE: copyFromClipboard(code); break;
// default: break; default: break;
// } }
// SDL_Keymod keymod = SDL_GetModState(); bool shift = tic->api.key(tic, tic_key_shift);
bool ctrl = tic->api.key(tic, tic_key_ctrl);
bool alt = tic->api.key(tic, tic_key_alt);
// switch(keycode) if(isKeyWasDown(tic_key_up)
// { || isKeyWasDown(tic_key_down)
// case SDLK_UP: || isKeyWasDown(tic_key_left)
// case SDLK_DOWN: || isKeyWasDown(tic_key_right)
// case SDLK_LEFT: || isKeyWasDown(tic_key_home)
// case SDLK_RIGHT: || isKeyWasDown(tic_key_end)
// case SDLK_HOME: || isKeyWasDown(tic_key_pageup)
// case SDLK_END: || isKeyWasDown(tic_key_pagedown))
// case SDLK_PAGEUP: {
// case SDLK_PAGEDOWN: if(!shift) code->cursor.selection = NULL;
else if(code->cursor.selection == NULL) code->cursor.selection = code->cursor.position;
}
// if(!(keymod & KMOD_SHIFT)) code->cursor.selection = NULL; if(ctrl)
// else if(code->cursor.selection == NULL) code->cursor.selection = code->cursor.position; {
// } if(ctrl)
{
// if(keymod & TIC_MOD_CTRL) if(isKeyWasDown(tic_key_left)) leftWord(code);
// { else if(isKeyWasDown(tic_key_right)) rightWord(code);
// if(keymod & KMOD_CTRL) else if(isKeyWasDown(tic_key_tab)) doTab(code, shift, ctrl);
// { }
// switch(keycode)
// {
// case SDLK_LEFT: leftWord(code); break;
// case SDLK_RIGHT: rightWord(code); break;
// case SDLK_TAB: doTab(code, keymod & KMOD_SHIFT, keymod & KMOD_CTRL); break;
// }
// }
// else if(keymod & KMOD_GUI) // else if(keymod & KMOD_GUI)
// { // {
// switch(keycode) // switch(keycode)
@ -928,48 +914,39 @@ static void commentLine(Code* code)
// } // }
// } // }
// switch(keycode) if(isKeyWasDown(tic_key_a)) selectAll(code);
// { else if(isKeyWasDown(tic_key_z)) undo(code);
// case SDLK_a: selectAll(code); break; else if(isKeyWasDown(tic_key_y)) redo(code);
// case SDLK_z: undo(code); break; else if(isKeyWasDown(tic_key_f)) setCodeMode(code, TEXT_FIND_MODE);
// case SDLK_y: redo(code); break; else if(isKeyWasDown(tic_key_g)) setCodeMode(code, TEXT_GOTO_MODE);
// case SDLK_f: setCodeMode(code, TEXT_FIND_MODE); break; else if(isKeyWasDown(tic_key_o)) setCodeMode(code, TEXT_OUTLINE_MODE);
// case SDLK_g: setCodeMode(code, TEXT_GOTO_MODE); break; else if(isKeyWasDown(tic_key_slash)) commentLine(code);
// case SDLK_o: setCodeMode(code, TEXT_OUTLINE_MODE); break; else if(isKeyWasDown(tic_key_home)) goCodeHome(code);
// case SDLK_SLASH: commentLine(code); break; else if(isKeyWasDown(tic_key_end)) goCodeEnd(code);
// case SDLK_HOME: goCodeHome(code); break; }
// case SDLK_END: goCodeEnd(code); break; else if(alt)
// } {
// } if(isKeyWasDown(tic_key_left)) leftWord(code);
// else if(keymod & KMOD_ALT) else if(isKeyWasDown(tic_key_right)) rightWord(code);
// { }
// switch(keycode) else
// { {
// case SDLK_LEFT: leftWord(code); break; if(isKeyWasDown(tic_key_up)) upLine(code);
// case SDLK_RIGHT: rightWord(code); break; else if(isKeyWasDown(tic_key_down)) downLine(code);
// } else if(isKeyWasDown(tic_key_left)) leftColumn(code);
// } else if(isKeyWasDown(tic_key_right)) rightColumn(code);
// else else if(isKeyWasDown(tic_key_home)) goHome(code);
// { else if(isKeyWasDown(tic_key_end)) goEnd(code);
// switch(keycode) else if(isKeyWasDown(tic_key_pageup)) pageUp(code);
// { else if(isKeyWasDown(tic_key_pagedown)) pageDown(code);
// case SDLK_UP: upLine(code); break; else if(isKeyWasDown(tic_key_delete)) deleteChar(code);
// case SDLK_DOWN: downLine(code); break; else if(isKeyWasDown(tic_key_backspace)) backspaceChar(code);
// case SDLK_LEFT: leftColumn(code); break; else if(isKeyWasDown(tic_key_return)) newLine(code);
// case SDLK_RIGHT: rightColumn(code); break; else if(isKeyWasDown(tic_key_tab)) doTab(code, shift, ctrl);
// case SDLK_HOME: goHome(code); break; }
// case SDLK_END: goEnd(code); break;
// case SDLK_PAGEUP: pageUp(code); break;
// case SDLK_PAGEDOWN: pageDown(code); break;
// case SDLK_DELETE: deleteChar(code); break;
// case SDLK_BACKSPACE: backspaceChar(code); break;
// case SDLK_RETURN: newLine(code); break;
// case SDLK_TAB: doTab(code, keymod & KMOD_SHIFT, keymod & KMOD_CTRL); break;
// }
// }
// updateEditor(code); updateEditor(code);
// } }
static void processGestures(Code* code) static void processGestures(Code* code)
{ {
@ -1059,6 +1036,8 @@ static void processMouse(Code* code)
static void textEditTick(Code* code) static void textEditTick(Code* code)
{ {
tic_mem* tic = code->tic;
// process scroll // process scroll
{ {
tic80_input* input = &code->tic->ram.input; tic80_input* input = &code->tic->ram.input;
@ -1073,30 +1052,18 @@ static void textEditTick(Code* code)
} }
} }
// SDL_Event* event = NULL; processKeyboard(code);
// while ((event = pollEvent()))
// {
// switch(event->type)
// {
// case SDL_KEYDOWN:
// processKeydown(code, event->key.keysym.sym);
// break;
// case SDL_TEXTINPUT:
// #if defined(__LINUX__) if(!tic->api.key(tic, tic_key_ctrl) && !tic->api.key(tic, tic_key_alt))
// if(!(SDL_GetModState() & KMOD_LALT)) {
// #endif char sym = getKeyboardText();
// if(strlen(event->text.text) == 1) if(sym)
// { {
inputSymbol(code, sym);
updateEditor(code);
// inputSymbol(code, *event->text.text); }
// updateEditor(code); }
// }
// break;
// }
// }
processGestures(code); processGestures(code);
processMouse(code); processMouse(code);
@ -1157,54 +1124,41 @@ static char* downStrStr(const char* start, const char* from, const char* substr)
static void textFindTick(Code* code) static void textFindTick(Code* code)
{ {
// SDL_Event* event = NULL; if(isKeyWasDown(tic_key_return)) setCodeMode(code, TEXT_EDIT_MODE);
// while ((event = pollEvent())) else if(isKeyWasDown(tic_key_up)
// { || isKeyWasDown(tic_key_down)
// switch(event->type) || isKeyWasDown(tic_key_left)
// { || isKeyWasDown(tic_key_right))
// case SDL_KEYDOWN: {
// switch(event->key.keysym.sym) if(*code->popup.text)
// { {
// case SDLK_RETURN: bool reverse = isKeyWasDown(tic_key_up) || isKeyWasDown(tic_key_left);
// setCodeMode(code, TEXT_EDIT_MODE); char* (*func)(const char*, const char*, const char*) = reverse ? upStrStr : downStrStr;
// break; char* from = reverse ? MIN(code->cursor.position, code->cursor.selection) : MAX(code->cursor.position, code->cursor.selection);
// case SDLK_UP: char* pos = func(code->src, from, code->popup.text);
// case SDLK_LEFT: updateFindCode(code, pos);
// case SDLK_DOWN: }
// case SDLK_RIGHT: }
// if(*code->popup.text) else if(isKeyWasDown(tic_key_backspace))
// { {
// tic_keycode keycode = event->key.keysym.sym; if(*code->popup.text)
// bool reverse = keycode == SDLK_UP || keycode == SDLK_LEFT; {
// char* (*func)(const char*, const char*, const char*) = reverse ? upStrStr : downStrStr; code->popup.text[strlen(code->popup.text)-1] = '\0';
// char* from = reverse ? MIN(code->cursor.position, code->cursor.selection) : MAX(code->cursor.position, code->cursor.selection); updateFindCode(code, strstr(code->src, code->popup.text));
// char* pos = func(code->src, from, code->popup.text); }
// updateFindCode(code, pos); }
// }
// break; char sym = getKeyboardText();
// case SDLK_BACKSPACE:
// if(*code->popup.text) if(sym)
// { {
// code->popup.text[strlen(code->popup.text)-1] = '\0'; if(strlen(code->popup.text) + 1 < sizeof code->popup.text)
// updateFindCode(code, strstr(code->src, code->popup.text)); {
// } char str[] = {sym , 0};
// break; strcat(code->popup.text, str);
// default: break; updateFindCode(code, strstr(code->src, code->popup.text));
// } }
// break; }
// case SDL_TEXTINPUT:
// if(strlen(event->text.text) == 1)
// {
// if(strlen(code->popup.text) + 1 < sizeof code->popup.text)
// {
// strcat(code->popup.text, event->text.text);
// updateFindCode(code, strstr(code->src, code->popup.text));
// }
// }
// break;
// default: break;
// }
// }
code->tic->api.clear(code->tic, getConfig()->theme.code.bg); code->tic->api.clear(code->tic, getConfig()->theme.code.bg);
@ -1234,51 +1188,41 @@ static void updateGotoCode(Code* code)
static void textGoToTick(Code* code) static void textGoToTick(Code* code)
{ {
// SDL_Event* event = NULL; tic_mem* tic = code->tic;
// while ((event = pollEvent()))
// {
// switch(event->type)
// {
// case SDL_KEYDOWN:
// switch(event->key.keysym.sym)
// {
// case SDLK_RETURN:
// if(*code->popup.text)
// updateGotoCode(code);
// setCodeMode(code, TEXT_EDIT_MODE); if(isKeyWasDown(tic_key_return))
// break; {
// case SDLK_BACKSPACE: if(*code->popup.text)
// if(*code->popup.text) updateGotoCode(code);
// {
// code->popup.text[strlen(code->popup.text)-1] = '\0';
// updateGotoCode(code);
// }
// break;
// default: break;
// }
// break;
// case SDL_TEXTINPUT:
// if(strlen(event->text.text) == 1)
// {
// char sym = *event->text.text;
// if(strlen(code->popup.text)+1 < sizeof code->popup.text && sym >= '0' && sym <= '9') setCodeMode(code, TEXT_EDIT_MODE);
// { }
// strcat(code->popup.text, event->text.text); else if(isKeyWasDown(tic_key_backspace))
// updateGotoCode(code); {
// } if(*code->popup.text)
// } {
// break; code->popup.text[strlen(code->popup.text)-1] = '\0';
// default: break; updateGotoCode(code);
// } }
// } }
code->tic->api.clear(code->tic, getConfig()->theme.code.bg); char sym = getKeyboardText();
if(sym)
{
if(strlen(code->popup.text)+1 < sizeof code->popup.text && sym >= '0' && sym <= '9')
{
char str[] = {sym, 0};
strcat(code->popup.text, str);
updateGotoCode(code);
}
}
tic->api.clear(tic, getConfig()->theme.code.bg);
if(code->jump.line >= 0) if(code->jump.line >= 0)
code->tic->api.rect(code->tic, 0, (code->jump.line - code->scroll.y) * TIC_FONT_HEIGHT + TOOLBAR_SIZE + 1, tic->api.rect(tic, 0, (code->jump.line - code->scroll.y) * (TIC_FONT_HEIGHT+1) + TOOLBAR_SIZE,
TIC80_WIDTH, TIC_FONT_HEIGHT+1, getConfig()->theme.code.select); TIC80_WIDTH, TIC_FONT_HEIGHT+2, getConfig()->theme.code.select);
drawCode(code, false); drawCode(code, false);
drawPopupBar(code, " GOTO:"); drawPopupBar(code, " GOTO:");
@ -1332,55 +1276,47 @@ static void drawOutlineBar(Code* code, s32 x, s32 y)
static void textOutlineTick(Code* code) static void textOutlineTick(Code* code)
{ {
// SDL_Event* event = NULL; if(isKeyWasDown(tic_key_up))
// while ((event = pollEvent())) {
// { if(code->outline.index > 0)
// switch(event->type) {
// { code->outline.index--;
// case SDL_KEYDOWN: updateOutlineCode(code);
// switch(event->key.keysym.sym) }
// { }
// case SDLK_UP: else if(isKeyWasDown(tic_key_down))
// if(code->outline.index > 0) {
// { if(code->outline.index < OUTLINE_SIZE - 1 && code->outline.items[code->outline.index + 1].pos)
// code->outline.index--; {
// updateOutlineCode(code); code->outline.index++;
// } updateOutlineCode(code);
// break; }
// case SDLK_DOWN: }
// if(code->outline.index < OUTLINE_SIZE - 1 && code->outline.items[code->outline.index + 1].pos) else if(isKeyWasDown(tic_key_return))
// { {
// code->outline.index++; updateOutlineCode(code);
// updateOutlineCode(code); setCodeMode(code, TEXT_EDIT_MODE);
// } }
// break; else if(isKeyWasDown(tic_key_backspace))
// case SDLK_RETURN: {
// updateOutlineCode(code); if(*code->popup.text)
// setCodeMode(code, TEXT_EDIT_MODE); {
// break; code->popup.text[strlen(code->popup.text)-1] = '\0';
// case SDLK_BACKSPACE: setOutlineMode(code);
// if(*code->popup.text) }
// { }
// code->popup.text[strlen(code->popup.text)-1] = '\0';
// setOutlineMode(code); char sym = getKeyboardText();
// }
// break; if(sym)
// default: break; {
// } if(strlen(code->popup.text) + 1 < sizeof code->popup.text)
// break; {
// case SDL_TEXTINPUT: char str[] = {sym, 0};
// if(strlen(event->text.text) == 1) strcat(code->popup.text, str);
// { setOutlineMode(code);
// if(strlen(code->popup.text) + 1 < sizeof code->popup.text) }
// { }
// strcat(code->popup.text, event->text.text);
// setOutlineMode(code);
// }
// }
// break;
// default: break;
// }
// }
code->tic->api.clear(code->tic, getConfig()->theme.code.bg); code->tic->api.clear(code->tic, getConfig()->theme.code.bg);

View File

@ -2556,6 +2556,8 @@ static void checkNewVersion(Console* console)
static void tick(Console* console) static void tick(Console* console)
{ {
tic_mem* tic = console->tic;
// process scroll // process scroll
{ {
tic80_input* input = &console->tic->ram.input; tic80_input* input = &console->tic->ram.input;
@ -2568,77 +2570,6 @@ static void tick(Console* console)
} }
} }
// SDL_Event* event = NULL;
// while ((event = pollEvent()))
// {
// switch(event->type)
// {
// case SDL_KEYDOWN:
// {
// switch(event->key.keysym.sym)
// {
// case SDLK_UP:
// onHistoryUp(console);
// break;
// case SDLK_DOWN:
// onHistoryDown(console);
// break;
// case SDLK_RIGHT:
// {
// console->inputPosition++;
// size_t len = strlen(console->inputBuffer);
// if(console->inputPosition > len)
// console->inputPosition = len;
// }
// break;
// case SDLK_LEFT:
// {
// if(console->inputPosition > 0)
// console->inputPosition--;
// }
// break;
// case SDLK_RETURN: processConsoleCommand(console); break;
// case SDLK_BACKSPACE: processConsoleBackspace(console); break;
// case SDLK_DELETE: processConsoleDel(console); break;
// case SDLK_HOME: processConsoleHome(console); break;
// case SDLK_END: processConsoleEnd(console); break;
// case SDLK_TAB: processConsoleTab(console); break;
// default: break;
// }
// scrollConsole(console);
// console->cursor.delay = CONSOLE_CURSOR_DELAY;
// }
// break;
// case SDL_TEXTINPUT:
// {
// const char* symbol = event->text.text;
// if(strlen(symbol) == 1)
// {
// char sym = *symbol;
// size_t size = strlen(console->inputBuffer);
// if(size < sizeof(console->inputBuffer))
// {
// char* pos = console->inputBuffer + console->inputPosition;
// memmove(pos + 1, pos, strlen(pos));
// *(console->inputBuffer + console->inputPosition) = sym;
// console->inputPosition++;
// }
// }
// console->cursor.delay = CONSOLE_CURSOR_DELAY;
// }
// break;
// }
// }
tic_mem* tic = console->tic;
{ {
if(isKeyWasDown(tic_key_up)) onHistoryUp(console); if(isKeyWasDown(tic_key_up)) onHistoryUp(console);
else if(isKeyWasDown(tic_key_down)) onHistoryDown(console); else if(isKeyWasDown(tic_key_down)) onHistoryDown(console);

View File

@ -1029,7 +1029,7 @@ static void copyFromClipboard(Map* map)
// { // {
// SDL_Keymod keymod = SDL_GetModState(); // SDL_Keymod keymod = SDL_GetModState();
// switch(getClipboardEvent(keycode)) // switch(getClipboardEvent())
// { // {
// case TIC_CLIPBOARD_CUT: cutToClipboard(map); break; // case TIC_CLIPBOARD_CUT: cutToClipboard(map); break;
// case TIC_CLIPBOARD_COPY: copyToClipboard(map); break; // case TIC_CLIPBOARD_COPY: copyToClipboard(map); break;

View File

@ -1007,7 +1007,7 @@ static void selectAll(Music* music)
// { // {
// tic_keycode keycode = keysum->sym; // tic_keycode keycode = keysum->sym;
// switch(getClipboardEvent(keycode)) // switch(getClipboardEvent())
// { // {
// case TIC_CLIPBOARD_CUT: copyToClipboard(music, true); break; // case TIC_CLIPBOARD_CUT: copyToClipboard(music, true); break;
// case TIC_CLIPBOARD_COPY: copyToClipboard(music, false); break; // case TIC_CLIPBOARD_COPY: copyToClipboard(music, false); break;

View File

@ -676,7 +676,7 @@ static void processKeyboard(Sfx* sfx)
// static void processKeydown(Sfx* sfx, tic_keycode keycode) // static void processKeydown(Sfx* sfx, tic_keycode keycode)
// { // {
// switch(getClipboardEvent(keycode)) // switch(getClipboardEvent())
// { // {
// case TIC_CLIPBOARD_CUT: cutToClipboard(sfx); break; // case TIC_CLIPBOARD_CUT: cutToClipboard(sfx); break;
// case TIC_CLIPBOARD_COPY: copyToClipboard(sfx); break; // case TIC_CLIPBOARD_COPY: copyToClipboard(sfx); break;
@ -706,7 +706,7 @@ static void processKeyboard(Sfx* sfx)
// static void processWaveformKeydown(Sfx* sfx, tic_keycode keycode) // static void processWaveformKeydown(Sfx* sfx, tic_keycode keycode)
// { // {
// switch(getClipboardEvent(keycode)) // switch(getClipboardEvent())
// { // {
// case TIC_CLIPBOARD_CUT: cutWaveToClipboard(sfx); break; // case TIC_CLIPBOARD_CUT: cutWaveToClipboard(sfx); break;
// case TIC_CLIPBOARD_COPY: copyWaveToClipboard(sfx); break; // case TIC_CLIPBOARD_COPY: copyWaveToClipboard(sfx); break;

View File

@ -1430,7 +1430,7 @@ static void switchBanks(Sprite* sprite)
// static void processKeydown(Sprite* sprite, tic_keycode keycode) // static void processKeydown(Sprite* sprite, tic_keycode keycode)
// { // {
// switch(getClipboardEvent(keycode)) // switch(getClipboardEvent())
// { // {
// case TIC_CLIPBOARD_CUT: cutToClipboard(sprite); break; // case TIC_CLIPBOARD_CUT: cutToClipboard(sprite); break;
// case TIC_CLIPBOARD_COPY: copyToClipboard(sprite); break; // case TIC_CLIPBOARD_COPY: copyToClipboard(sprite); break;

View File

@ -900,28 +900,24 @@ void setStudioEvent(StudioEvent event)
} }
} }
ClipboardEvent getClipboardEvent(tic_keycode keycode) ClipboardEvent getClipboardEvent()
{ {
// SDL_Keymod keymod = SDL_GetModState(); tic_mem* tic = studioImpl.studio.tic;
// if(keymod & TIC_MOD_CTRL) bool shift = tic->api.key(tic, tic_key_shift);
// { bool ctrl = tic->api.key(tic, tic_key_ctrl);
// switch(keycode)
// { if(ctrl)
// case SDLK_INSERT: {
// case SDLK_c: return TIC_CLIPBOARD_COPY; if(isKeyWasDown(tic_key_insert) || isKeyWasDown(tic_key_c)) return TIC_CLIPBOARD_COPY;
// case SDLK_x: return TIC_CLIPBOARD_CUT; else if(isKeyWasDown(tic_key_x)) return TIC_CLIPBOARD_CUT;
// case SDLK_v: return TIC_CLIPBOARD_PASTE; else if(isKeyWasDown(tic_key_v)) return TIC_CLIPBOARD_PASTE;
// } }
// } else if(shift)
// else if(keymod & KMOD_SHIFT) {
// { if(isKeyWasDown(tic_key_delete)) return TIC_CLIPBOARD_CUT;
// switch(keycode) else if(isKeyWasDown(tic_key_insert)) return TIC_CLIPBOARD_PASTE;
// { }
// case SDLK_DELETE: return TIC_CLIPBOARD_CUT;
// case SDLK_INSERT: return TIC_CLIPBOARD_PASTE;
// }
// }
return TIC_CLIPBOARD_NONE; return TIC_CLIPBOARD_NONE;
} }

View File

@ -173,7 +173,7 @@ typedef enum
TIC_CLIPBOARD_PASTE, TIC_CLIPBOARD_PASTE,
} ClipboardEvent; } ClipboardEvent;
ClipboardEvent getClipboardEvent(tic_keycode keycode); ClipboardEvent getClipboardEvent();
typedef enum typedef enum
{ {