diff options
author | Rr42 | 2018-06-20 12:13:49 +0530 |
---|---|---|
committer | Rr42 | 2018-06-20 12:13:49 +0530 |
commit | 307008b718c4bf9c3e91f7b0fc36823985c91d37 (patch) | |
tree | ba72d57c0dc85c84a0888560ca39628c44295bf6 | |
parent | e4c4f5ea11291e551967f5240f53c43895771ffb (diff) | |
parent | cae95cbf69ebe440ebcda9b21ab895e4e2bdf719 (diff) | |
download | LDMicroGtk-307008b718c4bf9c3e91f7b0fc36823985c91d37.tar.gz LDMicroGtk-307008b718c4bf9c3e91f7b0fc36823985c91d37.tar.bz2 LDMicroGtk-307008b718c4bf9c3e91f7b0fc36823985c91d37.zip |
Merge branch 'GUI_Port_2' into GUI_port, with menu update.
-rw-r--r-- | ldmicro/circuit.cpp | 4 | ||||
-rw-r--r-- | ldmicro/confdialog.cpp | 386 | ||||
-rw-r--r-- | ldmicro/draw_outputdev.cpp | 17 | ||||
-rw-r--r-- | ldmicro/includes/ldmicro.h | 219 | ||||
-rw-r--r-- | ldmicro/ldmicro.cpp | 410 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.cpp | 3 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.cpp | 4 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.h | 8 | ||||
-rw-r--r-- | ldmicro/maincontrols.cpp | 725 | ||||
-rw-r--r-- | ldmicro/miscutil.cpp | 4 | ||||
-rw-r--r-- | ldmicro/reg/t.pl | 205 | ||||
-rw-r--r-- | ldmicro/undoredo.cpp | 3 |
12 files changed, 1192 insertions, 796 deletions
diff --git a/ldmicro/circuit.cpp b/ldmicro/circuit.cpp index ad9c791..5f4bad9 100644 --- a/ldmicro/circuit.cpp +++ b/ldmicro/circuit.cpp @@ -24,9 +24,11 @@ #include <linuxUI.h> #include <stdio.h> #include <stdlib.h> +#include <iostream> #include "ldmicro.h" +using namespace std; static ElemSubcktSeries *LoadSeriesFromFile(FILE *f); @@ -638,7 +640,7 @@ void FreeCircuit(int which, void *any) //----------------------------------------------------------------------------- void FreeEntireProgram(void) { - ForgetEverything(); + // ForgetEverything(); int i; for(i = 0; i < Prog.numRungs; i++) { diff --git a/ldmicro/confdialog.cpp b/ldmicro/confdialog.cpp index f908893..cb61ce7 100644 --- a/ldmicro/confdialog.cpp +++ b/ldmicro/confdialog.cpp @@ -25,150 +25,108 @@ #include <linuxUI.h> #include <stdio.h> #include <stdlib.h> +#include <iostream> //#include <commctrl.h> - #include "ldmicro.h" -// static HWND ConfDialog; +using namespace std; + +static HWID ConfDialog; -// static HWND CrystalTextbox; -// static HWND CycleTextbox; -// static HWND BaudTextbox; +static HWID CrystalTextbox; +static HWID CycleTextbox; +static HWID BaudTextbox; +static HWID ButtonOk; +static HWID ButtonCancel; static LONG_PTR PrevCrystalProc; static LONG_PTR PrevCycleProc; static LONG_PTR PrevBaudProc; -//----------------------------------------------------------------------------- -// Don't allow any characters other than 0-9. in the text boxes. -//----------------------------------------------------------------------------- -// static LRESULT CALLBACK MyNumberProc(HWND hwnd, UINT msg, WPARAM wParam, -// LPARAM lParam) -// { -// if(msg == WM_CHAR) { -// if(!(isdigit(wParam) || wParam == '.' || wParam == '\b')) { -// return 0; -// } -// } - -// LONG_PTR t; -// if(hwnd == CrystalTextbox) -// t = PrevCrystalProc; -// else if(hwnd == CycleTextbox) -// t = PrevCycleProc; -// else if(hwnd == BaudTextbox) -// t = PrevBaudProc; -// else -// oops(); - -// return CallWindowProc((WNDPROC)t, hwnd, msg, wParam, lParam); -// } +HWID Grid; +HWID PackingBox; static void MakeControls(void) -{ -// HWND textLabel = CreateWindowEx(0, WC_STATIC, _("Cycle Time (ms):"), -// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, -// 5, 13, 145, 21, ConfDialog, NULL, Instance, NULL); -// NiceFont(textLabel); - -// CycleTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", -// WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, -// 155, 12, 85, 21, ConfDialog, NULL, Instance, NULL); -// NiceFont(CycleTextbox); - -// HWND textLabel2 = CreateWindowEx(0, WC_STATIC, -// _("Crystal Frequency (MHz):"), -// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, -// 0, 43, 150, 21, ConfDialog, NULL, Instance, NULL); -// NiceFont(textLabel2); - -// CrystalTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", -// WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, -// 155, 42, 85, 21, ConfDialog, NULL, Instance, NULL); -// NiceFont(CrystalTextbox); - -// HWND textLabel3 = CreateWindowEx(0, WC_STATIC, _("UART Baud Rate (bps):"), -// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, -// 5, 73, 145, 21, ConfDialog, NULL, Instance, NULL); -// NiceFont(textLabel3); - -// BaudTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", -// WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, -// 155, 72, 85, 21, ConfDialog, NULL, Instance, NULL); -// NiceFont(BaudTextbox); - -// if(!UartFunctionUsed()) { -// EnableWindow(BaudTextbox, FALSE); -// EnableWindow(textLabel3, FALSE); -// } - -// if(Prog.mcu && (Prog.mcu->whichIsa == ISA_ANSIC || -// Prog.mcu->whichIsa == ISA_INTERPRETED)) -// { -// EnableWindow(CrystalTextbox, FALSE); -// EnableWindow(textLabel2, FALSE); -// } - -// OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"), -// WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON, -// 258, 11, 70, 23, ConfDialog, NULL, Instance, NULL); -// NiceFont(OkButton); - -// CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"), -// WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, -// 258, 41, 70, 23, ConfDialog, NULL, Instance, NULL); -// NiceFont(CancelButton); - -// char explanation[1024] = ""; - -// if(UartFunctionUsed()) { -// if(Prog.mcu && Prog.mcu->uartNeeds.rxPin != 0) { -// sprintf(explanation, -// _("Serial (UART) will use pins %d and %d.\r\n\r\n"), -// Prog.mcu->uartNeeds.rxPin, Prog.mcu->uartNeeds.txPin); -// } else { -// strcpy(explanation, -// _("Please select a micro with a UART.\r\n\r\n")); -// } -// } else { -// strcpy(explanation, _("No serial instructions (UART Send/UART Receive) " -// "are in use; add one to program before setting baud rate.\r\n\r\n") -// ); -// } - -// strcat(explanation, -// _("The cycle time for the 'PLC' runtime generated by LDmicro is user-" -// "configurable. Very short cycle times may not be achievable due " -// "to processor speed constraints, and very long cycle times may not " -// "be achievable due to hardware overflows. Cycle times between 10 ms " -// "and 100 ms will usually be practical.\r\n\r\n" -// "The compiler must know what speed crystal you are using with the " -// "micro to convert between timing in clock cycles and timing in " -// "seconds. A 4 MHz to 20 MHz crystal is typical; check the speed " -// "grade of the part you are using to determine the maximum allowable " -// "clock speed before choosing a crystal.")); - -// HWND textLabel4 = CreateWindowEx(0, WC_STATIC, explanation, -// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, -// 11, 104, 310, 400, ConfDialog, NULL, Instance, NULL); -// NiceFont(textLabel4); - -// // Measure the explanation string, so that we know how to size our window -// RECT tr, cr; -// HDC hdc = CreateCompatibleDC(NULL); -// SelectObject(hdc, MyNiceFont); -// SetRect(&tr, 0, 0, 310, 400); -// DrawText(hdc, explanation, -1, &tr, DT_CALCRECT | -// DT_LEFT | DT_TOP | DT_WORDBREAK); -// DeleteDC(hdc); -// int h = 104 + tr.bottom + 10; -// SetWindowPos(ConfDialog, NULL, 0, 0, 344, h, SWP_NOMOVE); -// // h is the desired client height, but SetWindowPos includes title bar; -// // so fix it up by hand -// GetClientRect(ConfDialog, &cr); -// int nh = h + (h - (cr.bottom - cr.top)); -// SetWindowPos(ConfDialog, NULL, 0, 0, 344, nh, SWP_NOMOVE); - +{ + // Creating text labels + HWID textLabel = gtk_label_new ("Cycle Time (ms):"); + HWID textLabel2 = gtk_label_new ("Crystal Frequency (MHz):"); + HWID textLabel3 = gtk_label_new ("UART Baud Rate (bps):"); + + // Creating text boxes + CycleTextbox = gtk_entry_new (); + gtk_entry_set_max_length (GTK_ENTRY (CycleTextbox), 0); + // gtk_entry_set_input_purpose (GTK_ENTRY (CycleTextbox), GTK_INPUT_PURPOSE_DIGITS); + CrystalTextbox = gtk_entry_new (); + gtk_entry_set_max_length (GTK_ENTRY (CrystalTextbox), 0); + BaudTextbox = gtk_entry_new (); + gtk_entry_set_max_length (GTK_ENTRY (BaudTextbox), 0); + + if(!UartFunctionUsed()) { + gtk_widget_set_sensitive (BaudTextbox, FALSE); + gtk_widget_set_sensitive (textLabel3, FALSE); + } + + if(Prog.mcu && (Prog.mcu->whichIsa == ISA_ANSIC || + Prog.mcu->whichIsa == ISA_INTERPRETED)) + { + gtk_widget_set_sensitive (CrystalTextbox, FALSE); + gtk_widget_set_sensitive (textLabel2, FALSE); + } + + ButtonOk = gtk_button_new_with_label ("OK"); + ButtonCancel = gtk_button_new_with_label ("Cancel"); + + char explanation[1024] = ""; + + if(UartFunctionUsed()) { + if(Prog.mcu && Prog.mcu->uartNeeds.rxPin != 0) { + sprintf(explanation, + _("Serial (UART) will use pins %d and %d.\r\n\r\n"), + Prog.mcu->uartNeeds.rxPin, Prog.mcu->uartNeeds.txPin); + } + else { + strcpy(explanation, + _("Please select a micro with a UART.\r\n\r\n")); + } + } + else { + strcpy(explanation, _("\n No serial instructions (UART Send/UART Receive) \n" + "are in use; add one to program before \n" + "setting baud rate.\r\n\r\n") ); + } + + strcat(explanation, + _("The cycle time for the 'PLC' runtime generated by \n" "LDmicro is user-" + "configurable. Very short cycle \n" "times may not be achievable due " + "to processor \n" "speed constraints, and very long cycle times may \n" + "not be achievable due to hardware overflows. Cycle \n" "times between 10 ms \n" + "and 100 ms will usually be practical.\r\n\r\n" + "The compiler must know what speed crystal you \n" "are using with the " + "micro to convert between timing \n" "in clock cycles and timing in" + "seconds. A 4 MHz to \n" "20 MHz crystal is typical; check the speed " + "grade of \n" "the part you are using to determine the maximum \n" "allowable" + "clock speed before choosing a crystal.\n")); + + HWID textLabel4 = gtk_label_new (explanation); + + // Creating required containers for packing + Grid = gtk_grid_new(); + PackingBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + + gtk_grid_attach (GTK_GRID (Grid), textLabel, 1, 2, 1, 1); + gtk_grid_attach (GTK_GRID (Grid), CycleTextbox, 3, 2, 1, 1); + gtk_grid_attach (GTK_GRID (Grid), ButtonOk, 6, 2, 2, 1); + gtk_grid_attach (GTK_GRID (Grid), textLabel2, 1, 4, 1, 1); + gtk_grid_attach (GTK_GRID (Grid), CrystalTextbox, 3, 4, 1, 1); + gtk_grid_attach (GTK_GRID (Grid), ButtonCancel, 6, 4, 2, 1); + gtk_grid_attach (GTK_GRID (Grid), textLabel3, 1, 6, 1, 1); + gtk_grid_attach (GTK_GRID (Grid), BaudTextbox, 3, 6, 1, 1); + + gtk_grid_set_column_spacing (GTK_GRID (Grid), 2); + + gtk_box_pack_start(GTK_BOX(PackingBox), Grid, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(PackingBox), textLabel4, TRUE, TRUE, 0); // PrevCycleProc = SetWindowLongPtr(CycleTextbox, GWLP_WNDPROC, // (LONG_PTR)MyNumberProc); @@ -180,70 +138,102 @@ static void MakeControls(void) // (LONG_PTR)MyNumberProc); } +void DestroyWindow (GtkWidget* widget, gpointer data){ + gtk_widget_destroy (ConfDialog); + gtk_widget_set_sensitive (MainWindow, TRUE); +} + +//----------------------------------------------------------------------------- +// Don't allow any characters other than 0-9. in the text boxes. +//----------------------------------------------------------------------------- + +void MyNumberProc (GtkEditable *editable, gchar *NewText, gint length, + gint *position, gpointer data){ + for (int i = 0; i < length; i++){ + if (!(isdigit (NewText[i]) || NewText[i] == '.' || NewText[i] == '\b')){ + g_signal_stop_emission_by_name (G_OBJECT (editable), "insert-text"); + return; + } + } +} + +// Gets data from the text boxes +void GetData (GtkWidget* widget, gpointer data){ + char* buf; + + buf = const_cast <char*> (gtk_entry_get_text (GTK_ENTRY (CycleTextbox))); + Prog.cycleTime = (int)(1000*atof(buf) + 0.5); + if(Prog.cycleTime == 0) { + Error(_("Zero cycle time not valid; resetting to 10 ms.")); + Prog.cycleTime = 10000; + } + + buf = const_cast <char*> (gtk_entry_get_text (GTK_ENTRY(CrystalTextbox))); + Prog.mcuClock = (int)(1e6*atof(buf) + 0.5); + + buf = const_cast <char*> (gtk_entry_get_text (GTK_ENTRY(BaudTextbox))); + Prog.baudRate = atoi(buf); + DestroyWindow (ConfDialog, NULL); +} + +// Checks for the required key press +gboolean KeyPress (GtkWidget* widget, GdkEventKey* event, gpointer data){ + if (event -> keyval == GDK_KEY_Return){ + GetData(NULL, NULL); + } + else if (event -> keyval == GDK_KEY_Escape){ + DestroyWindow (ConfDialog, NULL); + } + return FALSE; +} + +// Consists of all the signal calls +void SignalCall () { + g_signal_connect (G_OBJECT(CycleTextbox), "insert-text", + G_CALLBACK(MyNumberProc), NULL); + g_signal_connect (G_OBJECT(CrystalTextbox), "insert-text", + G_CALLBACK(MyNumberProc), NULL); + g_signal_connect (G_OBJECT(BaudTextbox), "insert-text", + G_CALLBACK(MyNumberProc), NULL); + g_signal_connect (G_OBJECT (ConfDialog), "key-press-event", + G_CALLBACK(KeyPress), NULL); + g_signal_connect (G_OBJECT (ButtonOk), "clicked", + G_CALLBACK(GetData), NULL); + g_signal_connect (G_OBJECT (ButtonCancel), "clicked", + G_CALLBACK(DestroyWindow), NULL); +} + void ShowConfDialog(void) { -// // The window's height will be resized later, to fit the explanation text. -// ConfDialog = CreateWindowClient(0, "LDmicroDialog", _("PLC Configuration"), -// WS_OVERLAPPED | WS_SYSMENU, -// 100, 100, 0, 0, NULL, NULL, Instance, NULL); - -// MakeControls(); - -// char buf[16]; -// sprintf(buf, "%.1f", (Prog.cycleTime / 1000.0)); -// SendMessage(CycleTextbox, WM_SETTEXT, 0, (LPARAM)buf); - -// sprintf(buf, "%.6f", Prog.mcuClock / 1e6); -// SendMessage(CrystalTextbox, WM_SETTEXT, 0, (LPARAM)buf); - -// sprintf(buf, "%d", Prog.baudRate); -// SendMessage(BaudTextbox, WM_SETTEXT, 0, (LPARAM)buf); - -// EnableWindow(MainWindow, FALSE); -// ShowWindow(ConfDialog, TRUE); -// SetFocus(CycleTextbox); - -// MSG msg; -// DWORD ret; -// DialogDone = FALSE; -// DialogCancel = FALSE; -// while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) { -// if(msg.message == WM_KEYDOWN) { -// if(msg.wParam == VK_RETURN) { -// DialogDone = TRUE; -// break; -// } else if(msg.wParam == VK_ESCAPE) { -// DialogDone = TRUE; -// DialogCancel = TRUE; -// break; -// } -// } - -// if(IsDialogMessage(ConfDialog, &msg)) continue; -// TranslateMessage(&msg); -// DispatchMessage(&msg); -// } - -// if(!DialogCancel) { -// char buf[16]; -// SendMessage(CycleTextbox, WM_GETTEXT, (WPARAM)sizeof(buf), -// (LPARAM)(buf)); -// Prog.cycleTime = (int)(1000*atof(buf) + 0.5); -// if(Prog.cycleTime == 0) { -// Error(_("Zero cycle time not valid; resetting to 10 ms.")); -// Prog.cycleTime = 10000; -// } - -// SendMessage(CrystalTextbox, WM_GETTEXT, (WPARAM)sizeof(buf), -// (LPARAM)(buf)); -// Prog.mcuClock = (int)(1e6*atof(buf) + 0.5); - -// SendMessage(BaudTextbox, WM_GETTEXT, (WPARAM)sizeof(buf), -// (LPARAM)(buf)); -// Prog.baudRate = atoi(buf); -// } - -// EnableWindow(MainWindow, TRUE); -// DestroyWindow(ConfDialog); -// return; -} + // The window's height will be resized later, to fit the explanation text. + MakeControls(); + GdkEventKey* event; + + ConfDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(ConfDialog), "PLC Configuration"); + gtk_window_set_default_size(GTK_WINDOW(ConfDialog), 200, 250); + gtk_window_set_resizable (GTK_WINDOW (ConfDialog), FALSE); + gtk_container_add(GTK_CONTAINER(ConfDialog), PackingBox); + gtk_widget_add_events (ConfDialog, GDK_KEY_PRESS_MASK); + gtk_widget_add_events (ConfDialog, GDK_BUTTON_PRESS_MASK); + + char buf[16]; + sprintf(buf, "%.1f", (Prog.cycleTime / 1000.0)); + gtk_entry_set_text (GTK_ENTRY (CycleTextbox), buf); + + sprintf(buf, "%.6f", Prog.mcuClock / 1e6); + gtk_entry_set_text (GTK_ENTRY (CrystalTextbox), buf); + + sprintf(buf, "%d", Prog.baudRate); + gtk_entry_set_text (GTK_ENTRY (BaudTextbox), buf); + + gtk_widget_set_sensitive (MainWindow, FALSE); + gtk_widget_grab_focus (ButtonOk); + gtk_widget_set_state_flags (CycleTextbox, GTK_STATE_FLAG_FOCUSED, TRUE); + gtk_widget_grab_focus (CycleTextbox); + gtk_widget_show_all (ConfDialog); + + SignalCall(); + + return; +}
\ No newline at end of file diff --git a/ldmicro/draw_outputdev.cpp b/ldmicro/draw_outputdev.cpp index 2fdb98e..363aef0 100644 --- a/ldmicro/draw_outputdev.cpp +++ b/ldmicro/draw_outputdev.cpp @@ -87,22 +87,9 @@ void CALLBACK BlinkCursor(HWND hwnd, UINT msg, UINT_PTR id, DWORD time) // if(Cursor.left == 0) return; // PlcCursor c; - // memcpy(&c, &Cursor, sizeof(c)); + // SettingsInstance = gtk_settings_get_default(); + // gtk_settings_install_property_parser (gtk-cursor-blink ,black); - // c.top -= ScrollYOffset*POS_HEIGHT*FONT_HEIGHT; - // c.left -= ScrollXOffset; - - // if(c.top >= IoListTop) return; - - // if(c.top + c.height >= IoListTop) { - // c.height = IoListTop - c.top - 3; - // } - - // Hdc = GetDC(MainWindow); - // SelectObject(Hdc, GetStockObject(WHITE_BRUSH)); - // PatBlt(Hdc, c.left, c.top, c.width, c.height, PATINVERT); - // CursorDrawn = !CursorDrawn; - // ReleaseDC(MainWindow, Hdc); } //----------------------------------------------------------------------------- diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h index c93db3e..23d82fb 100644 --- a/ldmicro/includes/ldmicro.h +++ b/ldmicro/includes/ldmicro.h @@ -51,79 +51,151 @@ typedef signed long SDWORD; #define NUM_SUPPORTED_MCUS 16 // Menu IDs -extern HMENU MNU_NEW; -extern HMENU MNU_OPEN; -extern HMENU MNU_SAVE; -extern HMENU MNU_SAVE_AS; -extern HMENU MNU_EXPORT; -extern HMENU MNU_EXIT; - -extern HMENU MNU_UNDO; -extern HMENU MNU_REDO; -extern HMENU MNU_PUSH_RUNG_UP; -extern HMENU MNU_PUSH_RUNG_DOWN; -extern HMENU MNU_INSERT_RUNG_BEFORE; -extern HMENU MNU_INSERT_RUNG_AFTER; -extern HMENU MNU_DELETE_ELEMENT; -extern HMENU MNU_DELETE_RUNG; - -extern HMENU MNU_INSERT_COMMENT; -extern HMENU MNU_INSERT_CONTACTS; -extern HMENU MNU_INSERT_COIL; -extern HMENU MNU_INSERT_TON; -extern HMENU MNU_INSERT_TOF; -extern HMENU MNU_INSERT_RTO; -extern HMENU MNU_INSERT_RES; -extern HMENU MNU_INSERT_OSR; -extern HMENU MNU_INSERT_OSF; -extern HMENU MNU_INSERT_CTU; -extern HMENU MNU_INSERT_CTD; -extern HMENU MNU_INSERT_CTC; -extern HMENU MNU_INSERT_ADD; -extern HMENU MNU_INSERT_SUB; -extern HMENU MNU_INSERT_MUL; -extern HMENU MNU_INSERT_DIV; -extern HMENU MNU_INSERT_MOV; -extern HMENU MNU_INSERT_READ_ADC; -extern HMENU MNU_INSERT_SET_PWM; -extern HMENU MNU_INSERT_UART_SEND; -extern HMENU MNU_INSERT_UART_RECV; -extern HMENU MNU_INSERT_EQU; -extern HMENU MNU_INSERT_NEQ; -extern HMENU MNU_INSERT_GRT; -extern HMENU MNU_INSERT_GEQ; -extern HMENU MNU_INSERT_LES; -extern HMENU MNU_INSERT_LEQ; -extern HMENU MNU_INSERT_OPEN; -extern HMENU MNU_INSERT_SHORT; -extern HMENU MNU_INSERT_MASTER_RLY; -extern HMENU MNU_INSERT_SHIFT_REG; -extern HMENU MNU_INSERT_LUT; -extern HMENU MNU_INSERT_FMTD_STR; -extern HMENU MNU_INSERT_PERSIST; -extern HMENU MNU_MAKE_NORMAL; -extern HMENU MNU_NEGATE; -extern HMENU MNU_MAKE_SET_ONLY; -extern HMENU MNU_MAKE_RESET_ONLY; -extern HMENU MNU_INSERT_PWL; - -extern HMENU MNU_MCU_SETTINGS; -extern HMENU MNU_PROCESSOR[NUM_SUPPORTED_MCUS+1]; -extern HMENU MNU_MICRO_CONTROLLER; - -extern HMENU MNU_SIMULATION_MODE; -extern HMENU MNU_START_SIMULATION; -extern HMENU MNU_STOP_SIMULATION; -extern HMENU MNU_SINGLE_CYCLE; - -extern HMENU MNU_COMPILE; -extern HMENU MNU_COMPILE_AS; - -extern HMENU MNU_MANUAL; -extern HMENU MNU_ABOUT; - -extern HMENU MNU_ADV_SIMULATION; - +#define MNU_NEW 0x01 +#define MNU_OPEN 0x02 +#define MNU_SAVE 0x03 +#define MNU_SAVE_AS 0x04 +#define MNU_EXPORT 0x05 +#define MNU_EXIT 0x06 + +#define MNU_UNDO 0x10 +#define MNU_REDO 0x11 +#define MNU_PUSH_RUNG_UP 0x12 +#define MNU_PUSH_RUNG_DOWN 0x13 +#define MNU_INSERT_RUNG_BEFORE 0x14 +#define MNU_INSERT_RUNG_AFTER 0x15 +#define MNU_DELETE_ELEMENT 0x16 +#define MNU_DELETE_RUNG 0x17 + +#define MNU_INSERT_COMMENT 0x20 +#define MNU_INSERT_CONTACTS 0x21 +#define MNU_INSERT_COIL 0x22 +#define MNU_INSERT_TON 0x23 +#define MNU_INSERT_TOF 0x24 +#define MNU_INSERT_RTO 0x25 +#define MNU_INSERT_RES 0x26 +#define MNU_INSERT_OSR 0x27 +#define MNU_INSERT_OSF 0x28 +#define MNU_INSERT_CTU 0x29 +#define MNU_INSERT_CTD 0x2a +#define MNU_INSERT_CTC 0x2b +#define MNU_INSERT_ADD 0x2c +#define MNU_INSERT_SUB 0x2d +#define MNU_INSERT_MUL 0x2e +#define MNU_INSERT_DIV 0x2f +#define MNU_INSERT_MOV 0x30 +#define MNU_INSERT_READ_ADC 0x31 +#define MNU_INSERT_SET_PWM 0x32 +#define MNU_INSERT_UART_SEND 0x33 +#define MNU_INSERT_UART_RECV 0x34 +#define MNU_INSERT_EQU 0x35 +#define MNU_INSERT_NEQ 0x36 +#define MNU_INSERT_GRT 0x37 +#define MNU_INSERT_GEQ 0x38 +#define MNU_INSERT_LES 0x39 +#define MNU_INSERT_LEQ 0x3a +#define MNU_INSERT_OPEN 0x3b +#define MNU_INSERT_SHORT 0x3c +#define MNU_INSERT_MASTER_RLY 0x3d +#define MNU_INSERT_SHIFT_REG 0x3e +#define MNU_INSERT_LUT 0x3f +#define MNU_INSERT_FMTD_STR 0x40 +#define MNU_INSERT_PERSIST 0x41 +#define MNU_MAKE_NORMAL 0x42 +#define MNU_NEGATE 0x43 +#define MNU_MAKE_SET_ONLY 0x44 +#define MNU_MAKE_RESET_ONLY 0x45 +#define MNU_INSERT_PWL 0x46 + +#define MNU_MCU_SETTINGS 0x50 +#define MNU_PROCESSOR_0 0xa0 + +#define MNU_SIMULATION_MODE 0x60 +#define MNU_START_SIMULATION 0x61 +#define MNU_STOP_SIMULATION 0x62 +#define MNU_SINGLE_CYCLE 0x63 + +#define MNU_COMPILE 0x70 +#define MNU_COMPILE_AS 0x71 + +#define MNU_MANUAL 0x80 +#define MNU_ABOUT 0x81 + +// #define MNU_ADV_SIMULATION + +// New menu items here +extern HMENU NewMenu; +extern HMENU OpenMenu; +extern HMENU SaveMenu; +extern HMENU SaveAsMenu; +extern HMENU ExportMenu; +extern HMENU ExitMenu; + +extern HMENU UndoMenu; +extern HMENU RedoMenu; +extern HMENU PushRungUpMenu; +extern HMENU PushRungDownMenu; +extern HMENU InsertRungBeforeMenu; +extern HMENU InsertRungAfterMenu; +extern HMENU DeleteElementMenu; +extern HMENU DeleteRungMenu; + +extern HMENU InsertCommentMenu; +extern HMENU InsertContactsMenu; +extern HMENU InsertCoilMenu; +extern HMENU InsertTonMenu; +extern HMENU InsertTofMenu; +extern HMENU InsertRtoMenu; +extern HMENU InsertResMenu; +extern HMENU InsertOsrMenu; +extern HMENU InsertOsfMenu; +extern HMENU InsertCtuMenu; +extern HMENU InsertCtdMenu; +extern HMENU InsertCtcMenu; +extern HMENU InsertAddMenu; +extern HMENU InsertSubMenu; +extern HMENU InsertMulMenu; +extern HMENU InsertDivMenu; +extern HMENU InsertMovMenu; +extern HMENU InsertReadAdcMenu; +extern HMENU InsertSetPwmMenu; +extern HMENU InsertUartSendMenu; +extern HMENU InsertUartRecvMenu; +extern HMENU InsertEquMenu; +extern HMENU InsertNeqMenu; +extern HMENU InsertGrtMenu; +extern HMENU InsertGeqMenu; +extern HMENU InsertLesMenu; +extern HMENU InsertLeqMenu; +extern HMENU InsertOpenMenu; +extern HMENU InsertShortMenu; +extern HMENU InsertMasterRlyMenu; +extern HMENU InsertShiftRegMenu; +extern HMENU InsertLutMenu; +extern HMENU InsertFmtdStrMenu; +extern HMENU InsertPersistMenu; +extern HMENU MakeNormalMenu; +extern HMENU NegateMenu; +extern HMENU MakeSetOnlyMenu; +extern HMENU MakeResetOnlyMenu; +extern HMENU InsertPwlMenu; + +extern HMENU McuSettingsMenu; +extern HMENU ProcessorMenuItems[NUM_SUPPORTED_MCUS+1]; +extern HMENU MicroControllerMenu; + +extern HMENU SimulationModeMenu; +extern HMENU StartSimulationMenu; +extern HMENU StopSimulationMenu; +extern HMENU SingleCycleMenu; + +extern HMENU CompileMenu; +extern HMENU CompileAsMenu; + +extern HMENU ManualMenu; +extern HMENU AboutMenu; + +// extern HMENU MNU_ADV_SIMULATION; // Columns within the I/O etc. listview. #define LV_IO_NAME 0x00 @@ -547,6 +619,7 @@ extern BOOL NeedHoriz; extern HLIST IoList; extern int IoListTop; extern int IoListHeight; +extern HMENU ScrollWindow; // draw.cpp int ProgCountWidestRow(void); diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp index 1fa8567..cdc9e7f 100644 --- a/ldmicro/ldmicro.cpp +++ b/ldmicro/ldmicro.cpp @@ -31,6 +31,10 @@ #include "ldmicro.h" #include "freezeLD.h" #include "mcutable.h" +#include <iomanip> +#include <iostream> + +using namespace std; HINSTANCE Instance; @@ -274,17 +278,17 @@ static void CompileProgram(BOOL compileAs) // changed so that we ask if user wants to save before exiting, and update // the I/O list. //----------------------------------------------------------------------------- -// void ProgramChanged(void) -// { -// ProgramChangedNotSaved = TRUE; -// GenerateIoListDontLoseSelection(); -// RefreshScrollbars(); -// } -// #define CHANGING_PROGRAM(x) { \ -// UndoRemember(); \ -// x; \ -// ProgramChanged(); \ -// } +void ProgramChanged(void) +{ + ProgramChangedNotSaved = TRUE; + GenerateIoListDontLoseSelection(); + // RefreshScrollbars(); +} +#define CHANGING_PROGRAM(x) { \ + UndoRemember(); \ + x; \ + ProgramChanged();\ + } //----------------------------------------------------------------------------- // Hook that we install when the user starts dragging the `splitter,' in case @@ -323,155 +327,155 @@ static void CompileProgram(BOOL compileAs) //----------------------------------------------------------------------------- // Handle a selection from the menu bar of the main window. //----------------------------------------------------------------------------- -// static void ProcessMenu(int code) -// { -// if(code >= MNU_PROCESSOR_0 && code < MNU_PROCESSOR_0+NUM_SUPPORTED_MCUS) { -// strcpy(CurrentCompileFile, ""); -// Prog.mcu = &SupportedMcus[code - MNU_PROCESSOR_0]; -// RefreshControlsToSettings(); -// return; -// } -// if(code == MNU_PROCESSOR_0+NUM_SUPPORTED_MCUS) { -// Prog.mcu = NULL; -// strcpy(CurrentCompileFile, ""); -// RefreshControlsToSettings(); -// return; -// } +static void ProcessMenu(int code) +{ + if(code >= MNU_PROCESSOR_0 && code < MNU_PROCESSOR_0+NUM_SUPPORTED_MCUS) { + strcpy(CurrentCompileFile, ""); + Prog.mcu = &SupportedMcus[code - MNU_PROCESSOR_0]; + RefreshControlsToSettings(); + return; + } + if(code == MNU_PROCESSOR_0+NUM_SUPPORTED_MCUS) { + Prog.mcu = NULL; + strcpy(CurrentCompileFile, ""); + RefreshControlsToSettings(); + return; + } -// switch(code) { -// case MNU_NEW: -// if(CheckSaveUserCancels()) break; -// NewProgram(); -// strcpy(CurrentSaveFile, ""); -// strcpy(CurrentCompileFile, ""); -// GenerateIoListDontLoseSelection(); -// RefreshScrollbars(); -// UpdateMainWindowTitleBar(); -// break; + switch(code) { + case MNU_NEW: + // if(CheckSaveUserCancels()) break; + // NewProgram(); + // strcpy(CurrentSaveFile, ""); + // strcpy(CurrentCompileFile, ""); + // GenerateIoListDontLoseSelection(); + // RefreshScrollbars(); + // UpdateMainWindowTitleBar(); + break; -// case MNU_OPEN: -// if(CheckSaveUserCancels()) break; -// OpenDialog(); -// break; + case MNU_OPEN: + // if(CheckSaveUserCancels()) break; + // OpenDialog(); + break; -// case MNU_SAVE: -// SaveProgram(); -// UpdateMainWindowTitleBar(); -// break; + case MNU_SAVE: + // SaveProgram(); + // UpdateMainWindowTitleBar(); + break; -// case MNU_SAVE_AS: -// SaveAsDialog(); -// UpdateMainWindowTitleBar(); -// break; + case MNU_SAVE_AS: + // SaveAsDialog(); + // UpdateMainWindowTitleBar(); + break; -// case MNU_EXPORT: -// ExportDialog(); -// break; + case MNU_EXPORT: + // ExportDialog(); + break; -// case MNU_EXIT: -// if(CheckSaveUserCancels()) break; -// PostQuitMessage(0); -// break; + case MNU_EXIT: + // if(CheckSaveUserCancels()) break; + // PostQuitMessage(0); + break; -// case MNU_INSERT_COMMENT: -// CHANGING_PROGRAM(AddComment(_("--add comment here--"))); -// break; + case MNU_INSERT_COMMENT: + // CHANGING_PROGRAM(AddComment(_("--add comment here--"))); + break; -// case MNU_INSERT_CONTACTS: -// CHANGING_PROGRAM(AddContact()); -// break; + case MNU_INSERT_CONTACTS: + // CHANGING_PROGRAM(AddContact()); + break; -// case MNU_INSERT_COIL: -// CHANGING_PROGRAM(AddCoil()); -// break; + case MNU_INSERT_COIL: + // CHANGING_PROGRAM(AddCoil()); + break; -// case MNU_INSERT_TON: -// CHANGING_PROGRAM(AddTimer(ELEM_TON)); -// break; + case MNU_INSERT_TON: + // CHANGING_PROGRAM(AddTimer(ELEM_TON)); + break; -// case MNU_INSERT_TOF: -// CHANGING_PROGRAM(AddTimer(ELEM_TOF)); -// break; + case MNU_INSERT_TOF: + // CHANGING_PROGRAM(AddTimer(ELEM_TOF)); + break; -// case MNU_INSERT_RTO: -// CHANGING_PROGRAM(AddTimer(ELEM_RTO)); -// break; + case MNU_INSERT_RTO: + // CHANGING_PROGRAM(AddTimer(ELEM_RTO)); + break; -// case MNU_INSERT_CTU: -// CHANGING_PROGRAM(AddCounter(ELEM_CTU)); -// break; + case MNU_INSERT_CTU: + // CHANGING_PROGRAM(AddCounter(ELEM_CTU)); + break; -// case MNU_INSERT_CTD: -// CHANGING_PROGRAM(AddCounter(ELEM_CTD)); -// break; + case MNU_INSERT_CTD: + // CHANGING_PROGRAM(AddCounter(ELEM_CTD)); + break; -// case MNU_INSERT_CTC: -// CHANGING_PROGRAM(AddCounter(ELEM_CTC)); -// break; + case MNU_INSERT_CTC: + // CHANGING_PROGRAM(AddCounter(ELEM_CTC)); + break; -// case MNU_INSERT_RES: -// CHANGING_PROGRAM(AddReset()); -// break; + case MNU_INSERT_RES: + // CHANGING_PROGRAM(AddReset()); + break; -// case MNU_INSERT_OPEN: -// CHANGING_PROGRAM(AddEmpty(ELEM_OPEN)); -// break; + case MNU_INSERT_OPEN: + // CHANGING_PROGRAM(AddEmpty(ELEM_OPEN)); + break; -// case MNU_INSERT_SHORT: -// CHANGING_PROGRAM(AddEmpty(ELEM_SHORT)); -// break; + case MNU_INSERT_SHORT: + // CHANGING_PROGRAM(AddEmpty(ELEM_SHORT)); + break; -// case MNU_INSERT_MASTER_RLY: -// CHANGING_PROGRAM(AddMasterRelay()); -// break; + case MNU_INSERT_MASTER_RLY: + // CHANGING_PROGRAM(AddMasterRelay()); + break; -// case MNU_INSERT_SHIFT_REG: -// CHANGING_PROGRAM(AddShiftRegister()); -// break; + case MNU_INSERT_SHIFT_REG: + // CHANGING_PROGRAM(AddShiftRegister()); + break; -// case MNU_INSERT_LUT: -// CHANGING_PROGRAM(AddLookUpTable()); -// break; + case MNU_INSERT_LUT: + // CHANGING_PROGRAM(AddLookUpTable()); + break; -// case MNU_INSERT_PWL: -// CHANGING_PROGRAM(AddPiecewiseLinear()); -// break; + case MNU_INSERT_PWL: + // CHANGING_PROGRAM(AddPiecewiseLinear()); + break; -// case MNU_INSERT_FMTD_STR: -// CHANGING_PROGRAM(AddFormattedString()); -// break; + case MNU_INSERT_FMTD_STR: + // CHANGING_PROGRAM(AddFormattedString()); + break; -// case MNU_INSERT_OSR: -// CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_RISING)); -// break; + case MNU_INSERT_OSR: + // CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_RISING)); + break; -// case MNU_INSERT_OSF: -// CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_FALLING)); -// break; + case MNU_INSERT_OSF: + // CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_FALLING)); + break; -// case MNU_INSERT_MOV: -// CHANGING_PROGRAM(AddMove()); -// break; + case MNU_INSERT_MOV: + // CHANGING_PROGRAM(AddMove()); + break; -// case MNU_INSERT_SET_PWM: -// CHANGING_PROGRAM(AddSetPwm()); -// break; + case MNU_INSERT_SET_PWM: + // CHANGING_PROGRAM(AddSetPwm()); + break; -// case MNU_INSERT_READ_ADC: -// CHANGING_PROGRAM(AddReadAdc()); -// break; + case MNU_INSERT_READ_ADC: + // CHANGING_PROGRAM(AddReadAdc()); + break; -// case MNU_INSERT_UART_SEND: -// CHANGING_PROGRAM(AddUart(ELEM_UART_SEND)); -// break; + case MNU_INSERT_UART_SEND: + // CHANGING_PROGRAM(AddUart(ELEM_UART_SEND)); + break; -// case MNU_INSERT_UART_RECV: -// CHANGING_PROGRAM(AddUart(ELEM_UART_RECV)); -// break; + case MNU_INSERT_UART_RECV: + // CHANGING_PROGRAM(AddUart(ELEM_UART_RECV)); + break; -// case MNU_INSERT_PERSIST: -// CHANGING_PROGRAM(AddPersist()); -// break; + case MNU_INSERT_PERSIST: + // CHANGING_PROGRAM(AddPersist()); + break; // { // int elem; @@ -497,91 +501,101 @@ static void CompileProgram(BOOL compileAs) // break; // } -// case MNU_MAKE_NORMAL: -// CHANGING_PROGRAM(MakeNormalSelected()); -// break; + case MNU_MAKE_NORMAL: + // CHANGING_PROGRAM(MakeNormalSelected()); + break; -// case MNU_NEGATE: -// CHANGING_PROGRAM(NegateSelected()); -// break; + case MNU_NEGATE: + // CHANGING_PROGRAM(NegateSelected()); + break; -// case MNU_MAKE_SET_ONLY: -// CHANGING_PROGRAM(MakeSetOnlySelected()); -// break; + case MNU_MAKE_SET_ONLY: + // CHANGING_PROGRAM(MakeSetOnlySelected()); + break; -// case MNU_MAKE_RESET_ONLY: -// CHANGING_PROGRAM(MakeResetOnlySelected()); -// break; + case MNU_MAKE_RESET_ONLY: + // CHANGING_PROGRAM(MakeResetOnlySelected()); + break; -// case MNU_UNDO: -// UndoUndo(); -// break; + case MNU_UNDO: + // UndoUndo(); + break; -// case MNU_REDO: -// UndoRedo(); -// break; + case MNU_REDO: + // UndoRedo(); + break; -// case MNU_INSERT_RUNG_BEFORE: -// CHANGING_PROGRAM(InsertRung(FALSE)); -// break; + case MNU_INSERT_RUNG_BEFORE: + // CHANGING_PROGRAM(InsertRung(FALSE)); + break; -// case MNU_INSERT_RUNG_AFTER: -// CHANGING_PROGRAM(InsertRung(TRUE)); -// break; + case MNU_INSERT_RUNG_AFTER: + // CHANGING_PROGRAM(InsertRung(TRUE)); + break; -// case MNU_DELETE_RUNG: -// CHANGING_PROGRAM(DeleteSelectedRung()); -// break; + case MNU_DELETE_RUNG: + // CHANGING_PROGRAM(DeleteSelectedRung()); + break; -// case MNU_PUSH_RUNG_UP: -// CHANGING_PROGRAM(PushRungUp()); -// break; + case MNU_PUSH_RUNG_UP: + // CHANGING_PROGRAM(PushRungUp()); + break; -// case MNU_PUSH_RUNG_DOWN: -// CHANGING_PROGRAM(PushRungDown()); -// break; + case MNU_PUSH_RUNG_DOWN: + // CHANGING_PROGRAM(PushRungDown()); + break; -// case MNU_DELETE_ELEMENT: -// CHANGING_PROGRAM(DeleteSelectedFromProgram()); -// break; + case MNU_DELETE_ELEMENT: + // CHANGING_PROGRAM(DeleteSelectedFromProgram()); + break; -// case MNU_MCU_SETTINGS: -// CHANGING_PROGRAM(ShowConfDialog()); -// break; + case MNU_MCU_SETTINGS: + CHANGING_PROGRAM(ShowConfDialog()); + break; -// case MNU_SIMULATION_MODE: -// ToggleSimulationMode(); -// break; + case MNU_SIMULATION_MODE: + // ToggleSimulationMode(); + break; -// case MNU_START_SIMULATION: -// StartSimulation(); -// break; + case MNU_START_SIMULATION: + // StartSimulation(); + break; -// case MNU_STOP_SIMULATION: -// StopSimulation(); -// break; + case MNU_STOP_SIMULATION: + // StopSimulation(); + break; -// case MNU_SINGLE_CYCLE: -// SimulateOneCycle(TRUE); -// break; + case MNU_SINGLE_CYCLE: + // SimulateOneCycle(TRUE); + break; -// case MNU_COMPILE: -// CompileProgram(FALSE); -// break; + case MNU_COMPILE: + // CompileProgram(FALSE); + break; -// case MNU_COMPILE_AS: -// CompileProgram(TRUE); -// break; + case MNU_COMPILE_AS: + // CompileProgram(TRUE); + break; -// case MNU_MANUAL: -// ShowHelpDialog(FALSE); -// break; + case MNU_MANUAL: + // ShowHelpDialog(FALSE); + break; -// case MNU_ABOUT: -// ShowHelpDialog(TRUE); -// break; -// } -// } + case MNU_ABOUT: + // ShowHelpDialog(TRUE); + break; + } +} + +void WM_COMMAND (GtkMenuItem* men, gpointer gpcode){ + int tempcode = GPOINTER_TO_INT(gpcode); + ProcessMenu (tempcode); +} + +void MenuHandler (){ + g_signal_connect(G_OBJECT(McuSettingsMenu), "activate", + G_CALLBACK(WM_COMMAND), GINT_TO_POINTER(MNU_MCU_SETTINGS)); +} //----------------------------------------------------------------------------- // WndProc for MainWindow. @@ -959,8 +973,6 @@ gboolean LD_GTK_mouse_click_hook(GtkWidget *widget, GdkEvent *event, gpointer us * WM_LBUTTONDBLCLK, WM_LBUTTONDOWN */ - g_print("x = %f\n", event->button.x_root); - g_print("y = %f\n", event->button.y_root); switch(event->button.type) { case GDK_BUTTON_PRESS:// To Do: run only for left click @@ -1270,17 +1282,19 @@ int main(int argc, char** argv) MakeMainWindowControls(); /// takes care of MakeMainWindowMenus() MainWindowResized(); + // CHANGING_PROGRAM(ShowConfDialog()); + MenuHandler(); /// Keyboard and mouse hooks equivalent to MainWndProc g_signal_connect (MainWindow, "delete_event", G_CALLBACK (LD_WM_Close_call), NULL); - g_signal_connect (MainWindow, "key_press_event", G_CALLBACK (LD_WM_KeyDown_call), NULL); + // g_signal_connect (MainWindow, "key_press_event", G_CALLBACK (LD_WM_KeyDown_call), NULL); g_signal_connect (MainWindow, "button_press_event", G_CALLBACK (LD_GTK_mouse_click_hook), NULL); g_signal_connect (MainWindow, "scroll_event", G_CALLBACK (LD_GTK_mouse_scroll_hook), NULL); g_signal_connect (MainWindow, "motion_notify_event", G_CALLBACK (LD_WM_MouseMove_call), NULL); g_signal_connect (DrawWindow, "draw", G_CALLBACK (LD_WM_Paint_call), NULL); g_signal_connect (MainWindow, "destroy_event", G_CALLBACK (LD_WM_Destroy_call), NULL); g_signal_connect (MainWindow, "configure_event", G_CALLBACK (LD_WM_Size_call), NULL); - g_signal_connect (MainWindow, "focus_in_event", G_CALLBACK (LD_WM_SetFocus_call), NULL); + // g_signal_connect (MainWindow, "focus_in_event", G_CALLBACK (LD_WM_SetFocus_call), NULL); /// Keyboard and mouse hooks equivalent to MainWndProc - end NewProgram(); diff --git a/ldmicro/lib/linuxUI/linuxLD.cpp b/ldmicro/lib/linuxUI/linuxLD.cpp index 966c5b3..a83d15e 100644 --- a/ldmicro/lib/linuxUI/linuxLD.cpp +++ b/ldmicro/lib/linuxUI/linuxLD.cpp @@ -1,4 +1,7 @@ #include "linuxUI.h" +#include <iostream> + +using namespace std; std::vector<HEAPRECORD> HeapRecords; diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp index 3447c02..d9fbd3f 100644 --- a/ldmicro/lib/linuxUI/linuxUI.cpp +++ b/ldmicro/lib/linuxUI/linuxUI.cpp @@ -16,6 +16,10 @@ const UINT MF_GRAYED = 1; const UINT MF_CHECKED = 2; const UINT MF_UNCHECKED = 3; +/// Accelerators (keyboard shortcuts) +GtkAccelGroup* AccelGroup; +GClosure* closure; + /// ListStore HWID view; HTVC column; diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h index 8ac0c9b..2f13e79 100644 --- a/ldmicro/lib/linuxUI/linuxUI.h +++ b/ldmicro/lib/linuxUI/linuxUI.h @@ -73,9 +73,13 @@ extern const UINT MF_GRAYED; extern const UINT MF_CHECKED; extern const UINT MF_UNCHECKED; +/// Accelerators (keyboard shortcuts) +extern GtkAccelGroup* AccelGroup; +extern GClosure* closure; + /// ListStore -extern GtkWidget *view; -extern GtkTreeViewColumn *column; +extern HWID view; +extern HTVC column; /// Structures typedef struct OpenFileInfoData { diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp index 60760b7..ff7f5a8 100644 --- a/ldmicro/maincontrols.cpp +++ b/ldmicro/maincontrols.cpp @@ -31,76 +31,76 @@ #include "ldmicro.h" // Menu IDs -HMENU MNU_NEW; -HMENU MNU_OPEN; -HMENU MNU_SAVE; -HMENU MNU_SAVE_AS; -HMENU MNU_EXPORT; -HMENU MNU_EXIT; - -HMENU MNU_UNDO; -HMENU MNU_REDO; -HMENU MNU_PUSH_RUNG_UP; -HMENU MNU_PUSH_RUNG_DOWN; -HMENU MNU_INSERT_RUNG_BEFORE; -HMENU MNU_INSERT_RUNG_AFTER; -HMENU MNU_DELETE_ELEMENT; -HMENU MNU_DELETE_RUNG; - -HMENU MNU_INSERT_COMMENT; -HMENU MNU_INSERT_CONTACTS; -HMENU MNU_INSERT_COIL; -HMENU MNU_INSERT_TON; -HMENU MNU_INSERT_TOF; -HMENU MNU_INSERT_RTO; -HMENU MNU_INSERT_RES; -HMENU MNU_INSERT_OSR; -HMENU MNU_INSERT_OSF; -HMENU MNU_INSERT_CTU; -HMENU MNU_INSERT_CTD; -HMENU MNU_INSERT_CTC; -HMENU MNU_INSERT_ADD; -HMENU MNU_INSERT_SUB; -HMENU MNU_INSERT_MUL; -HMENU MNU_INSERT_DIV; -HMENU MNU_INSERT_MOV; -HMENU MNU_INSERT_READ_ADC; -HMENU MNU_INSERT_SET_PWM; -HMENU MNU_INSERT_UART_SEND; -HMENU MNU_INSERT_UART_RECV; -HMENU MNU_INSERT_EQU; -HMENU MNU_INSERT_NEQ; -HMENU MNU_INSERT_GRT; -HMENU MNU_INSERT_GEQ; -HMENU MNU_INSERT_LES; -HMENU MNU_INSERT_LEQ; -HMENU MNU_INSERT_OPEN; -HMENU MNU_INSERT_SHORT; -HMENU MNU_INSERT_MASTER_RLY; -HMENU MNU_INSERT_SHIFT_REG; -HMENU MNU_INSERT_LUT; -HMENU MNU_INSERT_FMTD_STR; -HMENU MNU_INSERT_PERSIST; -HMENU MNU_MAKE_NORMAL; -HMENU MNU_NEGATE; -HMENU MNU_MAKE_SET_ONLY; -HMENU MNU_MAKE_RESET_ONLY; -HMENU MNU_INSERT_PWL; - -HMENU MNU_MCU_SETTINGS; -HMENU MNU_PROCESSOR[NUM_SUPPORTED_MCUS+1]; -HMENU MNU_MICRO_CONTROLLER; // Item for Microcontroller - -HMENU MNU_SIMULATION_MODE; -HMENU MNU_START_SIMULATION; -HMENU MNU_STOP_SIMULATION; -HMENU MNU_SINGLE_CYCLE; - -HMENU MNU_COMPILE; -HMENU MNU_COMPILE_AS; - -HMENU MNU_MANUAL; -HMENU MNU_ABOUT; +HMENU NewMenu; +HMENU OpenMenu; +HMENU SaveMenu; +HMENU SaveAsMenu_AS; +HMENU ExportMenu; +HMENU ExitMenu; + +HMENU UndoMenu; +HMENU RedoMenu; +HMENU PushRungUpMenu; +HMENU PushRungDownMenu; +HMENU InsertRungBeforeMenu; +HMENU InsertRungAfterMenu; +HMENU DeleteElementMenu; +HMENU DeleteRungMenu; + +HMENU InsertCommentMenu; +HMENU InsertContactsMenu; +HMENU InsertCoilMenu; +HMENU InsertTonMenu; +HMENU InsertTofMenu; +HMENU InsertRtoMenu; +HMENU InsertResMenu; +HMENU InsertOsrMenu; +HMENU InsertOsfMenu; +HMENU InsertCtuMenu; +HMENU InsertCtdMenu; +HMENU InsertCtcMenu; +HMENU InsertAddMenu; +HMENU InsertSubMenu; +HMENU InsertMulMenu; +HMENU InsertDivMenu; +HMENU InsertMovMenu; +HMENU InsertReadAdcMenu; +HMENU InsertSetPwmMenu; +HMENU InsertUartSendMenu; +HMENU InsertUartRecvMenu; +HMENU InsertEquMenu; +HMENU InsertNeqMenu; +HMENU InsertGrtMenu; +HMENU InsertGeqMenu; +HMENU InsertLesMenu; +HMENU InsertLeqMenu; +HMENU InsertOpenMenu; +HMENU InsertShortMenu; +HMENU InsertMasterRlyMenu; +HMENU InsertShiftRegMenu; +HMENU InsertLutMenu; +HMENU InsertFmtdStrMenu; +HMENU InsertPersistMenu; +HMENU MakeNormalMenu; +HMENU NegateMenu; +HMENU MakeSetOnlyMenu; +HMENU MakeResetOnlyMenu; +HMENU InsertPwlMenu; + +HMENU McuSettingsMenu; +HMENU ProcessorMenuItems[NUM_SUPPORTED_MCUS+1]; +HMENU MicroControllerMenu; // Item for Microcontroller + +HMENU SimulationModeMenu; +HMENU StartSimulationMenu; +HMENU StopSimulationMenu; +HMENU SingleCycleMenu; + +HMENU CompileMenu; +HMENU CompileAsMenu; + +HMENU ManualMenu; +HMENU AboutMenu; // scrollbars for the ladder logic area // static HWND HorizScrollBar; @@ -119,10 +119,10 @@ static HMENU InstructionMenu; static HMENU ProcessorMenu; static HMENU SimulateMenu; static HMENU TopMenu; // Menu Bar -static HMENU settings; -static HMENU compile; -static HMENU help; -static HMENU ScrollWindow; +static HMENU Settings; +static HMENU Compile; +static HMENU Help; +HMENU ScrollWindow; // listview used to maintain the list of I/O pins with symbolic names, plus // the internal relay too @@ -137,15 +137,125 @@ GtkTreeModel **IoListPtr = (GtkTreeModel**)GTK_TREE_MODEL (IoList); // whether the simulation is running in real time static BOOL RealTimeSimulationRunning; +// Displaying keyboard shortcuts for each menu item +void AddMenuAccelerators (void){ + // Declaring the accelerator group for keyboard shortcuts + AccelGroup = gtk_accel_group_new (); + + // Creating keyboard shortcuts for File menu + gtk_widget_add_accelerator (NewMenu, "activate", AccelGroup, GDK_KEY_N, + GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (OpenMenu, "activate", AccelGroup, GDK_KEY_O, + GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (SaveMenu, "activate", AccelGroup, GDK_KEY_S, + GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (ExportMenu, "activate", AccelGroup, GDK_KEY_E, + GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); + + // Creating keyboard shortcuts for Edit menu + gtk_widget_add_accelerator (UndoMenu, "activate", AccelGroup, GDK_KEY_Z, + GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (RedoMenu, "activate", AccelGroup, GDK_KEY_Y, + GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertRungBeforeMenu, "activate", AccelGroup, GDK_KEY_F6, + GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertRungAfterMenu, "activate", AccelGroup, GDK_KEY_V, + GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (PushRungUpMenu, "activate", AccelGroup, GDK_KEY_uparrow, + GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (PushRungDownMenu, "activate", AccelGroup, GDK_KEY_downarrow, + GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (DeleteElementMenu, "activate", AccelGroup, GDK_KEY_Delete, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (DeleteRungMenu, "activate", AccelGroup, GDK_KEY_Delete, + GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE); + + // Creating keyboard shortcuts for Instructions menu + gtk_widget_add_accelerator (InsertCommentMenu, "activate", AccelGroup, GDK_KEY_semicolon, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertContactsMenu, "activate", AccelGroup, GDK_KEY_C, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertOsrMenu, "activate", AccelGroup, GDK_KEY_backslash, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertOsfMenu, "activate", AccelGroup, GDK_KEY_slash, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertTonMenu, "activate", AccelGroup, GDK_KEY_O, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertTofMenu, "activate", AccelGroup, GDK_KEY_F, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertRtoMenu, "activate", AccelGroup, GDK_KEY_T, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertCtuMenu, "activate", AccelGroup, GDK_KEY_U, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertCtdMenu, "activate", AccelGroup, GDK_KEY_I, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertCtcMenu, "activate", AccelGroup, GDK_KEY_J, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertEquMenu, "activate", AccelGroup, GDK_KEY_equal, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertGrtMenu, "activate", AccelGroup, GDK_KEY_greater, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertGeqMenu, "activate", AccelGroup, GDK_KEY_Stop, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertLesMenu, "activate", AccelGroup, GDK_KEY_less, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertLeqMenu, "activate", AccelGroup, GDK_KEY_comma, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertCoilMenu, "activate", AccelGroup, GDK_KEY_L, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertResMenu, "activate", AccelGroup, GDK_KEY_E, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertMovMenu, "activate", AccelGroup, GDK_KEY_M, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertAddMenu, "activate", AccelGroup, GDK_KEY_plus, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertSubMenu, "activate", AccelGroup, GDK_KEY_minus, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertMulMenu, "activate", AccelGroup, GDK_KEY_multiply, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertDivMenu, "activate", AccelGroup, GDK_KEY_D, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (InsertReadAdcMenu, "activate", AccelGroup, GDK_KEY_P, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (MakeNormalMenu, "activate", AccelGroup, GDK_KEY_A, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (NegateMenu, "activate", AccelGroup, GDK_KEY_N, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (MakeSetOnlyMenu, "activate", AccelGroup, GDK_KEY_S, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (MakeResetOnlyMenu, "activate", AccelGroup, GDK_KEY_R, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + + // Creating keyboard shortcuts for Simulation menu + gtk_widget_add_accelerator (SimulationModeMenu, "activate", AccelGroup, GDK_KEY_M, + GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (StartSimulationMenu, "activate", AccelGroup, GDK_KEY_R, + GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (StopSimulationMenu, "activate", AccelGroup, GDK_KEY_H, + GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); + gtk_widget_add_accelerator (SingleCycleMenu, "activate", AccelGroup, GDK_KEY_space, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + + // Creating keyboard shortcuts for Compile menu + gtk_widget_add_accelerator (CompileMenu, "activate", AccelGroup, GDK_KEY_F5, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + + // Creating keyboard shortcuts for Help menu + gtk_widget_add_accelerator (ManualMenu, "activate", AccelGroup, GDK_KEY_F1, + GDK_RELEASE_MASK, GTK_ACCEL_VISIBLE); + + gtk_window_add_accel_group (GTK_WINDOW (MainWindow), AccelGroup); + +} + //----------------------------------------------------------------------------- // Create the top-level menu bar for the main window. Mostly static, but we // create the "select processor" menu from the list in mcutable.h dynamically. //----------------------------------------------------------------------------- HMENU MakeMainWindowMenus(void) { - HMENU MenuBox; // Box for alignment - HMENU PackedMenuBox; // Stores the packed box - HMENU TopMenu; // Menu Bar + HMENU MenuBox; // Box for packing and alignment + // HMENU TopMenu; // Menu Bar HWID FileLabel; // File menu label HWID EditLabel; // Edit menu label HWID InstructionLabel; // Instruction menu label @@ -153,7 +263,6 @@ HMENU MakeMainWindowMenus(void) HWID CompileLabel; // Compile menu label HWID HelpLabel; // Help menu label HWID SimulateLabel; // Simulate menu label - HMENU ProcessorMenuItems; // Processor menu items HMENU FileMenuSeparator; // File menu separator HMENU EditMenuSeparator; // Edit menu separator HMENU InstructionMenuSeparator; // Instruction menu separator @@ -169,226 +278,226 @@ HMENU MakeMainWindowMenus(void) // Creating various menus FileMenu = gtk_menu_new(); EditMenu = gtk_menu_new(); - settings = gtk_menu_new(); + Settings = gtk_menu_new(); ProcessorMenu = gtk_menu_new(); InstructionMenu = gtk_menu_new(); SimulateMenu = gtk_menu_new(); - compile = gtk_menu_new(); - help = gtk_menu_new(); + Compile = gtk_menu_new(); + Help = gtk_menu_new(); // Creating labels for each menu - FileLabel = gtk_menu_item_new_with_label("File"); - EditLabel = gtk_menu_item_new_with_label("Edit"); - SettingsLabel = gtk_menu_item_new_with_label("Settings"); - InstructionLabel = gtk_menu_item_new_with_label("Instructions"); - SimulateLabel = gtk_menu_item_new_with_label("Simulate"); - CompileLabel = gtk_menu_item_new_with_label("Compile"); - HelpLabel = gtk_menu_item_new_with_label("Help"); + FileLabel = gtk_menu_item_new_with_mnemonic("_File"); + EditLabel = gtk_menu_item_new_with_mnemonic("_Edit"); + SettingsLabel = gtk_menu_item_new_with_mnemonic("_Settings"); + InstructionLabel = gtk_menu_item_new_with_mnemonic("_Instructions"); + SimulateLabel = gtk_menu_item_new_with_mnemonic("_Simulate"); + CompileLabel = gtk_menu_item_new_with_mnemonic("_Compile"); + HelpLabel = gtk_menu_item_new_with_mnemonic("_Help"); // Creating labels for File Menu - MNU_NEW = gtk_menu_item_new_with_label("New"); - MNU_OPEN = gtk_menu_item_new_with_label("Open"); - MNU_SAVE = gtk_menu_item_new_with_label("Save"); - MNU_SAVE_AS = gtk_menu_item_new_with_label("Save As"); - MNU_EXPORT = gtk_menu_item_new_with_label("Export As Text"); - MNU_EXIT = gtk_menu_item_new_with_label("Exit"); - + NewMenu = gtk_menu_item_new_with_mnemonic("_New"); + OpenMenu = gtk_menu_item_new_with_mnemonic("_Open"); + SaveMenu = gtk_menu_item_new_with_mnemonic("_Save"); + SaveAsMenu_AS = gtk_menu_item_new_with_mnemonic("_Save As"); + ExportMenu = gtk_menu_item_new_with_mnemonic("_Export As Text"); + ExitMenu = gtk_menu_item_new_with_mnemonic("_Exit"); + // Appending menu items (labels) to File menu and adding separators - gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_NEW); // Appending menu items - gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_OPEN); - gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_SAVE); - gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_SAVE_AS); + gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), NewMenu); // Appending menu items + gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), OpenMenu); + gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), SaveMenu); + gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), SaveAsMenu_AS); FileMenuSeparator = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), FileMenuSeparator); - gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_EXPORT); + gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), ExportMenu); FileMenuSeparator = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), FileMenuSeparator); - gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_EXIT); + gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), ExitMenu); // Creating labels for Edit Menu - MNU_UNDO = gtk_menu_item_new_with_label("Undo"); - MNU_REDO = gtk_menu_item_new_with_label("Redo"); - MNU_INSERT_RUNG_BEFORE = gtk_menu_item_new_with_label("Insert rung Before"); - MNU_INSERT_RUNG_AFTER = gtk_menu_item_new_with_label("Insert Rung After"); - MNU_PUSH_RUNG_UP = gtk_menu_item_new_with_label("Move Selected Rung Up"); - MNU_PUSH_RUNG_DOWN = gtk_menu_item_new_with_label("Move Selected Rung Down"); - MNU_DELETE_ELEMENT = gtk_menu_item_new_with_label("Delete Selected Element"); - MNU_DELETE_RUNG = gtk_menu_item_new_with_label("Delete Rung"); + UndoMenu = gtk_menu_item_new_with_mnemonic("_Undo"); + RedoMenu = gtk_menu_item_new_with_mnemonic("_Redo"); + InsertRungBeforeMenu = gtk_menu_item_new_with_mnemonic("_Insert rung Before"); + InsertRungAfterMenu = gtk_menu_item_new_with_mnemonic("_Insert Rung After"); + PushRungUpMenu = gtk_menu_item_new_with_mnemonic("_Move Selected Rung Up"); + PushRungDownMenu = gtk_menu_item_new_with_mnemonic("_Move Selected Rung Down"); + DeleteElementMenu = gtk_menu_item_new_with_mnemonic("_Delete Selected Element"); + DeleteRungMenu = gtk_menu_item_new_with_mnemonic("_Delete Rung"); // Appending menu items to Edit menu and adding separators - gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_UNDO); - gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_REDO); + gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), UndoMenu); + gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), RedoMenu); EditMenuSeparator = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(EditMenu), EditMenuSeparator); - gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_INSERT_RUNG_BEFORE); - gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_INSERT_RUNG_AFTER); - gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_PUSH_RUNG_UP); - gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_PUSH_RUNG_DOWN); + gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), InsertRungBeforeMenu); + gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), InsertRungAfterMenu); + gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), PushRungUpMenu); + gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), PushRungDownMenu); EditMenuSeparator = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(EditMenu), EditMenuSeparator); - gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_DELETE_ELEMENT); - gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_DELETE_RUNG); + gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), DeleteElementMenu); + gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), DeleteRungMenu); // Creating labels for Settings Menu - MNU_MCU_SETTINGS = gtk_menu_item_new_with_label ("MCU Parameters..."); - MNU_MICRO_CONTROLLER = gtk_menu_item_new_with_label ("Microcontroller"); + McuSettingsMenu = gtk_menu_item_new_with_mnemonic ("_MCU Parameters..."); + MicroControllerMenu = gtk_menu_item_new_with_mnemonic ("_Microcontroller"); // Appending menu items to Settings menu - gtk_menu_shell_append (GTK_MENU_SHELL (settings), MNU_MCU_SETTINGS); - gtk_menu_shell_append (GTK_MENU_SHELL (settings), MNU_MICRO_CONTROLLER); + gtk_menu_shell_append (GTK_MENU_SHELL (Settings), McuSettingsMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (Settings), MicroControllerMenu); // Appending the microcontroller names to "Microcontroller" item for (i = 0; i < NUM_SUPPORTED_MCUS; i++){ - MNU_PROCESSOR[i] = gtk_check_menu_item_new_with_label (SupportedMcus[i].mcuName); - gtk_menu_shell_append (GTK_MENU_SHELL (ProcessorMenu), MNU_PROCESSOR[i]); + ProcessorMenuItems[i] = gtk_check_menu_item_new_with_label (SupportedMcus[i].mcuName); + gtk_menu_shell_append (GTK_MENU_SHELL (ProcessorMenu), ProcessorMenuItems[i]); } - MNU_PROCESSOR[NUM_SUPPORTED_MCUS] = gtk_check_menu_item_new_with_label ("(no microcontroller)"); - gtk_menu_shell_append (GTK_MENU_SHELL (ProcessorMenu), MNU_PROCESSOR[NUM_SUPPORTED_MCUS]); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(MNU_MICRO_CONTROLLER), ProcessorMenu); + ProcessorMenuItems[NUM_SUPPORTED_MCUS] = gtk_check_menu_item_new_with_label ("(no microcontroller)"); + gtk_menu_shell_append (GTK_MENU_SHELL (ProcessorMenu), ProcessorMenuItems[NUM_SUPPORTED_MCUS]); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(MicroControllerMenu), ProcessorMenu); // Creating labels for Instruction Menu and adding separators - MNU_INSERT_COMMENT = gtk_menu_item_new_with_label("Insert Comment"); - MNU_INSERT_CONTACTS = gtk_menu_item_new_with_label("Insert Contacts"); - MNU_INSERT_OSR = gtk_menu_item_new_with_label("Insert OSR (One Shot Rising)"); - MNU_INSERT_OSF = gtk_menu_item_new_with_label("Insert OSF (One Shot Falling)"); - MNU_INSERT_TON = gtk_menu_item_new_with_label("Insert TON (Delayed Turn On)"); - MNU_INSERT_TOF = gtk_menu_item_new_with_label("Insert TOF (Delayed Turn Off)"); - MNU_INSERT_RTO = gtk_menu_item_new_with_label("Insert RTO (Retentive Delayed Turn On)"); - MNU_INSERT_CTU = gtk_menu_item_new_with_label("Insert CTU (Count Up)"); - MNU_INSERT_CTD = gtk_menu_item_new_with_label("Insert CTD (Count Down)"); - MNU_INSERT_CTC = gtk_menu_item_new_with_label("Insert CTC (Count Circular)"); - MNU_INSERT_EQU = gtk_menu_item_new_with_label("Insert EQU (Compare for Equals)"); - MNU_INSERT_NEQ = gtk_menu_item_new_with_label("Insert NEQ (Compare for Not Equals)"); - MNU_INSERT_GRT = gtk_menu_item_new_with_label("Insert GRT (Compare for Greater Than)"); - MNU_INSERT_GEQ = gtk_menu_item_new_with_label("Insert GEQ (Compare for Greater Than or Equal)"); - MNU_INSERT_LES = gtk_menu_item_new_with_label("Insert LES (Compare for Less Than)"); - MNU_INSERT_LEQ = gtk_menu_item_new_with_label("Insert LEQ (Compare for Less Than or Equal)"); - MNU_INSERT_OPEN = gtk_menu_item_new_with_label("Insert Open Circuit"); - MNU_INSERT_SHORT = gtk_menu_item_new_with_label("Insert Short Circuit"); - MNU_INSERT_MASTER_RLY = gtk_menu_item_new_with_label("Insert Master Control Relay"); - MNU_INSERT_COIL = gtk_menu_item_new_with_label("Insert Coil"); - MNU_INSERT_RES = gtk_menu_item_new_with_label("Insert RES (Counter/RTO Reset)"); - MNU_INSERT_MOV = gtk_menu_item_new_with_label("Insert MOV (Move)"); - MNU_INSERT_ADD = gtk_menu_item_new_with_label("Insert ADD (16-bit Integer Ad)"); - MNU_INSERT_SUB = gtk_menu_item_new_with_label("Insert SUB (16-bit Integer Subtract)"); - MNU_INSERT_MUL = gtk_menu_item_new_with_label("Insert MUL (16-bit Integer Multiply)"); - MNU_INSERT_DIV = gtk_menu_item_new_with_label("Insert DIV (16-bit Integer Division)"); - MNU_INSERT_SHIFT_REG = gtk_menu_item_new_with_label("Insert Shift Register"); - MNU_INSERT_LUT = gtk_menu_item_new_with_label("Insert Look-Up Table"); - MNU_INSERT_PWL = gtk_menu_item_new_with_label("Insert Piecewise Linear"); - MNU_INSERT_FMTD_STR = gtk_menu_item_new_with_label("Insert Formatted String Over UART"); - MNU_INSERT_UART_SEND = gtk_menu_item_new_with_label("Insert UART Send"); - MNU_INSERT_UART_RECV = gtk_menu_item_new_with_label("Insert UART Receive"); - MNU_INSERT_SET_PWM = gtk_menu_item_new_with_label("Insert Set PWM Output"); - MNU_INSERT_READ_ADC = gtk_menu_item_new_with_label("Insert A/D Converter Read"); - MNU_INSERT_PERSIST = gtk_menu_item_new_with_label("Insert Make Persistent"); - MNU_MAKE_NORMAL = gtk_menu_item_new_with_label("Make Normal"); - MNU_NEGATE = gtk_menu_item_new_with_label("Make Negated"); - MNU_MAKE_SET_ONLY = gtk_menu_item_new_with_label("Make Set-Only"); - MNU_MAKE_RESET_ONLY = gtk_menu_item_new_with_label("Make Reset-Only"); + InsertCommentMenu = gtk_menu_item_new_with_mnemonic("_Insert Comment"); + InsertContactsMenu = gtk_menu_item_new_with_mnemonic("_Insert Contacts"); + InsertOsrMenu = gtk_menu_item_new_with_mnemonic("_Insert OSR (One Shot Rising)"); + InsertOsfMenu = gtk_menu_item_new_with_mnemonic("_Insert OSF (One Shot Falling)"); + InsertTonMenu = gtk_menu_item_new_with_mnemonic("_Insert TON (Delayed Turn On)"); + InsertTofMenu = gtk_menu_item_new_with_mnemonic("_Insert TOF (Delayed Turn Off)"); + InsertRtoMenu = gtk_menu_item_new_with_mnemonic("_Insert RTO (Retentive Delayed Turn On)"); + InsertCtuMenu = gtk_menu_item_new_with_mnemonic("_Insert CTU (Count Up)"); + InsertCtdMenu = gtk_menu_item_new_with_mnemonic("_Insert CTD (Count Down)"); + InsertCtcMenu = gtk_menu_item_new_with_mnemonic("_Insert CTC (Count Circular)"); + InsertEquMenu = gtk_menu_item_new_with_mnemonic("_Insert EQU (Compare for Equals)"); + InsertNeqMenu = gtk_menu_item_new_with_mnemonic("_Insert NEQ (Compare for Not Equals)"); + InsertGrtMenu = gtk_menu_item_new_with_mnemonic("_Insert GRT (Compare for Greater Than)"); + InsertGeqMenu = gtk_menu_item_new_with_mnemonic("_Insert GEQ (Compare for Greater Than or Equal)"); + InsertLesMenu = gtk_menu_item_new_with_mnemonic("_Insert LES (Compare for Less Than)"); + InsertLeqMenu = gtk_menu_item_new_with_mnemonic("_Insert LEQ (Compare for Less Than or Equal)"); + InsertOpenMenu = gtk_menu_item_new_with_mnemonic("_Insert Open Circuit"); + InsertShortMenu = gtk_menu_item_new_with_mnemonic("_Insert Short Circuit"); + InsertMasterRlyMenu = gtk_menu_item_new_with_mnemonic("_Insert Master Control Relay"); + InsertCoilMenu = gtk_menu_item_new_with_mnemonic("_Insert Coil"); + InsertResMenu = gtk_menu_item_new_with_mnemonic("_Insert RES (Counter/RTO Reset)"); + InsertMovMenu = gtk_menu_item_new_with_mnemonic("_Insert MOV (Move)"); + InsertAddMenu = gtk_menu_item_new_with_mnemonic("_Insert ADD (16-bit Integer Ad)"); + InsertSubMenu = gtk_menu_item_new_with_mnemonic("_Insert SUB (16-bit Integer Subtract)"); + InsertMulMenu = gtk_menu_item_new_with_mnemonic("_Insert MUL (16-bit Integer Multiply)"); + InsertDivMenu = gtk_menu_item_new_with_mnemonic("_Insert DIV (16-bit Integer Division)"); + InsertShiftRegMenu = gtk_menu_item_new_with_mnemonic("_Insert Shift Register"); + InsertLutMenu = gtk_menu_item_new_with_mnemonic("_Insert Look-Up Table"); + InsertPwlMenu = gtk_menu_item_new_with_mnemonic("_Insert Piecewise Linear"); + InsertFmtdStrMenu = gtk_menu_item_new_with_mnemonic("_Insert Formatted String Over UART"); + InsertUartSendMenu = gtk_menu_item_new_with_mnemonic("_Insert UART Send"); + InsertUartRecvMenu = gtk_menu_item_new_with_mnemonic("_Insert UART Receive"); + InsertSetPwmMenu = gtk_menu_item_new_with_mnemonic("_Insert Set PWM Output"); + InsertReadAdcMenu = gtk_menu_item_new_with_mnemonic("_Insert A/D Converter Read"); + InsertPersistMenu = gtk_menu_item_new_with_mnemonic("_Insert Make Persistent"); + MakeNormalMenu = gtk_menu_item_new_with_mnemonic("_Make Normal"); + NegateMenu = gtk_menu_item_new_with_mnemonic("_Make Negated"); + MakeSetOnlyMenu = gtk_menu_item_new_with_mnemonic("_Make Set-Only"); + MakeResetOnlyMenu = gtk_menu_item_new_with_mnemonic("_Make Reset-Only"); // Appending menu items to Instruction menu and adding separators - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_COMMENT); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertCommentMenu); InstructionMenuSeparator = gtk_separator_menu_item_new(); gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CONTACTS); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertContactsMenu); InstructionMenuSeparator = gtk_separator_menu_item_new(); gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OSR); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertOsrMenu); InstructionMenuSeparator = gtk_separator_menu_item_new(); gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OSF); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_TON); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_TOF); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_RTO); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertOsfMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertTonMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertTofMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertRtoMenu); InstructionMenuSeparator = gtk_separator_menu_item_new(); gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTU); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTD); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTC); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertCtuMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertCtdMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertCtcMenu); InstructionMenuSeparator = gtk_separator_menu_item_new(); gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_EQU); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_NEQ); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_GRT); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_GEQ); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LES); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LEQ); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertEquMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertNeqMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertGrtMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertGeqMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertLesMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertLeqMenu); InstructionMenuSeparator = gtk_separator_menu_item_new(); gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OPEN); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SHORT); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MASTER_RLY); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertOpenMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertShortMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertMasterRlyMenu); InstructionMenuSeparator = gtk_separator_menu_item_new(); gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_COIL); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_RES); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertCoilMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertResMenu); InstructionMenuSeparator = gtk_separator_menu_item_new(); gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MOV); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_ADD); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SUB); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MUL); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_DIV); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertMovMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertAddMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertSubMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertMulMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertDivMenu); InstructionMenuSeparator = gtk_separator_menu_item_new(); gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SHIFT_REG); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LUT); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_PWL); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_FMTD_STR); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertShiftRegMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertLutMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertPwlMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertFmtdStrMenu); InstructionMenuSeparator = gtk_separator_menu_item_new(); gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_UART_SEND); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_UART_RECV); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SET_PWM); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_READ_ADC); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_PERSIST); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertUartSendMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertUartRecvMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertSetPwmMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertReadAdcMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InsertPersistMenu); InstructionMenuSeparator = gtk_separator_menu_item_new(); gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_NORMAL); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_NEGATE); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_SET_ONLY); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_RESET_ONLY); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MakeNormalMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), NegateMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MakeSetOnlyMenu); + gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MakeResetOnlyMenu); - // Creating labels for Simulation Menu - MNU_COMPILE = gtk_menu_item_new_with_label("Compile"); - MNU_COMPILE_AS = gtk_menu_item_new_with_label("Compile As..."); + // Creating labels for Compile Menu + CompileMenu = gtk_menu_item_new_with_mnemonic("_Compile"); + CompileAsMenu = gtk_menu_item_new_with_mnemonic("_Compile As..."); // Appending menu items to Compile menu - gtk_menu_shell_append(GTK_MENU_SHELL (compile), MNU_COMPILE); - gtk_menu_shell_append(GTK_MENU_SHELL (compile), MNU_COMPILE_AS); + gtk_menu_shell_append(GTK_MENU_SHELL (Compile), CompileMenu); + gtk_menu_shell_append(GTK_MENU_SHELL (Compile), CompileAsMenu); - // Creating labels for Simulation Menu - MNU_MANUAL = gtk_menu_item_new_with_label("Manual..."); - MNU_ABOUT = gtk_menu_item_new_with_label("About..."); + // Creating labels for Help Menu + ManualMenu = gtk_menu_item_new_with_mnemonic("_Manual..."); + AboutMenu = gtk_menu_item_new_with_mnemonic("_About..."); // Appending menu items to Help menu - gtk_menu_shell_append(GTK_MENU_SHELL (help), MNU_MANUAL); - gtk_menu_shell_append(GTK_MENU_SHELL (help), MNU_ABOUT); + gtk_menu_shell_append(GTK_MENU_SHELL (Help), ManualMenu); + gtk_menu_shell_append(GTK_MENU_SHELL (Help), AboutMenu); // Creating labels for Simulation Menu - MNU_SIMULATION_MODE = gtk_check_menu_item_new_with_label("Simulation Mode"); - MNU_START_SIMULATION = gtk_menu_item_new_with_label("Start Real-Time Simulation"); - MNU_STOP_SIMULATION = gtk_menu_item_new_with_label("Halt Simulation"); - MNU_SINGLE_CYCLE = gtk_menu_item_new_with_label("Single Cycle"); + SimulationModeMenu = gtk_check_menu_item_new_with_mnemonic("_Simulation Mode"); + StartSimulationMenu = gtk_menu_item_new_with_mnemonic("_Start Real-Time Simulation"); + StopSimulationMenu = gtk_menu_item_new_with_mnemonic("_Halt Simulation"); + SingleCycleMenu = gtk_menu_item_new_with_mnemonic("_Single Cycle"); // Appending menu items to Simulate menu and adding separators - gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_SIMULATION_MODE); - gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_START_SIMULATION); - gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_STOP_SIMULATION); - gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_SINGLE_CYCLE); + gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), SimulationModeMenu); + gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), StartSimulationMenu); + gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), StopSimulationMenu); + gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), SingleCycleMenu); SimulateMenuSeparator = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(SimulateMenu), SimulateMenuSeparator); // Creating submenus for each menu gtk_menu_item_set_submenu(GTK_MENU_ITEM(FileLabel), FileMenu); gtk_menu_item_set_submenu(GTK_MENU_ITEM(EditLabel), EditMenu); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(SettingsLabel), settings); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(SettingsLabel), Settings); gtk_menu_item_set_submenu(GTK_MENU_ITEM(InstructionLabel), InstructionMenu); gtk_menu_item_set_submenu(GTK_MENU_ITEM(SimulateLabel), SimulateMenu); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(CompileLabel), compile); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(HelpLabel), help); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(CompileLabel), Compile); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(HelpLabel), Help); // Appending the menu item to the menu bar gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), FileLabel); @@ -401,7 +510,8 @@ HMENU MakeMainWindowMenus(void) // Packing the menu bar into the box for alignment gtk_box_pack_start(GTK_BOX(MenuBox), TopMenu, FALSE, FALSE, 0); - + AddMenuAccelerators (); + return MenuBox; } @@ -481,23 +591,22 @@ void MakeMainWindowControls(void) /// Adding DrawWindow to pane gtk_container_add (GTK_CONTAINER(viewport), DrawWindow); gtk_container_add (GTK_CONTAINER(ScrollWindow), viewport); - gtk_paned_add1 (GTK_PANED (pane), ScrollWindow); - gtk_paned_set_position (GTK_PANED (pane), 0); - + gtk_paned_pack1 (GTK_PANED (pane), ScrollWindow, TRUE, TRUE); + gtk_paned_set_position (GTK_PANED (pane), 0); /// Appending tree view to pane and pane to grid gtk_paned_pack2 (GTK_PANED(pane), view, FALSE, FALSE); - gtk_paned_set_position (GTK_PANED (pane), 250); + gtk_paned_set_position (GTK_PANED (pane), 400); gtk_grid_attach (GTK_GRID (grid), pane, 0, 0, 1, 1); /// Creating Status Bar and attaching to grid StatusBar = gtk_statusbar_new(); gtk_statusbar_push (GTK_STATUSBAR (StatusBar), - gtk_statusbar_get_context_id (GTK_STATUSBAR (StatusBar), "Introduction"), - "LDMicro Started"); + gtk_statusbar_get_context_id (GTK_STATUSBAR (StatusBar), + "Introduction"), "LDMicro Started"); /// Appneding Status Bar to box which is then added to Main Window - gtk_box_pack_start(GTK_BOX(PackBox), grid, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(PackBox), grid, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(PackBox), StatusBar, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(MainWindow), PackBox); } @@ -665,66 +774,66 @@ void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly, BOOL canSetOnly, BOOL canDelete, BOOL canInsertEnd, BOOL canInsertOther, BOOL canPushDown, BOOL canPushUp, BOOL canInsertComment) { - EnableMenuItem(EditMenu, MNU_PUSH_RUNG_UP, + EnableMenuItem(EditMenu, PushRungUpMenu, canPushUp ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(EditMenu, MNU_PUSH_RUNG_DOWN, + EnableMenuItem(EditMenu, PushRungDownMenu, canPushDown ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(EditMenu, MNU_DELETE_RUNG, + EnableMenuItem(EditMenu, DeleteRungMenu, (Prog.numRungs > 1) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(InstructionMenu, MNU_NEGATE, + EnableMenuItem(InstructionMenu, NegateMenu, canNegate ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(InstructionMenu, MNU_MAKE_NORMAL, + EnableMenuItem(InstructionMenu, MakeNormalMenu, canNormal ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(InstructionMenu, MNU_MAKE_RESET_ONLY, + EnableMenuItem(InstructionMenu, MakeResetOnlyMenu, canResetOnly ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(InstructionMenu, MNU_MAKE_SET_ONLY, + EnableMenuItem(InstructionMenu, MakeSetOnlyMenu, canSetOnly ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(InstructionMenu, MNU_INSERT_COMMENT, + EnableMenuItem(InstructionMenu, InsertCommentMenu, canInsertComment ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(EditMenu, MNU_DELETE_ELEMENT, + EnableMenuItem(EditMenu, DeleteElementMenu, canDelete ? MF_ENABLED : MF_GRAYED); int t; t = canInsertEnd ? MF_ENABLED : MF_GRAYED; - EnableMenuItem(InstructionMenu, MNU_INSERT_COIL, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_RES, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_MOV, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_ADD, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_SUB, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_MUL, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_DIV, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_CTC, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_PERSIST, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_READ_ADC, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_SET_PWM, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_MASTER_RLY, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_SHIFT_REG, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_LUT, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_PWL, t); + EnableMenuItem(InstructionMenu, InsertCoilMenu, t); + EnableMenuItem(InstructionMenu, InsertResMenu, t); + EnableMenuItem(InstructionMenu, InsertMovMenu, t); + EnableMenuItem(InstructionMenu, InsertAddMenu, t); + EnableMenuItem(InstructionMenu, InsertSubMenu, t); + EnableMenuItem(InstructionMenu, InsertMulMenu, t); + EnableMenuItem(InstructionMenu, InsertDivMenu, t); + EnableMenuItem(InstructionMenu, InsertCtcMenu, t); + EnableMenuItem(InstructionMenu, InsertPersistMenu, t); + EnableMenuItem(InstructionMenu, InsertReadAdcMenu, t); + EnableMenuItem(InstructionMenu, InsertSetPwmMenu, t); + EnableMenuItem(InstructionMenu, InsertMasterRlyMenu, t); + EnableMenuItem(InstructionMenu, InsertShiftRegMenu, t); + EnableMenuItem(InstructionMenu, InsertLutMenu, t); + EnableMenuItem(InstructionMenu, InsertPwlMenu, t); t = canInsertOther ? MF_ENABLED : MF_GRAYED; - EnableMenuItem(InstructionMenu, MNU_INSERT_TON, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_TOF, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_OSR, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_OSF, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_RTO, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_CONTACTS, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_CTU, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_CTD, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_EQU, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_NEQ, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_GRT, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_GEQ, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_LES, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_LEQ, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_SHORT, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_OPEN, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_UART_SEND, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_UART_RECV, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_FMTD_STR, t); + EnableMenuItem(InstructionMenu, InsertTonMenu, t); + EnableMenuItem(InstructionMenu, InsertTofMenu, t); + EnableMenuItem(InstructionMenu, InsertOsrMenu, t); + EnableMenuItem(InstructionMenu, InsertOsfMenu, t); + EnableMenuItem(InstructionMenu, InsertRtoMenu, t); + EnableMenuItem(InstructionMenu, InsertContactsMenu, t); + EnableMenuItem(InstructionMenu, InsertCtuMenu, t); + EnableMenuItem(InstructionMenu, InsertCtdMenu, t); + EnableMenuItem(InstructionMenu, InsertEquMenu, t); + EnableMenuItem(InstructionMenu, InsertNeqMenu, t); + EnableMenuItem(InstructionMenu, InsertGrtMenu, t); + EnableMenuItem(InstructionMenu, InsertGeqMenu, t); + EnableMenuItem(InstructionMenu, InsertLesMenu, t); + EnableMenuItem(InstructionMenu, InsertLeqMenu, t); + EnableMenuItem(InstructionMenu, InsertShortMenu, t); + EnableMenuItem(InstructionMenu, InsertOpenMenu, t); + EnableMenuItem(InstructionMenu, InsertUartSendMenu, t); + EnableMenuItem(InstructionMenu, InsertUartRecvMenu, t); + EnableMenuItem(InstructionMenu, InsertFmtdStrMenu, t); } //----------------------------------------------------------------------------- @@ -732,8 +841,8 @@ void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly, //----------------------------------------------------------------------------- void SetUndoEnabled(BOOL undoEnabled, BOOL redoEnabled) { - // EnableMenuItem(EditMenu, MNU_UNDO, undoEnabled ? MF_ENABLED : MF_GRAYED); - // EnableMenuItem(EditMenu, MNU_REDO, redoEnabled ? MF_ENABLED : MF_GRAYED); + EnableMenuItem(EditMenu, UndoMenu, undoEnabled ? MF_ENABLED : MF_GRAYED); + EnableMenuItem(EditMenu, RedoMenu, redoEnabled ? MF_ENABLED : MF_GRAYED); } //----------------------------------------------------------------------------- @@ -744,24 +853,24 @@ void ToggleSimulationMode(void) { InSimulationMode = !InSimulationMode; if(InSimulationMode) { - EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_ENABLED); - EnableMenuItem(SimulateMenu, MNU_SINGLE_CYCLE, MF_ENABLED); + EnableMenuItem(SimulateMenu, StartSimulationMenu, MF_ENABLED); + EnableMenuItem(SimulateMenu, SingleCycleMenu, MF_ENABLED); - EnableMenuItem(FileMenu, MNU_OPEN, MF_GRAYED); - EnableMenuItem(FileMenu, MNU_SAVE, MF_GRAYED); - EnableMenuItem(FileMenu, MNU_SAVE_AS, MF_GRAYED); - EnableMenuItem(FileMenu, MNU_NEW, MF_GRAYED); - EnableMenuItem(FileMenu, MNU_EXPORT, MF_GRAYED); + EnableMenuItem(FileMenu, OpenMenu, MF_GRAYED); + EnableMenuItem(FileMenu, SaveMenu, MF_GRAYED); + EnableMenuItem(FileMenu, SaveAsMenu_AS, MF_GRAYED); + EnableMenuItem(FileMenu, NewMenu, MF_GRAYED); + EnableMenuItem(FileMenu, ExportMenu, MF_GRAYED); EnableMenuItem(TopMenu, EditMenu, MF_GRAYED); - EnableMenuItem(TopMenu, settings, MF_GRAYED); + EnableMenuItem(TopMenu, Settings, MF_GRAYED); EnableMenuItem(TopMenu, InstructionMenu, MF_GRAYED); - EnableMenuItem(TopMenu, compile, MF_GRAYED); + EnableMenuItem(TopMenu, Compile, MF_GRAYED); - CheckMenuItem(SimulateMenu, MNU_SIMULATION_MODE, MF_CHECKED); + CheckMenuItem(SimulateMenu, SimulationModeMenu, MF_CHECKED); // ClearSimulationData(); // simulation.cpp, ldmicro.h - // Recheck InSimulationMode, because there could have been a compile + // Recheck InSimulationMode, because there could have been a Compile // error, which would have kicked us out of simulation mode. // if(UartFunctionUsed() && InSimulationMode) { // ShowUartSimulationWindow(); // simulate.cpp @@ -771,22 +880,22 @@ void ToggleSimulationMode(void) RealTimeSimulationRunning = FALSE; // KillTimer(MainWindow, TIMER_SIMULATE); - EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_GRAYED); - EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_GRAYED); - EnableMenuItem(SimulateMenu, MNU_SINGLE_CYCLE, MF_GRAYED); + EnableMenuItem(SimulateMenu, StartSimulationMenu, MF_GRAYED); + EnableMenuItem(SimulateMenu, StopSimulationMenu, MF_GRAYED); + EnableMenuItem(SimulateMenu, SingleCycleMenu, MF_GRAYED); - EnableMenuItem(FileMenu, MNU_OPEN, MF_ENABLED); - EnableMenuItem(FileMenu, MNU_SAVE, MF_ENABLED); - EnableMenuItem(FileMenu, MNU_SAVE_AS, MF_ENABLED); - EnableMenuItem(FileMenu, MNU_NEW, MF_ENABLED); - EnableMenuItem(FileMenu, MNU_EXPORT, MF_ENABLED); + EnableMenuItem(FileMenu, OpenMenu, MF_ENABLED); + EnableMenuItem(FileMenu, SaveMenu, MF_ENABLED); + EnableMenuItem(FileMenu, SaveAsMenu_AS, MF_ENABLED); + EnableMenuItem(FileMenu, NewMenu, MF_ENABLED); + EnableMenuItem(FileMenu, ExportMenu, MF_ENABLED); EnableMenuItem(TopMenu, EditMenu, MF_ENABLED); - EnableMenuItem(TopMenu, settings, MF_ENABLED); + EnableMenuItem(TopMenu, Settings, MF_ENABLED); EnableMenuItem(TopMenu, InstructionMenu, MF_ENABLED); - EnableMenuItem(TopMenu, compile, MF_ENABLED); + EnableMenuItem(TopMenu, Compile, MF_ENABLED); - CheckMenuItem(SimulateMenu, MNU_SIMULATION_MODE, MF_UNCHECKED); + CheckMenuItem(SimulateMenu, SimulationModeMenu, MF_UNCHECKED); // if(UartFunctionUsed()) { // DestroyUartSimulationWindow(); @@ -836,18 +945,18 @@ void RefreshControlsToSettings(void) } for(i = 0; i < NUM_SUPPORTED_MCUS; i++) { if(&SupportedMcus[i] == Prog.mcu) { - CheckMenuItem(ProcessorMenu, MNU_PROCESSOR[i], MF_CHECKED); + CheckMenuItem(ProcessorMenu, ProcessorMenuItems[i], MF_CHECKED); } else { - CheckMenuItem(ProcessorMenu, MNU_PROCESSOR[i], MF_UNCHECKED); + CheckMenuItem(ProcessorMenu, ProcessorMenuItems[i], MF_UNCHECKED); } } // `(no microcontroller)' setting if (!Prog.mcu){ - CheckMenuItem(ProcessorMenu, MNU_PROCESSOR[NUM_SUPPORTED_MCUS], MF_CHECKED); + CheckMenuItem(ProcessorMenu, ProcessorMenuItems[NUM_SUPPORTED_MCUS], MF_CHECKED); } else { - CheckMenuItem(ProcessorMenu, MNU_PROCESSOR[NUM_SUPPORTED_MCUS], MF_UNCHECKED); + CheckMenuItem(ProcessorMenu, ProcessorMenuItems[NUM_SUPPORTED_MCUS], MF_UNCHECKED); } } @@ -921,8 +1030,8 @@ void MainWindowResized(void) void StartSimulation(void) { RealTimeSimulationRunning = TRUE; - EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_GRAYED); - EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_ENABLED); + EnableMenuItem(SimulateMenu, StartSimulationMenu, MF_GRAYED); + EnableMenuItem(SimulateMenu, StopSimulationMenu, MF_ENABLED); // StartSimulationTimer(); UpdateMainWindowTitleBar(); } @@ -935,8 +1044,8 @@ void StopSimulation(void) { RealTimeSimulationRunning = FALSE; - EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_ENABLED); - EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_GRAYED); + EnableMenuItem(SimulateMenu, StartSimulationMenu, MF_ENABLED); + EnableMenuItem(SimulateMenu, StopSimulationMenu, MF_GRAYED); // KillTimer(MainWindow, TIMER_SIMULATE); UpdateMainWindowTitleBar(); diff --git a/ldmicro/miscutil.cpp b/ldmicro/miscutil.cpp index 092f606..777b721 100644 --- a/ldmicro/miscutil.cpp +++ b/ldmicro/miscutil.cpp @@ -23,9 +23,11 @@ #include "linuxUI.h" #include <stdio.h> #include <stdlib.h> - +#include <iostream> #include "ldmicro.h" +using namespace std; + // We should display messages to the user differently if we are running // interactively vs. in batch (command-line) mode. BOOL RunningInBatchMode = FALSE; diff --git a/ldmicro/reg/t.pl b/ldmicro/reg/t.pl new file mode 100644 index 0000000..b388e96 --- /dev/null +++ b/ldmicro/reg/t.pl @@ -0,0 +1,205 @@ + 0:set bit '$mcr' + 1:# + 2:# start rung 2 + 3:let bit '$rung_top' := '$mcr' + 4: + 5:# start series [ + 6:if not 'Rosc' { + 7: clear bit '$rung_top' + 8:} + 9: + 10:if not '$Tof_antiglitch' { + 11: let var 'Tof' := 9 + 12:} + 13:set bit '$Tof_antiglitch' + 14:if not '$rung_top' { + 15: if 'Tof' < 9 { + 16: increment 'Tof' + 17: set bit '$rung_top' + 18: } + 19:} else { + 20: let var 'Tof' := 0 + 21:} + 22: + 23:if '$rung_top' { + 24: if 'Ton' < 9 { + 25: increment 'Ton' + 26: clear bit '$rung_top' + 27: } + 28:} else { + 29: let var 'Ton' := 0 + 30:} + 31: + 32:if '$rung_top' { + 33: clear bit 'Rosc' + 34:} else { + 35: set bit 'Rosc' + 36:} + 37: + 38:# ] finish series + 39:# + 40:# start rung 3 + 41:let bit '$rung_top' := '$mcr' + 42: + 43:# start series [ + 44:if not 'Rosc' { + 45: clear bit '$rung_top' + 46:} + 47: + 48:if not 'Xup' { + 49: clear bit '$rung_top' + 50:} + 51: + 52:if '$rung_top' { + 53: if not '$oneShot_0000' { + 54: increment 'Ccnt' + 55: } + 56:} + 57:let bit '$oneShot_0000' := '$rung_top' + 58:if 'Ccnt' < 20 { + 59: clear bit '$rung_top' + 60:} else { + 61: set bit '$rung_top' + 62:} + 63: + 64:if 'Trto' < 999 { + 65: if '$rung_top' { + 66: increment 'Trto' + 67: } + 68: clear bit '$rung_top' + 69:} else { + 70: set bit '$rung_top' + 71:} + 72: + 73:let bit 'Yup' := '$rung_top' + 74: + 75:# ] finish series + 76:# + 77:# start rung 4 + 78:let bit '$rung_top' := '$mcr' + 79: + 80:# start series [ + 81:if not 'Rosc' { + 82: clear bit '$rung_top' + 83:} + 84: + 85:if not 'Xdown' { + 86: clear bit '$rung_top' + 87:} + 88: + 89:if '$rung_top' { + 90: if not '$oneShot_0001' { + 91: let var '$scratch' := 1 + 92: let var 'Ccnt' := 'Ccnt' - '$scratch' + 93: } + 94:} + 95:let bit '$oneShot_0001' := '$rung_top' + 96:if 'Ccnt' < 10 { + 97: clear bit '$rung_top' + 98:} else { + 99: set bit '$rung_top' +100:} +101: +102:let bit 'Ydown' := '$rung_top' +103: +104:# ] finish series +105:# +106:# start rung 5 +107:let bit '$rung_top' := '$mcr' +108: +109:# start series [ +110:if not 'Xres' { +111: clear bit '$rung_top' +112:} +113: +114:# start parallel [ +115:clear bit '$parOut_0000' +116:let bit '$parThis_0000' := '$rung_top' +117:let bit '$scratch' := '$parThis_0000' +118:if '$oneShot_0002' { +119: clear bit '$parThis_0000' +120:} +121:let bit '$oneShot_0002' := '$scratch' +122: +123:if '$parThis_0000' { +124: set bit '$parOut_0000' +125:} +126:let bit '$parThis_0000' := '$rung_top' +127:let bit '$scratch' := '$parThis_0000' +128:if not '$parThis_0000' { +129: if '$oneShot_0003' { +130: set bit '$parThis_0000' +131: } +132:} else { +133: clear bit '$parThis_0000' +134:} +135:let bit '$oneShot_0003' := '$scratch' +136: +137:if '$parThis_0000' { +138: set bit '$parOut_0000' +139:} +140:let bit '$rung_top' := '$parOut_0000' +141:# ] finish parallel +142:if '$rung_top' { +143: let var 'Trto' := 0 +144:} +145: +146:# ] finish series +147:# +148:# start rung 6 +149:let bit '$rung_top' := '$mcr' +150: +151:# start series [ +152:if not 'Rosc' { +153: clear bit '$rung_top' +154:} +155: +156:if '$rung_top' { +157: if not '$oneShot_0004' { +158: increment 'Ccirc' +159: if 'Ccirc' < 8 { +160: } else { +161: let var 'Ccirc' := 0 +162: } +163: } +164:} +165:let bit '$oneShot_0004' := '$rung_top' +166: +167:# ] finish series +168:# +169:# start rung 7 +170:let bit '$rung_top' := '$mcr' +171: +172:# start series [ +173:let var '$scratch2' := 3 +174:if 'Ccirc' == '$scratch2' { +175:} else { +176: clear bit '$rung_top' +177:} +178: +179:let bit '$scratch' := '$rung_top' +180:if not '$rung_top' { +181: if '$oneShot_0005' { +182: set bit '$rung_top' +183: } +184:} else { +185: clear bit '$rung_top' +186:} +187:let bit '$oneShot_0005' := '$scratch' +188: +189:if not '$Tpulse_antiglitch' { +190: let var 'Tpulse' := 19 +191:} +192:set bit '$Tpulse_antiglitch' +193:if not '$rung_top' { +194: if 'Tpulse' < 19 { +195: increment 'Tpulse' +196: set bit '$rung_top' +197: } +198:} else { +199: let var 'Tpulse' := 0 +200:} +201: +202:let bit 'Ypulse' := '$rung_top' +203: +204:# ] finish series diff --git a/ldmicro/undoredo.cpp b/ldmicro/undoredo.cpp index 69831d8..2a3c2fd 100644 --- a/ldmicro/undoredo.cpp +++ b/ldmicro/undoredo.cpp @@ -25,9 +25,12 @@ #include "linuxUI.h" #include <stdio.h> #include <stdlib.h> +#include <iostream> #include "ldmicro.h" +using namespace std; + // Store a `deep copy' of the entire program before every change, in a // circular buffer so that the first one scrolls out as soon as the buffer // is full and we try to push another one. |