Skip to content

Commit c3064c0

Browse files
committed
SDL: add editing context items
1 parent c3d76b0 commit c3064c0

File tree

4 files changed

+51
-8
lines changed

4 files changed

+51
-8
lines changed

src/platform/sdl/runtime.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ void Runtime::optionsBox(StringList *items) {
605605
width += (charWidth * OPTIONS_BOX_WIDTH_EXTRA);
606606

607607
int charHeight = _output->getCharHeight();
608-
int textHeight = charHeight + (charHeight / 2);
608+
int textHeight = charHeight + (charHeight / 3);
609609
int height = textHeight * items->size();
610610
if (_menuX + width >= _output->getWidth()) {
611611
_menuX = _output->getWidth() - width;
@@ -855,7 +855,6 @@ int debugThread(void *data) {
855855
// quit
856856
signalTrace(SDL_FALSE, SDL_TRUE);
857857
g_breakPoints.removeAll();
858-
net_print(socket, "Bye\n");
859858
net_disconnect(socket);
860859
socket = -1;
861860
break;
@@ -873,7 +872,6 @@ int debugThread(void *data) {
873872
}
874873

875874
extern "C" void dev_trace_line(int lineNo) {
876-
runtime->getOutput()->redraw();
877875
SDL_LockMutex(g_lock);
878876
g_debugLine = lineNo;
879877

@@ -889,6 +887,7 @@ extern "C" void dev_trace_line(int lineNo) {
889887
}
890888
}
891889
if (g_debugBreak) {
890+
runtime->getOutput()->redraw();
892891
g_debugPause = SDL_TRUE;
893892
while (g_debugPause) {
894893
SDL_CondWaitTimeout(g_cond, g_lock, COND_WAIT_TIME);

src/platform/sdl/syswm.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ int getStartupFontSize(SDL_Window *window) {
4545
}
4646

4747
void launchDebug(const char *file) {
48-
// TODO
48+
STARTUPINFO info={sizeof(info)};
49+
PROCESS_INFORMATION processInfo;
50+
char cmd[1024];
51+
sprintf(cmd, "-p %d -d %s", g_debugPort, file);
52+
CreateProcess(g_appPath, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo);
4953
}
5054

5155
#else

src/ui/system.cpp

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@
3535
#define MENU_AUDIO 12
3636
#define MENU_SCREENSHOT 13
3737
#define MENU_SCRATCHPAD 14
38-
#define MENU_SIZE 15
38+
#define MENU_UNDO 15
39+
#define MENU_REDO 16
40+
#define MENU_SAVE 17
41+
#define MENU_RUN 18
42+
#define MENU_DEBUG 19
43+
#define MENU_SIZE 20
3944

4045
#define FONT_SCALE_INTERVAL 10
4146
#define FONT_MIN 20
@@ -216,7 +221,8 @@ uint32_t System::getModifiedTime() {
216221
return result;
217222
}
218223

219-
void System::handleMenu(int menuId) {
224+
void System::handleMenu(MAEvent &event) {
225+
int menuId = event.optionsBoxButtonIndex;
220226
int fontSize = _output->getFontSize();
221227
int menuItem = _systemMenu[menuId];
222228
delete [] _systemMenu;
@@ -288,6 +294,26 @@ void System::handleMenu(int menuId) {
288294
case MENU_SCRATCHPAD:
289295
scratchPad();
290296
break;
297+
case MENU_UNDO:
298+
event.type = EVENT_TYPE_KEY_PRESSED;
299+
event.key = SB_KEY_CTRL('z');
300+
break;
301+
case MENU_REDO:
302+
event.type = EVENT_TYPE_KEY_PRESSED;
303+
event.key = SB_KEY_CTRL('y');
304+
break;
305+
case MENU_SAVE:
306+
event.type = EVENT_TYPE_KEY_PRESSED;
307+
event.key = SB_KEY_CTRL('s');
308+
break;
309+
case MENU_RUN:
310+
event.type = EVENT_TYPE_KEY_PRESSED;
311+
event.key = SB_KEY_F(9);
312+
break;
313+
case MENU_DEBUG:
314+
event.type = EVENT_TYPE_KEY_PRESSED;
315+
event.key = SB_KEY_F(5);
316+
break;
291317
}
292318

293319
if (fontSize != _output->getFontSize()) {
@@ -307,7 +333,7 @@ void System::handleEvent(MAEvent &event) {
307333
switch (event.type) {
308334
case EVENT_TYPE_OPTIONS_BOX_BUTTON_CLICKED:
309335
if (_systemMenu != NULL) {
310-
handleMenu(event.optionsBoxButtonIndex);
336+
handleMenu(event);
311337
} else if (isRunning()) {
312338
if (!form_ui::optionSelected(event.optionsBoxButtonIndex)) {
313339
dev_clrkb();
@@ -687,6 +713,20 @@ void System::showMenu() {
687713
_systemMenu[index++] = MENU_CUT;
688714
_systemMenu[index++] = MENU_COPY;
689715
_systemMenu[index++] = MENU_PASTE;
716+
717+
if (isEditing()) {
718+
items->add(new String("Undo"));
719+
items->add(new String("Redo"));
720+
items->add(new String("Save"));
721+
items->add(new String("Run"));
722+
items->add(new String("Debug"));
723+
_systemMenu[index++] = MENU_UNDO;
724+
_systemMenu[index++] = MENU_REDO;
725+
_systemMenu[index++] = MENU_SAVE;
726+
_systemMenu[index++] = MENU_RUN;
727+
_systemMenu[index++] = MENU_DEBUG;
728+
}
729+
690730
#if defined(_SDL)
691731
items->add(new String("Back"));
692732
_systemMenu[index++] = MENU_BACK;

src/ui/system.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct System {
6767
MAEvent getNextEvent() { return processEvents(1); }
6868
uint32_t getModifiedTime();
6969
void handleEvent(MAEvent &event);
70-
void handleMenu(int menuId);
70+
void handleMenu(MAEvent &event);
7171
bool loadSource(const char *fileName);
7272
void resize();
7373
void runEdit(const char *startupBas);

0 commit comments

Comments
 (0)