NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
terminal.cpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2018 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19
20#ifdef __GNUG__
21#pragma implementation "wxterm.h"
22#endif
23
24// For compilers that support precompilation, includes "wx/wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
28#pragma hdrstop
29#endif
30
31// for all others, include the necessary headers (this file is usually all you
32// need because it includes almost all "standard" wxWindows headers
33#ifndef WX_PRECOMP
34#include "wx/wx.h"
35#endif
36
37#include <wx/timer.h>
38
39#include <ctype.h>
40
41#include "gterm.hpp"
42#include "terminal.hpp"
43#include "terminalcalltip.hpp"
44#include <wx/clipbrd.h>
45#include <wx/dataobj.h>
46#include "../globals.hpp"
47
48void WinMessageBeep();
49
50#define CURSOR_BLINK_DEFAULT_TIMEOUT 500
51#define CURSOR_BLINK_MAX_TIMEOUT 2000
52#define KERNEL_THREAD_STACK_SIZE 4194304 // Bytes
53#define MEASURING_STRING "The quick brown fox jumps over a lazy dog."
54
55BEGIN_EVENT_TABLE(NumeReTerminal, wxWindow)
56 EVT_PAINT (NumeReTerminal::OnPaint)
57 EVT_CHAR (NumeReTerminal::OnChar)
58 EVT_LEFT_DOWN (NumeReTerminal::OnLeftDown)
59 EVT_MOUSE_CAPTURE_LOST (NumeReTerminal::OnLoseMouseCapture)
60 EVT_LEFT_UP (NumeReTerminal::OnLeftUp)
62// EVT_ENTER_WINDOW (NumeReTerminal::OnEnter)
63 EVT_TIMER (-1, NumeReTerminal::OnTimer)
64 EVT_KEY_DOWN (NumeReTerminal::OnKeyDown)
65 EVT_SIZE (NumeReTerminal::OnSize)
66 EVT_SET_FOCUS (NumeReTerminal::OnGainFocus)
67 EVT_KILL_FOCUS (NumeReTerminal::OnLoseFocus)
68 EVT_CLOSE (NumeReTerminal::OnClose)
70
71
72
85NumeReTerminal::NumeReTerminal(wxWindow* parent, wxWindowID id, Options* _option, const wxString& sPath, const wxPoint& pos, int width, int height, const wxString& name) : wxWindow(parent, id, pos, wxSize(-1, -1), wxWANTS_CHARS, name), GenericTerminal(width, height)
86{
87 // Bind the thread update event to the corresponding handler function
88 Bind(wxEVT_THREAD, &NumeReTerminal::OnThreadUpdate, this);
89
90 m_init = 1;
91
92 // Initialize the terminal member variables
93 m_inUpdateSize = false;
94 m_isActive = false;
95 m_isBusy = false;
96 m_scrollBarWidth = wxSystemSettings::GetMetric(wxSYS_VSCROLL_ARROW_X);
97 m_curDC = nullptr;
98 m_charsInLine = width;
99 m_linesDisplayed = height;
100 m_selecting = false;
101 m_selx1 = m_sely1 = m_selx2 = m_sely2 = 0;
102 m_marking = false;
103 m_curX = -1;
104 m_curY = -1;
105 m_curBlinkRate = CURSOR_BLINK_DEFAULT_TIMEOUT;
106 m_timer.SetOwner(this);
107 m_boldStyle = FONT;
108 m_options = _option;
109 m_width = width;
110 m_height = height;
111 m_bitmap = nullptr;
112 m_wxParent = nullptr;
113 m_callTip = nullptr;
114
115 SetCursor(wxCursor(wxCURSOR_IBEAM));
116
117 // Start the kernel
118 _kernel.StartUp(this, sPath.ToStdString(), getSyntax()->getFunctions());
119 m_options->copySettings(_kernel.getKernelSettings());
120 m_useSmartSense = m_options->getSetting(SETTING_B_SMARTSENSE).active();
121
122 // Update the terminal colors
123 UpdateColors();
124
125 // Initialize the relevant fonts
126 SetFont(m_options->toFont(m_options->getSetting(SETTING_S_TERMINALFONT).stringval()));
127
128 m_callTip = new TerminalCallTip(this, wxSize(100*m_charWidth, 2*m_charHeight));
129 m_callTip->ChangeFont(m_options->toFont(m_options->getSetting(SETTING_S_TERMINALFONT).stringval()));
130 SetClientSize(m_charsInLine * 8, m_linesDisplayed * 16);
131 // 10pt Courier New is 8 pixels wide and 16 pixels high... set up
132 // a default client size to match
133 UpdateSize();
134
135 // Start the cursor blink rate timer
136 if (m_curBlinkRate)
137 m_timer.Start(m_curBlinkRate);
138
139#ifdef DO_LOG
140 // Activate logging
141 wxLog::SetActiveTarget(new wxLogWindow(this, "Logger"));
142#endif
143
144 // Start the kernel thread
145 StartKernelTask();
146
147 // Initialize the kernel-specific veriables
148 m_KernelStatus = NumeReKernel::NUMERE_DONE;
149 m_bCommandAvailable = false;
150 m_bTableEditAvailable = false;
151 m_bTableEditCanceled = false;
152 m_nDebuggerCode = 0;
153 m_sCommandLine = "";
154 m_sAnswer = "";
155
156 // Copy the plugin definitions to the syntax stylers
157 {
158 wxCriticalSectionLocker lock(m_kernelCS);
159 getSyntax()->addPlugins(_kernel.getPluginCommands());
160 }
161 m_init = 0;
162}
163
164
169{
170 if (m_bitmap)
171 {
172 m_memDC.SelectObject(wxNullBitmap);
173 delete m_bitmap;
174 }
175}
176
177
185std::vector<std::string> NumeReTerminal::getPathSettings()
186{
187 wxCriticalSectionLocker lock(m_kernelCS);
188 std::vector<std::string> vPaths = _kernel.getPathSettings();
189 return vPaths;
190}
191
192
200const std::vector<Package>& NumeReTerminal::getInstalledPackages()
201{
202 wxCriticalSectionLocker lock(m_kernelCS);
204}
205
206
214std::map<std::string, std::string> NumeReTerminal::getMenuMap()
215{
216 wxCriticalSectionLocker lock(m_kernelCS);
217 return _kernel.getMenuMap();
218}
219
220
230void NumeReTerminal::updatePackage(const std::string& package)
231{
232 wxCriticalSectionLocker lock(m_kernelCS);
234}
235
236
246{
247 wxCriticalSectionLocker lock(m_kernelCS);
248 _kernel.table = _table;
250}
251
252
263void NumeReTerminal::addBreakpoint(const std::string& _sFilename, size_t nLine)
264{
265 wxCriticalSectionLocker lock(m_kernelCS);
267}
268
269
280void NumeReTerminal::removeBreakpoint(const std::string& _sFilename, size_t nLine)
281{
282 wxCriticalSectionLocker lock(m_kernelCS);
284}
285
286
295void NumeReTerminal::clearBreakpoints(const std::string& _sFilename)
296{
297 wxCriticalSectionLocker lock(m_kernelCS);
299}
300
301
310std::string NumeReTerminal::getDocumentation(const std::string& sCommand)
311{
312 wxCriticalSectionLocker lock(m_kernelCS);
313 return _kernel.getDocumentation(sCommand);
314}
315
316
324std::vector<std::string> NumeReTerminal::getDocIndex()
325{
326 wxCriticalSectionLocker lock(m_kernelCS);
327 return _kernel.getDocIndex();
328}
329
330
339std::map<std::string, std::string> NumeReTerminal::getPluginLanguageStrings()
340{
341 wxCriticalSectionLocker lock(m_kernelCS);
343}
344
345
354std::map<std::string, std::string> NumeReTerminal::getFunctionLanguageStrings()
355{
356 wxCriticalSectionLocker lock(m_kernelCS);
358}
359
360
370{
371 wxCriticalSectionLocker lock(m_kernelCS);
372 return _kernel.getVariableList();
373}
374
375
384{
385 wxCriticalSectionLocker lock(m_kernelCS);
387 return _option;
388}
389
390
400{
401 wxCriticalSectionLocker lock(m_kernelCS);
402 _kernel.setKernelSettings(_settings);
404}
405
406
416{
417 if (CreateThread(wxTHREAD_JOINABLE, KERNEL_THREAD_STACK_SIZE) != wxTHREAD_NO_ERROR)
418 {
419 wxLogError("Could not create kernel thread!");
420 return;
421 }
422 if (GetThread()->Run() != wxTHREAD_NO_ERROR)
423 {
424 wxLogError("Could not run the kernel thread!");
425 return;
426 }
427}
428
429
438wxThread::ExitCode NumeReTerminal::Entry()
439{
440 std::string sCommand;
441 bool bCommandAvailable;
442 bool updateLibrary;
445 _kernel.printPreFmt("|\n|<- ");
446
447 // Test repeatedly, whether the thread shall terminate
448 while (!GetThread()->TestDestroy())
449 {
450 // Perform this loop only 10 times a second
451 Sleep(100);
452
453 // start critical section for reading the command and the boolean
454 {
455 wxCriticalSectionLocker lock(m_kernelCS);
456
457 bCommandAvailable = m_bCommandAvailable;
458 sCommand = m_sCommandLine;
459 m_bCommandAvailable = false;
460
461 updateLibrary = m_updateProcedureLibrary;
463 m_sCommandLine.clear();
464
465 if (!sCommand.length() && bCommandAvailable)
466 {
468 wxQueueEvent(GetEventHandler(), new wxThreadEvent());
469 continue;
470 }
471 }
472
473 // Refreshing the library before any command is executed
474 if (updateLibrary)
475 {
476 // update the internal procedure library if needed
478 }
479
480 // A command is available
481 if (bCommandAvailable)
482 {
483 // This is the actual evaluating function. It is called from this second thread regularly (every 100ms) and
484 // enters the function, if a command was passed to the terminal.
485 m_KernelStatus = _kernel.MainLoop(sCommand);
486
487 /*if (m_KernelStatus > 0) // these are valid status values (0 = error, -1 = quit)
488 {
489 wxCriticalSectionLocker lock(m_kernelCS);
490
491 switch (m_KernelStatus)
492 {
493 case NumeReKernel::NUMERE_DONE:
494 m_sAnswer += _kernel.ReadAnswer();
495 break;
496 default:
497 break;
498 //All others
499 }
500 }
501 else */
503 {
504 break;
505 }
506
507 // Notify the event handler that there's an update
508 wxQueueEvent(GetEventHandler(), new wxThreadEvent());
509 }
510
511 // During idle times so that these tasks don't interfere with the main evaluation routine
512 // do the following:
514 _kernel.Autosave(); // save the cache
515
516 }
517
518 // The thread will terminate
519 // Close the session and inform the thread handler
522 wxQueueEvent(GetEventHandler(), new wxThreadEvent());
523 return (wxThread::ExitCode)0;
524}
525
526
536{
537 if (GetThread() && GetThread()->IsRunning())
538 {
539 erase_line();
540 GetThread()->Delete();
541 }
542}
543
544
554void NumeReTerminal::OnClose(wxCloseEvent& event)
555{
556 if (GetThread() && GetThread()->IsRunning())
557 GetThread()->Wait();
558 wxMilliSleep(200);
559 Destroy();
560}
561
562
573void NumeReTerminal::OnThreadUpdate(wxThreadEvent& event)
574{
575 bool Closing = false;
576 bool changedSettings = false;
577 bool done = false;
578 bool refreshFunctionTree = false;
579 std::queue<NumeReTask> taskQueue;
580 std::string sAnswer = "";
581
582 // Get the kernel status and read the variables
583 // correspondingly
584 {
585 wxCriticalSectionLocker lock(m_kernelCS);
586 // Always read the complete task queue
587 if (_kernel.taskQueue.size())
588 taskQueue.swap(_kernel.taskQueue);
589
590 switch (m_KernelStatus)
591 {
594 return;
595 // fallthrough is intended
596 //case NumeReKernel::NUMERE_DONE:
597 // sAnswer = m_sAnswer + "\n|\n|<- ";
598 // done = true;
599 // break;
600 // fallthrough is intended
604 sAnswer = m_sAnswer + "|\n|<- ";
605 done = true;
606 break;
608 done = true;
609 sAnswer = "|<- ";
610 break;
612 Closing = true;
613 break;
614 default:
615 //All other cases
616 sAnswer = m_sAnswer;
617 }
618
619 // clear the communication variables
620 m_sAnswer.clear();
621 changedSettings = _kernel.SettingsModified();
622
623 // Warnings may be issued without kernel interaction
625 sAnswer += "|\n|<- ";
626
628 }
629
630 // Toggle the toolbar tools used for stopping and starting tasks
631 if (done)
632 {
633 Ready();
634 }
635
636 // If the kernel asks the application to terminate
637 // do this after 200msec
638 if (Closing)
639 {
640 wxMilliSleep(300);
641 m_wxParent->Close();
642 return;
643 }
644
645 // Evaluate the task queue. It will contain also the transmitted
646 // variables needed for the current task
647 while (taskQueue.size())
648 {
649 // Get the first task and remove it from
650 // the queue
651 NumeReTask task = taskQueue.front();
652 taskQueue.pop();
653
654 // Evaluate the current task depending on its type
655 switch (task.taskType)
656 {
658 {
659 if (task.sString.find(".png") != std::string::npos
660 || task.sString.find(".jpg") != std::string::npos
661 || task.sString.find(".jpeg") != std::string::npos
662 || task.sString.find(".gif") != std::string::npos
663 || task.sString.find(".bmp") != std::string::npos)
664 {
665 m_wxParent->openImage(wxFileName(task.sString));
666 }
667 else
668 {
669 m_wxParent->OpenSourceFile(wxArrayString(1, task.sString), task.nLine, _kernel.ReadOpenFileFlag());
670 }
671 break;
672 }
674 Refresh();
676 break;
679 break;
681 m_wxParent->openTable(task.table, task.sString, task.sString);
682 break;
685 break;
687 m_wxParent->editTable(task.table, task.sString);
688 break;
691 break;
693 refreshFunctionTree = true;
694 break;
697 break;
700 break;
703 break;
704 }
705 }
706
707 // This boolean is true, if the user switched a setting directly in the kernel
708 if (changedSettings)
709 {
712 }
713
714 // Refresh now the function tree (will avoid multiple
715 // refreshes in a single event loop).
716 if (refreshFunctionTree)
717 {
720 }
721
722 // To ensure that the user is able to read the answer
723 // scroll to the input location and process the kernel
724 // message
726
727 if (sAnswer == "|\n|<- " && GetTM()->getPreviousLine() == "|")
728 sAnswer = "|<- ";
729
730 ProcessOutput(sAnswer.length(), sAnswer);
731 Refresh();
732}
733
734
745bool
746NumeReTerminal::SetFont(const wxFont& font)
747{
748 if (font == m_normalFont)
749 return true;
750
751 m_init = 1;
752
753 // Set the passed font to all internal member variables
754 wxWindow::SetFont(font);
755 m_normalFont = font;
756 m_underlinedFont = font;
757 m_underlinedFont.SetUnderlined(true);
758 m_boldFont = GetFont();
759 m_boldFont.SetWeight(wxBOLD);
761 m_boldUnderlinedFont.SetUnderlined(true);
762
763 if (m_callTip)
764 m_callTip->ChangeFont(font);
765
766 m_init = 0;
767
768 // Resize the terminal, because the new
769 // font might have a new text extent
771
772 // Refresh the GUI element
773 Refresh();
774
775 return true;
776}
777
778
790void
792{
793 // Set the correct bold style
794 if (boldStyle == DEFAULT)
795 boldStyle = m_boldStyle;
796
797 // Beause the enumeration of the internal syntax and the syntax of the
798 // terminal is not identical, we need to use this lookup function
799 //
800 // We could also use a simple array to get the correct index, however
801 // using this switch with the correct enumerators is probably more safe.
802 for (size_t i = 0; i < 16; i++)
803 {
804 switch (i)
805 {
806 case 0:
808 break;
811 break;
814 break;
817 break;
820 break;
823 break;
826 break;
829 break;
832 break;
835 break;
838 break;
841 break;
844 break;
847 break;
848 default:
849 colors[i] = *wxBLACK;
850 }
851 }
852}
853
854
865void
867{
868 // Ensure that the new rate is reasonable
869 if (rate < 0 || rate > CURSOR_BLINK_MAX_TIMEOUT)
870 return;
871
872 m_init = 1;
873
874 // If the new rate is different from the old rate
875 // set it and restart the blinking timer
876 if (rate != m_curBlinkRate)
877 {
878 m_curBlinkRate = rate;
879 if (!m_curBlinkRate)
880 m_timer.Stop();
881 else
882 m_timer.Start(m_curBlinkRate);
883 }
884
885 m_init = 0;
886}
887
888
901void NumeReTerminal::pipe_command(const std::string& sCommand)
902{
903 wxCriticalSectionLocker lock(m_kernelCS);
904
905 // the commandline from tm...
906 m_sCommandLine = sCommand;
907
908 // only add the line to the history, if the kernel isn't currently fetching a line with NumeReKernel::getline()
910 m_wxParent->AddToHistory(sCommand);
911
912 m_bCommandAvailable = true;
913}
914
915
925void NumeReTerminal::pass_command(const std::string& command, bool isEvent)
926{
927 // Don't do anything if the command is emoty
928 if (!command.length())
929 return;
930
931#ifdef DO_LOG
932 if (isEvent)
933 wxLogDebug("Event: '%s'", command);
934#endif
935
936 // scroll to the input location
938
939 // erase the current line
940 erase_line();
941
942 Busy();
943
944 // Set the new command to the kernel and log it
945 wxCriticalSectionLocker lock(m_kernelCS);
946
947 if (!isEvent)
948 m_wxParent->AddToHistory(command);
949
950 m_sCommandLine = command;
951 m_bCommandAvailable = true;
952}
953
954
964NumeRe::Table NumeReTerminal::getTable(const std::string& sTableName)
965{
966 wxCriticalSectionLocker lock(m_kernelCS);
967 return _kernel.getTable(sTableName);
968}
969
970
980{
981 wxCriticalSectionLocker lock(m_kernelCS);
982 return _kernel.getStringTable(sStringTableName);
983}
984
985
995{
996 wxCriticalSectionLocker lock(m_kernelCS);
998}
999
1000
1011void
1012NumeReTerminal::OnChar(wxKeyEvent& event)
1013{
1014 if (!(GetMode() & PC) && event.AltDown())
1015 event.Skip();
1016 else
1017 {
1018 // if the user is scrolled up and they typed something, scroll
1019 // all the way to the bottom
1020 scrollToInput();
1021
1022 int keyCode = (int)event.GetKeyCode();
1023 int len = 1;
1024
1025 // Clear selection mode
1026 // can probably be modified to clear the selected input line
1027 if (HasSelection())
1028 {
1029 if (keyCode == WXK_DELETE || keyCode == WXK_BACK)
1030 {
1031 delSelected();
1033 return;
1034 }
1035 else if (keyCode < WXK_START)
1036 delSelected();
1037
1039 }
1040
1041 // Filter special keycodes
1042 if (filterKeyCodes(keyCode, event.ControlDown()))
1043 return;
1044
1045 std::string buf = " ";
1046 buf[0] = (char)keyCode;
1047
1049 wxClientDC dc(this);
1050
1051 m_curDC = &dc;
1052
1053 // Process the input line
1055
1056 m_curDC = nullptr;
1057 }
1058}
1059
1060
1070bool NumeReTerminal::filterKeyCodes(int keyCode, bool ctrlDown)
1071{
1072 // Filter special keycodes
1073 switch (keyCode)
1074 {
1075 case WXK_RETURN:
1076 {
1078 std::string sCommand = GetTM()->getCurrentInputLine();
1082 Refresh();
1083 Busy();
1084 pipe_command(sCommand);
1085 return true;
1086 }
1087 case WXK_BACK:
1089 if (GenericTerminal::bs())
1090 Refresh();
1091
1092 return true;
1093 case WXK_TAB:
1096 Refresh();
1097 return true;
1098 case WXK_LEFT:
1101 {
1102 Refresh();
1103 }
1104 return true;
1105 case WXK_RIGHT:
1108 {
1109 Refresh();
1110 }
1111 return true;
1112 case WXK_UP:
1115 {
1116 Refresh();
1117 }
1118 return true;
1119 case WXK_DOWN:
1122 {
1123 Refresh();
1124 }
1125 return true;
1126 case WXK_HOME:
1129 {
1130 Refresh();
1131 }
1132 return true;
1133 case WXK_END:
1136 {
1137 Refresh();
1138 }
1139 return true;
1140 case WXK_DELETE:
1143 Refresh();
1144
1145 return true;
1146 }
1147
1148 // Filter out any other non-ASCII characters
1149 if (keyCode >= WXK_START || keyCode < WXK_SPACE)
1150 return true;
1151
1152 // No special key code
1153 return false;
1154}
1155
1156
1165{
1167 {
1168 // Get the number of scrolled lines and scroll them down
1169 GenericTerminal::Scroll(GetTM()->GetNumLinesScrolled(), false);
1171 Refresh();
1172 }
1173}
1174
1175
1186void
1188{
1189 if (!(GetMode() & PC) && event.AltDown())
1190 event.Skip();
1191 else if (event.ControlDown() && event.ShiftDown())
1192 {
1193 // The keycode will be in uppercase letters,
1194 // if we require to push shift
1195 if (event.GetKeyCode() == 'C' || event.GetKeyCode() == 'V')
1196 {
1197 // Copy or paste
1198 if (event.GetKeyCode() == 'C' && HasSelection())
1199 copyText();
1200 else if (event.GetKeyCode() == 'V')
1201 pasteText();
1202
1203 return;
1204 }
1205 }
1206 else if (event.GetKeyCode() == WXK_ESCAPE)
1207 {
1208 if (m_isBusy)
1210 else
1211 {
1214 Refresh();
1215 }
1216 }
1217 else
1218 event.Skip();
1219}
1220
1221
1232void
1233NumeReTerminal::OnPaint(wxPaintEvent& WXUNUSED(event))
1234{
1235 wxPaintDC dc(this);
1236
1237#ifdef DO_LOG
1238 wxLogDebug("Painting");
1239#endif
1240
1241 wxDC* backup = m_curDC;
1242
1243 m_curDC = &dc;
1245 m_curDC = backup;
1246}
1247
1248
1259void
1260NumeReTerminal::OnLeftDown(wxMouseEvent& event)
1261{
1262 SetFocus();
1264 m_selx1 = m_selx2 = event.GetX() / m_charWidth;
1265 m_sely1 = m_sely2 = event.GetY() / m_charHeight;
1266 m_selecting = true;
1267 this->CaptureMouse();
1268}
1269
1270
1280void NumeReTerminal::OnLoseMouseCapture(wxMouseCaptureLostEvent& event)
1281{
1282 if (this->GetCapture() == this)
1283 {
1284 m_selecting = false;
1285 this->ReleaseMouse();
1286 Refresh();
1287 }
1288}
1289
1290
1301void
1302NumeReTerminal::OnLeftUp(wxMouseEvent& event)
1303{
1304 m_selecting = false;
1305 if (this->GetCapture() == this)
1306 {
1307 this->ReleaseMouse();
1308 Refresh();
1309 }
1311}
1312
1313
1324void
1326{
1327 if (m_selecting)
1328 {
1329 // Get the text coordinates of the mouse
1330 m_selx2 = event.GetX() / m_charWidth;
1331
1332 if (m_selx2 >= Width())
1333 m_selx2 = Width() - 1;
1334
1335 m_sely2 = event.GetY() / m_charHeight;
1336
1337 if (m_sely2 >= Height())
1338 m_sely2 = Height() - 1;
1339
1340 // Mark the selections
1341 if (event.AltDown())
1342 MarkSelection(true);
1343 else
1344 MarkSelection();
1345
1346 // Update the terminal
1347 // GenericTerminal::Update();
1348 Refresh();
1349 }
1350}
1351
1352
1361void NumeReTerminal::OnEnter(wxMouseEvent& event)
1362{
1363 if (g_findReplace != nullptr && g_findReplace->IsShown())
1364 {
1365 event.Skip();
1366 return;
1367 }
1368 this->SetFocus();
1369 event.Skip();
1370}
1371
1372
1381void
1383{
1384 if (!HasSelection() || m_selecting)
1385 return;
1386
1387 m_selx1 = m_sely1 = m_selx2 = m_sely2 = 0;
1388 GetTM()->unselectAll();
1389 Refresh();
1390}
1391
1392
1402void
1404{
1405 int x;
1406 int y;
1407
1408 m_marking = true;
1409
1410 // First deselect all text
1411 GetTM()->unselectAll();
1412
1413 // Now select the corresponding region
1414 if (bRectangular)
1415 {
1416 // Rectangular mode
1417 for (y = std::min(m_sely1, m_sely2); y <= std::max(m_sely1, m_sely2); y++)
1418 {
1419 for (x = std::min(m_selx1, m_selx2); x <= std::max(m_selx1, m_selx2); x++)
1420 {
1421 Select(x, y, 1);
1422 }
1423 }
1424 }
1425 else
1426 {
1427 // Line mode
1428 // More difficult
1429 if (m_sely1 == m_sely2)
1430 {
1431 for (x = std::min(m_selx1, m_selx2); x <= std::max(m_selx1, m_selx2); x++)
1432 Select(x, m_sely1, 1);
1433 }
1434 else if (m_sely1 < m_sely2)
1435 {
1436 for (x = m_selx1; x < Width(); x++)
1437 Select(x, m_sely1, 1);
1438
1439 for (y = m_sely1 + 1; y < m_sely2; y++)
1440 {
1441 for (x = 0; x < Width(); x++)
1442 Select(x, y, 1);
1443 }
1444
1445 for (x = 0; x <= m_selx2; x++)
1446 Select(x, m_sely2, 1);
1447 }
1448 else
1449 {
1450 for (x = 0; x <= m_selx1; x++)
1451 Select(x, m_sely1, 1);
1452
1453 for (y = m_sely2 + 1; y < m_sely1; y++)
1454 {
1455 for (x = 0; x < Width(); x++)
1456 Select(x, y, 1);
1457 }
1458
1459 for (x = m_selx2; x < Width(); x++)
1460 Select(x, m_sely2, 1);
1461 }
1462 }
1463
1464 m_marking = false;
1465}
1466
1467
1476bool
1478{
1479 return (m_selx1 != m_selx2 || m_sely1 != m_sely2);
1480}
1481
1482
1491wxString
1493{
1494 wxString sel = get_selected_text();
1495
1496 return sel;
1497}
1498
1499
1507{
1508 // Get the selection and store it in the clipboard
1509 wxString sSelection = GetSelection();
1510
1511 if (!sSelection.length())
1512 return;
1513
1514 if (wxTheClipboard->Open())
1515 {
1516 wxTheClipboard->SetData(new wxTextDataObject(sSelection));
1517 wxTheClipboard->Close();
1518 }
1519}
1520
1521
1529{
1530 // Get the text from the clipboard and process it as new input
1531 if (wxTheClipboard->Open())
1532 {
1533 if (wxTheClipboard->IsSupported(wxDF_TEXT))
1534 {
1535 wxTextDataObject data;
1536 wxTheClipboard->GetData(data);
1537 NumeReTerminal::ProcessInput(data.GetTextLength(), data.GetText().ToStdString());
1538 Refresh();
1539 }
1540
1541 wxTheClipboard->Close();
1542 }
1543}
1544
1545
1554{
1555 this->copyText();
1556 delSelected();
1558}
1559
1560
1577void
1578NumeReTerminal::DrawText(int fg_color, int bg_color, int flags, int x, int y, const std::string& sText)
1579{
1580 int
1581 t;
1582
1583 // Overwrite the passed colors depending on the flags
1584 if (flags & SELECTED)
1585 {
1586 fg_color = 0;
1587 bg_color = 15;
1588 }
1589
1590 if (flags & INVERSE)
1591 {
1592 t = fg_color;
1594 bg_color = t;
1595 }
1596
1597 if (!m_curDC)
1598 return;
1599
1600 // Convert std::string into wxString
1601 wxString
1602 str(sText);
1603
1604 // Set the correct font
1605 if (m_boldStyle != FONT)
1606 {
1607 if (flags & UNDERLINE)
1608 m_curDC->SetFont(m_underlinedFont);
1609 else
1610 m_curDC->SetFont(m_normalFont);
1611 }
1612 else
1613 {
1614 if (flags & BOLD)
1615 {
1616 if (flags & UNDERLINE)
1617 m_curDC->SetFont(m_boldUnderlinedFont);
1618 else
1619 m_curDC->SetFont(m_boldFont);
1620 }
1621 else
1622 {
1623 if (flags & UNDERLINE)
1624 m_curDC->SetFont(m_underlinedFont);
1625 else
1626 m_curDC->SetFont(m_normalFont);
1627 }
1628 }
1629
1630 // Convert x-y char coordinates into pixel coordinates
1631 x *= m_charWidth;
1632 y *= m_charHeight;
1633
1634 // Set colors and background mode
1635 m_curDC->SetBackgroundMode(wxSOLID);
1636 m_curDC->SetTextBackground(m_colors[bg_color]);
1637 m_curDC->SetTextForeground(m_colors[fg_color]);
1638
1639 // Draw the actual text
1640 m_curDC->DrawText(str, x, y);
1641 if (flags & BOLD && m_boldStyle == OVERSTRIKE)
1642 m_curDC->DrawText(str, x + 1, y);
1643}
1644
1645
1661void
1662NumeReTerminal::DoDrawCursor(int fg_color, int bg_color, int flags, int x, int y, unsigned char c)
1663{
1664 // Do nothing, if the terminal is scrolled up
1666 {
1667 return;
1668 }
1669 int
1670 t;
1671
1672 // Overwrite the passed colors depending on the flags
1673 if (flags & BOLD && m_boldStyle == COLOR)
1674 fg_color = (fg_color % 8) + 8;
1675
1676 if (flags & INVERSE)
1677 {
1678 t = fg_color;
1680 bg_color = t;
1681 }
1682
1683 if (!m_curDC)
1684 return;
1685
1686 // Convert the character into wxString
1687 wxString
1688 str((char)c);
1689
1690 // Set the correct font
1691 if (m_boldStyle != FONT)
1692 {
1693 if (flags & UNDERLINE)
1694 m_curDC->SetFont(m_underlinedFont);
1695 else
1696 m_curDC->SetFont(m_normalFont);
1697 }
1698 else
1699 {
1700 if (flags & BOLD)
1701 {
1702 if (flags & UNDERLINE)
1703 m_curDC->SetFont(m_boldUnderlinedFont);
1704 else
1705 m_curDC->SetFont(m_boldFont);
1706 }
1707 else
1708 {
1709 if (flags & UNDERLINE)
1710 m_curDC->SetFont(m_underlinedFont);
1711 else
1712 m_curDC->SetFont(m_normalFont);
1713 }
1714 }
1715
1716 // Convert x-y char coordinates into pixel coordinates
1717 x *= m_charWidth;
1718 y *= m_charHeight;
1719
1720 // Set colors and background mode
1721 m_curDC->SetBackgroundMode(wxSOLID);
1722 m_curDC->SetTextBackground(m_colors[fg_color]);
1723 m_curDC->SetTextForeground(m_colors[bg_color]);
1724
1725 // Draw the actual text
1726 m_curDC->DrawText(str, x, y);
1727 if (flags & BOLD && m_boldStyle == OVERSTRIKE)
1728 m_curDC->DrawText(str, x + 1, y);
1729}
1730
1731
1748void
1749NumeReTerminal::DrawCursor(int fg_color, int bg_color, int flags, int x, int y, unsigned char c)
1750{
1751 // Set cursor-related member variables
1752 m_curX = x;
1753 m_curY = y;
1754 m_curFG = fg_color;
1755 m_curBG = bg_color,
1756 m_curFlags = flags;
1757 m_curChar = c;
1758
1759 // Stop the timer
1760 if (m_timer.IsRunning())
1761 m_timer.Stop();
1762
1763 // Draw the cursor at its position
1764 DoDrawCursor(fg_color, bg_color, flags, x, y, c);
1765
1766 // Restart the timer
1767 if (m_curBlinkRate)
1768 {
1769 m_timer.Start(m_curBlinkRate);
1770 m_curState = 1;
1771 }
1772}
1773
1774
1785void
1786NumeReTerminal::OnTimer(wxTimerEvent& WXUNUSED(event))
1787{
1788 wxClientDC* dc = nullptr;
1789
1790 if (m_init)
1791 return;
1792
1793 // Do nothing if the cursor coordinates are invalid
1794 if (m_curX == -1 || m_curY == -1 || m_selecting)
1795 return;
1796
1797 // Do nothing, if the cursor is invisible
1798 if (GetMode() & CURSORINVISIBLE)
1799 {
1800 //wxLogDebug("Skipping cursor");
1801 return;
1802 }
1803 //wxLogDebug("Drawing cursor");
1804 if (!m_curDC)
1805 {
1806 dc = new wxClientDC(this);
1807 m_curDC = dc;
1808 }
1809
1810 // Draw the blinking cursor
1811 // Blinking is done by alternating fore and background colors
1812 if (m_curBlinkRate)
1813 {
1814 m_curState++;
1815 if (m_curState & 1 && m_curX != -1 && m_curY != -1)
1817 else
1819 }
1820
1821 if (dc)
1822 {
1823 delete dc;
1824 m_curDC = nullptr;
1825 }
1826}
1827
1828
1840{
1841 // Convert x-y char coordinates into pixel coordinates
1842 // and compensate for an additional line
1843 x *= m_charWidth;
1844
1845 // Consider here the possible shift due toe the fact that
1846 // the window could be below the bottom corner
1847 if ((y+2.1) > m_height) // m_height is already in character units
1848 y = (y-1) * m_charHeight - 2;
1849 else
1850 y = (y+1) * m_charHeight;
1851
1852 m_callTip->PopUp(wxPoint(x, y), _cTip.sDefinition);
1853 m_callTip->Resize(wxSize(m_charWidth * (_cTip.sDefinition.length()+1.5), m_charHeight));
1854 m_callTip->Highlight(_cTip.nStart, _cTip.nEnd-_cTip.nStart);
1855}
1856
1857
1866{
1867 m_callTip->Dismiss();
1868}
1869
1870
1886void
1887NumeReTerminal::ClearChars(int bg_color, int x, int y, int w, int h)
1888{
1889 x *= m_charWidth;
1890 y *= m_charHeight;
1891 w *= m_charWidth;
1892 h *= m_charHeight;
1893
1894 if (!m_curDC)
1895 return;
1896
1897 // Clear the area by drawing a rectangle with the background color
1898 m_curDC->SetPen(m_colorPens[bg_color]);
1899 m_curDC->SetBrush(wxBrush(m_colors[bg_color], wxSOLID));
1900 m_curDC->DrawRectangle(x, y, w /* + 1*/, h /*+ 1*/);
1901}
1902
1903
1914void
1916{
1918
1921
1923}
1924
1925
1934void
1936{
1937#ifdef __WIN32__
1939#else
1940 wxBell();
1941#endif
1942}
1943
1944
1954{
1955 // prevent any nasty recursion
1956 if (m_inUpdateSize)
1957 {
1958 return;
1959 }
1960
1961 m_inUpdateSize = true;
1962 int charWidth, charHeight;
1963 wxClientDC* dc = nullptr;
1964
1965 if (!m_curDC)
1966 {
1967 dc = new wxClientDC(this);
1968 m_curDC = dc;
1969 }
1970 else
1971 return;
1972
1973 // Set the normal font
1974 dc->SetFont(m_boldFont);
1975
1976 // Calculate the correct text extent
1977 dc->GetTextExtent(MEASURING_STRING, &charWidth, &charHeight); // EKHL: Changed because Heigth made no sense
1978 charWidth = std::rint(charWidth / (double)strlen(MEASURING_STRING));
1979
1980 wxSize currentClientSize = GetClientSize();
1981
1982 // Get the number of characters per line and the number of lines
1983 int numCharsInLine = currentClientSize.GetX() / charWidth;
1984 int numLinesShown = currentClientSize.GetY() / charHeight;
1985
1986 // Update the size, if the calculated numbers are not matching the previous ones
1987 if ( (numCharsInLine != m_charsInLine) || (numLinesShown != m_linesDisplayed))
1988 {
1989 wxString message;
1990
1991 // FINALLY! Finally killed the memory leak! The problem is that somehow a size event
1992 // was generating negative numbers for these values, which led to weird things happening.
1993 if ( (numCharsInLine > 0) && (numLinesShown > 0))
1994 {
1995 m_charsInLine = numCharsInLine;
1996 m_linesDisplayed = numLinesShown;
1997 // tell the GTerm core to resize itself
1998 ResizeTerminal(numCharsInLine, numLinesShown);
1999 {
2000 wxCriticalSectionLocker lock(m_kernelCS);
2001 _kernel.updateLineLenght(numCharsInLine);
2002 }
2003 }
2004 }
2005
2006 m_inUpdateSize = false;
2007 Refresh();
2008
2009 delete dc;
2010 m_curDC = nullptr;
2011}
2012
2013
2022{
2024
2026
2027 SetBackgroundColour(m_colors[0]);
2028 m_parent->SetBackgroundColour(m_colors[0]);
2029
2030 for (int i = 0; i < 16; i++)
2031 m_colorPen_defs[i] = wxPen(m_color_defs[i], 1, wxSOLID);
2032
2035 wxWindow::Update();
2036 m_parent->Update();
2037}
2038
2039
2051void
2053{
2054 int
2055 w,
2056 h;
2057
2059
2060 /*
2061 ** Determine window size from current font
2062 */
2063 wxClientDC
2064 dc(this);
2065
2066 // Calculate text extents
2067 dc.SetFont(m_boldFont);
2068 dc.GetTextExtent(MEASURING_STRING, &m_charWidth, &m_charHeight); // EKHL: Changed because Height made no sense
2070
2071 w = width * m_charWidth;
2072 h = height * m_charHeight;
2073
2074 /*
2075 ** Create our bitmap for copying
2076 */
2077 if (m_bitmap)
2078 {
2079 m_memDC.SelectObject(wxNullBitmap);
2080 delete m_bitmap;
2081 }
2082 m_bitmap = new wxBitmap(w, h);
2083 m_memDC.SelectObject(*m_bitmap);
2084
2085 /*
2086 ** Set window size
2087 */
2088 SetSize(w, h);
2089
2090 /*
2091 ** Set terminal size
2092 */
2094
2095 m_width = width;
2096 m_height = height;
2097
2098 /*
2099 ** Send event
2100 */
2101 if (!m_init)
2102 {
2103 wxCommandEvent e(wxEVT_COMMAND_TERM_RESIZE, GetId());
2104 e.SetEventObject(this);
2105 GetParent()->GetEventHandler()->ProcessEvent(e);
2106 }
2107}
2108
2109
2110
2118void NumeReTerminal::ProcessInput(int len, const std::string& sData)
2119{
2120 scrollToInput();
2121
2122 // Delete selected characters and/or remove
2123 // the selection
2124 if (HasSelection())
2125 {
2126 delSelected();
2128 }
2129
2130 wxClientDC
2131 dc(this);
2132
2133 m_curDC = &dc;
2135 m_curDC = nullptr;
2136}
2137
2138
2146void NumeReTerminal::ProcessOutput(int len, const std::string& sData)
2147{
2148 if (HasSelection())
2150 wxClientDC
2151 dc(this);
2152 m_curDC = &dc;
2154 m_curDC = nullptr;
2155}
2156
2157
2168void NumeReTerminal::OnActivate(wxActivateEvent& event)
2169{
2170 m_isActive = event.GetActive();
2171}
2172
2173
2184void NumeReTerminal::OnGainFocus(wxFocusEvent& event)
2185{
2188}
2189
2190
2201void NumeReTerminal::OnLoseFocus(wxFocusEvent& event)
2202{
2205}
2206
2207
2216{
2217 m_isBusy = true;
2218 m_wxParent->Busy();
2219}
2220
2221
2230{
2231 m_isBusy = false;
2232 m_wxParent->Ready();
2233}
2234
2235
2247void NumeReTerminal::ScrollTerminal(int numLines, bool scrollUp /* = true */)
2248{
2249 if (GenericTerminal::Scroll(numLines, scrollUp))
2250 Refresh();
2251}
2252
2253
2264void NumeReTerminal::OnSize(wxSizeEvent& event)
2265{
2266 UpdateSize();
2267}
2268
2269
2278void NumeReTerminal::UpdateRemoteSize(int width, int height)
2279{
2280}
2281
2282
2291{
2292 wxCriticalSectionLocker lock(m_kernelCS);
2293
2294 // Reset terminal removes all lines
2295 GetTM()->Reset();
2296
2297 // Print the version info same as during start of program
2299}
void addBreakpoint(const std::string &_sFilename, size_t nLine)
void removeBreakpoint(const std::string &_sFilename, size_t nLine)
void clearBreakpoints(const std::string &_sFilename)
An implementation of a generic terminal, which has to be specialized in the child classes.
Definition: gterm.hpp:42
bool cursor_up()
Either moves the cursor up or performs a history jump.
Definition: actions.cpp:480
bool del()
Perform a delete key operation.
Definition: actions.cpp:329
void clear_mode_flag(int flag)
Clears a mode flag (mainly used to make the cursor visible again).
Definition: utils.cpp:336
void erase_line()
Erases the current line in the internal buffer.
Definition: actions.cpp:779
TextManager * GetTM()
Get a pointer to the internal text buffer.
Definition: gterm.cpp:261
bool Scroll(int numLines, bool scrollUp)
Definition: gterm.cpp:278
virtual void ProcessInput(int len, const std::string &sData)
Definition: gterm.cpp:36
void set_mode_flag(int flag)
Sets a mode flag (only used to make the cursor invisble).
Definition: utils.cpp:320
std::string get_selected_text()
Gets the selected text (if any).
Definition: gterm.cpp:248
virtual void Update()
Simple wrapper around update_changes()
Definition: gterm.cpp:19
bool cursor_right()
Moves the cursor to the right.
Definition: actions.cpp:456
void tab()
Evaluate the tab key (do not insert a tab character but try to autocomplete the current input).
Definition: actions.cpp:224
virtual void ModeChange(int state)
Definition: gterm.hpp:198
virtual void ProcessOutput(int len, const std::string &sData)
Processes output returned from the kernel and hands it over to the internal buffer.
Definition: gterm.cpp:63
void update_changes()
Definition: utils.cpp:37
int Width() const
Definition: gterm.hpp:152
bool cursor_down()
Either moves the cursor down or performs a history jump.
Definition: actions.cpp:535
void resetAutoComp(int mode)
Reset the current autocompletion list and the corresponding variables.
Definition: actions.cpp:120
virtual void Select(int x, int y, int select)
Definition: gterm.cpp:215
bool cursor_left()
Moves the cursor to the left.
Definition: actions.cpp:432
virtual void ResizeTerminal(int _width, int _height)
Definition: gterm.cpp:101
bool m_useSmartSense
Definition: gterm.hpp:117
bool end()
Moves the cursor to the rightmost position in the current line.
Definition: actions.cpp:692
bool home()
Moves the cursor to the leftmost position in the current line.
Definition: actions.cpp:667
NumeReSyntax * getSyntax()
Definition: gterm.hpp:145
bool delSelected()
Delete a selected block.
Definition: actions.cpp:360
bool ctrl_left()
Moves the cursor one word to the left.
Definition: actions.cpp:599
int Height() const
Definition: gterm.hpp:156
void cr()
Insert a carriage return.
Definition: actions.cpp:179
bool bs()
Perform a backspace operation.
Definition: actions.cpp:292
void move_cursor_editable_area(int x, int y)
Moves the cursor to a location, if this location is editable.
Definition: utils.cpp:305
void erase_usercontent_line()
Erases alle user-written contents from the current line.
Definition: actions.cpp:792
bool IsScrolledUp()
Determine, whether the terminal is scrolled up.
Definition: gterm.cpp:298
bool ctrl_right()
Moves the cursor one word to the right.
Definition: actions.cpp:637
void lf()
Insert a line feed.
Definition: actions.cpp:191
int GetMode() const
Definition: gterm.hpp:171
This data container is a copy- efficient table to interchange data between Kernel and GUI.
Definition: table.hpp:87
BreakpointManager & getBreakpointManager()
Definition: debugger.hpp:110
static ProcedureLibrary ProcLibrary
Definition: kernel.hpp:202
std::map< std::string, std::string > getPluginLanguageStrings()
This member function returns a map of language strings for the installed plugins, which will be used ...
Definition: kernel.cpp:2281
Settings getKernelSettings()
Get the settings available in the Settings class.
Definition: kernel.cpp:94
std::vector< std::string > getDocIndex()
This member function returns the documentation index as a string vector, which can be used to fill th...
Definition: kernel.cpp:2383
static NumeRe::Table getTable()
This member function is used by the kernel to be notified when the user finished the table edit proce...
Definition: kernel.cpp:3299
static bool bGettingLine
Definition: kernel.hpp:200
void CancelCalculation()
Definition: kernel.hpp:357
void updateLineLenght(int nLength)
This member function is used to update the internal terminal line length information after the termin...
Definition: kernel.cpp:2169
static void printPreFmt(const std::string &__sLine, bool printingEnabled=true)
This member function appends the pre- formatted string to the buffer and informs the terminal that we...
Definition: kernel.cpp:2683
bool SettingsModified()
Returns true, if the user changed any internal settings using the set command.
Definition: kernel.cpp:2515
static std::queue< NumeReTask > taskQueue
Definition: kernel.hpp:190
std::vector< std::string > getPluginCommands()
This member function is used by the syntax highlighter to hightlight the plugin commands.
Definition: kernel.cpp:2329
NumeReDebugger & getDebugger()
Definition: kernel.hpp:326
int getAutosaveInterval() const
Definition: kernel.hpp:346
std::map< std::string, std::string > getMenuMap() const
Returns the menu map used to construct the package menu.
Definition: kernel.cpp:2566
KernelStatus MainLoop(const std::string &sCommand)
This is the main loop for the core of NumeRe.
Definition: kernel.cpp:600
std::string getDocumentation(const std::string &sCommand)
This member function returns the documentation for the passed command string as HTML string prepared ...
Definition: kernel.cpp:2368
@ NUMERE_CLC_TERMINAL
Definition: kernel.hpp:126
@ NUMERE_EDIT_FILE
Definition: kernel.hpp:115
@ NUMERE_INSTALLATION_DONE
Definition: kernel.hpp:125
@ NUMERE_PENDING_SPECIAL
Definition: kernel.hpp:111
@ NUMERE_EDIT_TABLE
Definition: kernel.hpp:118
@ NUMERE_ANSWER_READ
Definition: kernel.hpp:121
@ NUMERE_ISSUE_WARNING
Definition: kernel.hpp:109
@ NUMERE_SHOW_WINDOW
Definition: kernel.hpp:122
@ NUMERE_OPEN_DOC
Definition: kernel.hpp:116
@ NUMERE_PENDING
Definition: kernel.hpp:110
@ NUMERE_DEBUG_EVENT
Definition: kernel.hpp:120
@ NUMERE_CLOSE_WINDOWS
Definition: kernel.hpp:124
@ NUMERE_SHOW_TABLE
Definition: kernel.hpp:117
@ NUMERE_DONE_KEYWORD
Definition: kernel.hpp:106
@ NUMERE_REFRESH_FUNCTIONTREE
Definition: kernel.hpp:123
@ NUMERE_SHOW_STRING_TABLE
Definition: kernel.hpp:119
static NumeRe::Table table
Definition: kernel.hpp:198
std::map< std::string, std::string > getFunctionLanguageStrings()
This member function returns a map of language strings for the declared functions,...
Definition: kernel.cpp:2306
void CloseSession()
This member function shuts the kernel down and terminates the kernel instance. Every call to NumeReKe...
Definition: kernel.cpp:2210
NumeRe::Container< std::string > getStringTable(const std::string &sStringTableName)
This member function creates the table container for the string table or the clusters.
Definition: kernel.cpp:3357
const std::vector< Package > & getInstalledPackages() const
Returns a vector containing the names and the version info of each installed plugin.
Definition: kernel.cpp:2553
void printVersionInfo()
This member function prints the version headline and the version information to the console.
Definition: kernel.cpp:563
NumeReVariables getVariableList()
This member function returns a structure containing all currently declared variables,...
Definition: kernel.cpp:2421
int ReadOpenFileFlag()
This member function returns the mode, how a file shall be opened in the editor, when called by the k...
Definition: kernel.cpp:2351
void setKernelSettings(const Settings &_settings)
Update the internal settings.
Definition: kernel.cpp:107
long long int getLastSavedTime() const
Definition: kernel.hpp:350
Procedure & getProcedureInterpreter()
Definition: kernel.hpp:316
void initializeStackTracker()
Starts the stack tracker, which will prevent stack overflows.
Definition: kernel.cpp:546
std::vector< std::string > getPathSettings() const
This member function returns a vector containing all currently declared paths in a distinct order.
Definition: kernel.cpp:2531
void Autosave()
Saves the allocated memories by the tables automatically.
Definition: kernel.cpp:121
void addPlugins(const std::vector< std::string > &vPlugins)
Add the plugin definitions to the command strings. Will reload the standard settings in advance to re...
Definition: syntax.cpp:165
@ SYNTAX_OPTION
Definition: syntax.hpp:92
@ SYNTAX_FUNCTION
Definition: syntax.hpp:93
@ SYNTAX_METHODS
Definition: syntax.hpp:102
@ SYNTAX_STRING
Definition: syntax.hpp:96
@ SYNTAX_PROCEDURE
Definition: syntax.hpp:99
@ SYNTAX_COMMENT
Definition: syntax.hpp:103
@ SYNTAX_CONSTANT
Definition: syntax.hpp:94
@ SYNTAX_NPRC_COMMAND
Definition: syntax.hpp:101
@ SYNTAX_COMMAND
Definition: syntax.hpp:91
@ SYNTAX_SPECIALVAL
Definition: syntax.hpp:95
@ SYNTAX_OPERATOR
Definition: syntax.hpp:98
The terminal class for the GUI. It's a specialisation of the GenericTerminal.
Definition: terminal.hpp:46
std::vector< std::string > getDocIndex()
Gets the contents of the documentation index as a vector.
Definition: terminal.cpp:324
TerminalCallTip * m_callTip
Definition: terminal.hpp:75
NumeReVariables getVariableList()
This will return the variable list from the kernel to be shown in the variable viewer.
Definition: terminal.cpp:369
void ClearSelection()
Definition: terminal.cpp:1382
void OnPaint(wxPaintEvent &event)
Definition: terminal.cpp:1233
NumeReKernel::KernelStatus m_KernelStatus
Definition: terminal.hpp:168
void OnThreadUpdate(wxThreadEvent &event)
This function is the thread update event handler member function. Here are all returned messages from...
Definition: terminal.cpp:573
wxFont m_boldUnderlinedFont
Definition: terminal.hpp:98
virtual void UpdateRemoteSize(int width, int height)
Fallback for the virtual definition.
Definition: terminal.cpp:2278
std::map< std::string, std::string > getPluginLanguageStrings()
This will return the language strings for the plugins used by the language class for filling the symb...
Definition: terminal.cpp:339
bool m_bTableEditAvailable
Definition: terminal.hpp:170
bool m_inUpdateSize
Definition: terminal.hpp:84
void passEditedTable(NumeRe::Table _table)
Passes a table (as a container) to the kernel.
Definition: terminal.cpp:245
Options * m_options
Definition: terminal.hpp:114
void OnSize(wxSizeEvent &event)
Definition: terminal.cpp:2264
void cutText()
Implements copy to clip board and deleting the selection.
Definition: terminal.cpp:1553
void DoDrawCursor(int fg_color, int bg_color, int flags, int x, int y, unsigned char c)
Definition: terminal.cpp:1662
void pipe_command(const std::string &sCommand)
Pass the entered command line to the kernel.
Definition: terminal.cpp:901
void EndKernelTask()
This function forces the thread to terminate so that the application may be shut down.
Definition: terminal.cpp:535
wxMemoryDC m_memDC
Definition: terminal.hpp:104
NumeRe::Table getTable(const std::string &sTableName)
This function will return the named table from the kernel to be shown in a GUI window.
Definition: terminal.cpp:964
wxTimer m_timer
Definition: terminal.hpp:110
virtual void Bell() override
Definition: terminal.cpp:1935
virtual void Calltip(int x, int y, NumeRe::CallTip &_cTip) override
Function reimplementation to display a tooltip requested by the GenericTerminal.
Definition: terminal.cpp:1839
NumeReKernel _kernel
Definition: terminal.hpp:166
void OnGainFocus(wxFocusEvent &event)
Definition: terminal.cpp:2184
virtual void DrawCursor(int fg_color, int bg_color, int flags, int x, int y, unsigned char c) override
Definition: terminal.cpp:1749
bool m_selecting
Definition: terminal.hpp:81
void StartKernelTask()
This member function will start the managed, second thread, in which the kernel will operate.
Definition: terminal.cpp:415
wxDC * m_curDC
Definition: terminal.hpp:101
void OnLoseMouseCapture(wxMouseCaptureLostEvent &event)
This member function handles the "MouseCaptureLostEvent" and releases the mouse.
Definition: terminal.cpp:1280
void clearTerminal()
This member function clears the terminal.
Definition: terminal.cpp:2290
virtual ~NumeReTerminal()
Terminal destructor.
Definition: terminal.cpp:168
virtual void ModeChange(int state) override
Definition: terminal.cpp:1915
bool HasSelection()
Definition: terminal.cpp:1477
wxString GetSelection()
Definition: terminal.cpp:1492
wxColour * m_colors
Definition: terminal.hpp:89
void OnLeftDown(wxMouseEvent &event)
Definition: terminal.cpp:1260
const std::vector< Package > & getInstalledPackages()
Returns the installed plugins as a STL vector.
Definition: terminal.cpp:200
void copyText()
Implements copy to clip board.
Definition: terminal.cpp:1506
virtual void ProcessOutput(int len, const std::string &sData) override
Processes text received from the kernel.
Definition: terminal.cpp:2146
void Busy()
Inform the GUI that the kernel is currently busy.
Definition: terminal.cpp:2215
bool filterKeyCodes(int keyCode, bool ctrlDown)
This private member function filters special key codes and handles them.
Definition: terminal.cpp:1070
virtual void CalltipCancel() override
Function reimplementation to close the previously opened calltip.
Definition: terminal.cpp:1865
void OnClose(wxCloseEvent &event)
This function forces the thread to terminate immediately. Should only occur in situations,...
Definition: terminal.cpp:554
void pasteText()
Implements paste from clip board.
Definition: terminal.cpp:1528
void OnLoseFocus(wxFocusEvent &event)
Definition: terminal.cpp:2201
std::string m_sCommandLine
Definition: terminal.hpp:174
void MarkSelection(bool bRectangular=false)
Definition: terminal.cpp:1403
virtual void ClearChars(int bg_color, int x, int y, int w, int h) override
Definition: terminal.cpp:1887
void OnKeyDown(wxKeyEvent &event)
Definition: terminal.cpp:1187
void ScrollTerminal(int numLines, bool scrollUp=true)
Definition: terminal.cpp:2247
void pass_command(const std::string &command, bool isEvent)
Pass the external command to the kernel without printing it to the console.
Definition: terminal.cpp:925
void updatePackage(const std::string &package)
Updates an installed package with new information after the user created a package with the package c...
Definition: terminal.cpp:230
virtual void DrawText(int fg_color, int bg_color, int flags, int x, int y, const std::string &sText) override
Definition: terminal.cpp:1578
Settings getKernelSettings()
This will return a copy of the internal settings object of the kernel.
Definition: terminal.cpp:383
void CancelCalculation()
Inform the kernel to stop the current calculation. Used to handle the ESC key press.
Definition: terminal.cpp:994
NumeReWindow * m_wxParent
Definition: terminal.hpp:112
bool m_updateProcedureLibrary
Definition: terminal.hpp:86
wxFont m_underlinedFont
Definition: terminal.hpp:96
wxFont m_normalFont
Definition: terminal.hpp:95
int m_curBlinkRate
Definition: terminal.hpp:69
bool m_bCommandAvailable
Definition: terminal.hpp:169
void UpdateColors()
This member function sets the new colors to the internal pen definitions.
Definition: terminal.cpp:2021
virtual void ResizeTerminal(int width, int height) override
Definition: terminal.cpp:2052
void clearBreakpoints(const std::string &_sFilename)
This member function removes all breakpoints from the passed file.
Definition: terminal.cpp:295
void GetDefColors(wxColor colors[16], NumeReTerminal::BOLDSTYLE boldStyle=NumeReTerminal::DEFAULT)
Definition: terminal.cpp:791
wxCriticalSection m_kernelCS
Definition: terminal.hpp:167
void UpdateSize()
Definition: terminal.cpp:1953
void scrollToInput()
This private member function scrolls the terminal all the way down.
Definition: terminal.cpp:1164
std::map< std::string, std::string > getMenuMap()
Returns the menu map of the installed plugins as a STL map.
Definition: terminal.cpp:214
NumeRe::Container< std::string > getStringTable(const std::string &sStringTableName)
This member function will return the named table containing strings.
Definition: terminal.cpp:979
void removeBreakpoint(const std::string &_sFilename, size_t nLine)
This member function removes a breakpoint from the passed file at the indicated line number.
Definition: terminal.cpp:280
void OnTimer(wxTimerEvent &event)
Definition: terminal.cpp:1786
void OnEnter(wxMouseEvent &event)
This member function handles the "Mouse Enter" event.
Definition: terminal.cpp:1361
std::string getDocumentation(const std::string &sCommand)
Gets the desired documentation article as a HTML string.
Definition: terminal.cpp:310
wxPen * m_colorPens
Definition: terminal.hpp:92
void OnChar(wxKeyEvent &event)
Definition: terminal.cpp:1012
virtual void ProcessInput(int len, const std::string &sData) override
Processes text received from the keybord or clipboard.
Definition: terminal.cpp:2118
wxBitmap * m_bitmap
Definition: terminal.hpp:107
wxFont m_boldFont
Definition: terminal.hpp:97
std::string m_sAnswer
Definition: terminal.hpp:175
void setKernelSettings(const Settings &)
This will pass the new kernel settings to the kernel.
Definition: terminal.cpp:399
void SetCursorBlinkRate(int rate)
Definition: terminal.cpp:866
std::map< std::string, std::string > getFunctionLanguageStrings()
This will return the language strings for the custom defined functions used by the language class for...
Definition: terminal.cpp:354
wxColour m_color_defs[16]
Definition: terminal.hpp:89
std::vector< std::string > getPathSettings()
Returns the standard paths as a STL vector.
Definition: terminal.cpp:185
void OnActivate(wxActivateEvent &event)
Definition: terminal.cpp:2168
int m_linesDisplayed
Definition: terminal.hpp:73
void Ready()
Inform the GUI that the kernel is ready for calculation.
Definition: terminal.cpp:2229
unsigned char m_curChar
Definition: terminal.hpp:78
bool SetFont(const wxFont &font)
Definition: terminal.cpp:746
void OnMouseMove(wxMouseEvent &event)
Definition: terminal.cpp:1325
wxPen m_colorPen_defs[16]
Definition: terminal.hpp:92
BOLDSTYLE m_boldStyle
Definition: terminal.hpp:138
void OnLeftUp(wxMouseEvent &event)
Definition: terminal.cpp:1302
virtual wxThread::ExitCode Entry()
This is the main thread function and will be called repeatedly from the wxWidgets library.
Definition: terminal.cpp:438
void addBreakpoint(const std::string &_sFilename, size_t nLine)
This member function adds a breakpoint to the passed file at the indicated line number.
Definition: terminal.cpp:263
void editTable(NumeRe::Container< std::string > _stringTable, const std::string &tableDisplayName)
This member function displays the contents of the "string()" table or a cluster and enables editing i...
void AddToHistory(const wxString &sCommand)
This function is a wrapper for the corresponding function from the history widget and stores the pass...
void Ready()
This member function tells NumeRe that it shall display the "ready" state to the user.
void openTable(NumeRe::Container< std::string > _stringTable, const std::string &tableDisplayName, const std::string &sIntName)
This member function displays the contents of the "string()" table or a cluster.
void EvaluateOptions()
void showWindow(NumeRe::Window &window)
This public member function handles the creation of windows requested by the kernel.
void Busy()
This member function tells NumeRe that it shall display the "busy" state to the user.
void notifyInstallationDone()
Notifies all instances of the PackagRepoBrowser to refresh its internal list of installed packages an...
bool ShowHelp(const wxString &sDocId)
This member function displays the help page for the selected documentation ID.
void openImage(wxFileName filename)
This member function opens the selected image in the image viewer window.
void OpenSourceFile(wxArrayString fnames, unsigned int nLine=0, int nOpenFileFlag=OPENFILE_NOTHING)
Opens the given list of source files in the editor.
void closeWindows(WindowType type=WT_ALL)
Close all windows of the selected WindowType or simply use WT_ALL to close all terminal-closable floa...
void evaluateDebugInfo(const std::vector< std::string > &vDebugInfo)
This function will pass the obtained debugging information to the debug viewer. If this object does n...
void refreshFunctionTree()
This member function is a simple wrapper for refreshing the contents of the function tree.
This class implements an interface of the internal Settings object adapted to be usable from the GUI.
Definition: Options.h:178
@ FUNCTION
Definition: Options.h:285
@ OPERATOR
Definition: Options.h:293
@ STRING
Definition: Options.h:290
@ CONSOLE_STD
Definition: Options.h:279
@ COMMAND
Definition: Options.h:280
@ SPECIALVAL
Definition: Options.h:289
@ NUMBER
Definition: Options.h:295
@ COMMENT
Definition: Options.h:281
@ PROCEDURE
Definition: Options.h:294
@ OPTION
Definition: Options.h:284
@ CONSTANT
Definition: Options.h:288
@ PROCEDURE_COMMAND
Definition: Options.h:296
@ METHODS
Definition: Options.h:297
SyntaxStyles GetSyntaxStyle(size_t i) const
Return the selected syntax style by constructing it from the style string.
Definition: options.cpp:112
bool declareNewPackage(const std::string &sInstallInfoString)
This member function declares a new plugin from the passed install information string.
Definition: plugin.cpp:664
void updateLibrary()
Perform an update, e.g. if a procedure was deleted.
This class manages the setting values of the internal (kernel) settings of this application.
Definition: settings.hpp:663
SettingsValue & getSetting(const std::string &value)
Returns a reference to the setting value, which corresponds to the passed string. Throws an exception...
Definition: settings.hpp:711
void copySettings(const Settings &_settings)
This member function is an alias for the assignment operator overload.
Definition: settings.cpp:740
bool & active()
Returns a reference to a boolean value type setting.
Definition: settings.hpp:556
This class represents the calltip in the terminal. The associated window will only be shown and hidde...
void Highlight(size_t start, size_t len)
Hightlight the section of the text in the calltip.
void Resize(const wxSize &s)
Change the calltip's size.
void Dismiss()
Remove the shown calltip.
void PopUp(const wxPoint &pos, const wxString &text)
Show the calltip at the desired position. This function does not check, whether the calltip is acutal...
void ChangeFont(const wxFont &font)
Changes the font of the calltip.
void ChangeEditableState()
Removes the editable flag from the managed text.
std::string getCurrentInputLine() const
Returns the contents of the input line.
void unselectAll()
This member function unselects the whole text at once.
WindowType
This enumeration defines all terminal- closable window types.
FindReplaceDialog * g_findReplace
value_type rint(value_type v)
char name[32]
Definition: resampler.cpp:371
#define min(a, b)
Definition: resampler.cpp:34
#define max(a, b)
Definition: resampler.cpp:30
#define SETTING_B_SMARTSENSE
Definition: settings.hpp:100
#define SETTING_S_TERMINALFONT
Definition: settings.hpp:55
This structure contains the data for a single calltip, which might be shown in the editor or the term...
std::string sDefinition
This structure abstracts the necessary information for a task to be done by the graphical user interf...
Definition: kernel.hpp:380
NumeRe::Table table
Definition: kernel.hpp:384
NumeRe::Container< std::string > stringTable
Definition: kernel.hpp:386
std::vector< std::string > vDebugEvent
Definition: kernel.hpp:383
NumeRe::Window window
Definition: kernel.hpp:385
int taskType
Definition: kernel.hpp:387
size_t nLine
Definition: kernel.hpp:382
std::string sString
Definition: kernel.hpp:381
This structure combines a vector of declared variables including their values and respective sizes wi...
Definition: kernel.hpp:80
wxColour background
Definition: Options.h:29
wxColour foreground
Definition: Options.h:28
#define MEASURING_STRING
Definition: terminal.cpp:53
#define KERNEL_THREAD_STACK_SIZE
Definition: terminal.cpp:52
#define CURSOR_BLINK_DEFAULT_TIMEOUT
Definition: terminal.cpp:50
void WinMessageBeep()
Definition: winmesgbeep.cpp:13
#define CURSOR_BLINK_MAX_TIMEOUT
Definition: terminal.cpp:51
#define wxEVT_COMMAND_TERM_RESIZE
Definition: terminal.hpp:33
END_EVENT_TABLE()