NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
NumeReWindow.cpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2019 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
21
22
23#define CHAMELEON__CPP
24
25#define _CRTDBG_MAP_ALLOC
26#include <stdlib.h>
27#ifdef _MSC_VER
28 #include <crtdbg.h>
29#else
30 #define _ASSERT(expr) ((void)0)
31
32 #define _ASSERTE(expr) ((void)0)
33#endif
34
35#include "NumeReWindow.h"
36#include <wx/wx.h>
37#include <wx/dir.h>
38#include <wx/string.h>
39#include <wx/filedlg.h>
40#include <wx/statusbr.h>
41#include <wx/choicdlg.h>
42#include <wx/msgdlg.h>
43#include <wx/msw/wince/tbarwce.h>
44#include <wx/msw/private.h>
45#include <wx/print.h>
46#include <wx/printdlg.h>
47#include <wx/mimetype.h>
48#include <wx/stdpaths.h>
49#include <wx/filename.h>
50#include <wx/artprov.h>
51#include <fstream>
52#include <wx/clipbrd.h>
53#include <wx/display.h>
54#include <array>
55
56
57//need to include <wx/filename.h> and <wx/stdpaths.h>
58#include <math.h>
59
60#include "NumeReNotebook.h"
61#include "numeredroptarget.hpp"
62#include "DirTraverser.hpp"
63#include "IconManager.h"
66#include "graphviewer.hpp"
67#include "textsplashscreen.hpp"
68
77
78#include "editor/editor.h"
79#include "editor/history.hpp"
81
89
90#include "terminal/terminal.hpp"
91
92#include "../kernel/core/version.h"
93#include "../kernel/core/utils/tools.hpp"
94#include "../kernel/core/procedure/dependency.hpp"
95#include "../kernel/core/datamanagement/database.hpp"
96#include "../kernel/core/documentation/docgen.hpp"
97#include "../kernel/core/ui/error.hpp"
98#include "../kernel/core/io/logger.hpp"
99#include "../kernel/core/ui/calltipprovider.hpp"
100
101#include "../common/recycler.hpp"
102#include "../common/Options.h"
103#include "../common/vcsmanager.hpp"
104#include "../common/filerevisions.hpp"
105#include "../common/ipc.hpp"
106
107#include "../common/http.h"
108#include "../common/compareFiles.hpp"
109
112
113#include "icons/newstart1.xpm"
114#include "icons/newcontinue1.xpm"
115#include "icons/newstop1.xpm"
116#include "icons/gtk-apply.xpm"
117#include "icons/stepnext.xpm"
118#include "icons/wraparound.xpm"
119#include "icons/breakpoint_octagon.xpm"
120#include "icons/breakpoint_octagon_crossed.xpm"
121#include "icons/breakpoint_octagon_disable.xpm"
122
123const std::string sVersion = toString((int)AutoVersion::MAJOR) + "." + toString((int)AutoVersion::MINOR) + "." + toString((int)AutoVersion::BUILD) + " \"" + AutoVersion::STATUS + "\"";
124
125// Forward declaration
126std::string removeMaskedStrings(const std::string& sString);
127std::string removeQuotationMarks(const std::string&);
128
129std::string prepareStringsForDialog(const std::string& sString)
130{
132}
133// Create the stack trace object here
134
137double g_pixelScale = 1.0;
138
140wxPrintData* g_printData = (wxPrintData*) nullptr;
141wxPageSetupData* g_pageSetupData = (wxPageSetupData*) nullptr;
142
143BEGIN_EVENT_TABLE(NumeReWindow, wxFrame)
146
147 EVT_FIND (-1, NumeReWindow::OnFindEvent)
148 EVT_FIND_NEXT (-1, NumeReWindow::OnFindEvent)
149 EVT_FIND_REPLACE (-1, NumeReWindow::OnFindEvent)
150 EVT_FIND_REPLACE_ALL (-1, NumeReWindow::OnFindEvent)
151 EVT_FIND_CLOSE (-1, NumeReWindow::OnFindEvent)
152
153 EVT_CLOSE (NumeReWindow::OnClose)
154
155 //EVT_NOTEBOOK_PAGE_CHANGED (ID_NOTEBOOK_ED, NumeReWindow::OnPageChange)
156 EVT_AUINOTEBOOK_PAGE_CHANGED (ID_NOTEBOOK_ED, NumeReWindow::OnPageChange)
157
160
161 EVT_TREE_ITEM_RIGHT_CLICK (ID_PROJECTTREE, NumeReWindow::OnTreeItemRightClick)
162 EVT_TREE_ITEM_RIGHT_CLICK (ID_FUNCTIONTREE, NumeReWindow::OnTreeItemRightClick)
163 EVT_TREE_ITEM_ACTIVATED (ID_PROJECTTREE, NumeReWindow::OnTreeItemActivated)
164 EVT_TREE_ITEM_ACTIVATED (ID_FUNCTIONTREE, NumeReWindow::OnTreeItemActivated)
165 EVT_TREE_ITEM_GETTOOLTIP (ID_PROJECTTREE, NumeReWindow::OnTreeItemToolTip)
166 EVT_TREE_ITEM_GETTOOLTIP (ID_FUNCTIONTREE, NumeReWindow::OnTreeItemToolTip)
167 EVT_TREE_BEGIN_DRAG (ID_PROJECTTREE, NumeReWindow::OnTreeDragDrop)
168 EVT_TREE_BEGIN_DRAG (ID_FUNCTIONTREE, NumeReWindow::OnTreeDragDrop)
169
170 EVT_IDLE (NumeReWindow::OnIdle)
174
175IMPLEMENT_APP(MyApp)
176
177
186static wxRect determineWindowSize(std::string& sWinSize)
187{
188 wxRect winRect;
189
190 if (sWinSize == "{}")
191 return winRect;
192
193 EndlessVector<StringView> vArgs = getAllArguments(StringView(sWinSize, 1, sWinSize.length()-2));
194
195 if (vArgs.size() < 4)
196 sWinSize = "{}";
197 else
198 {
199 winRect.x = StrToInt(vArgs[0].subview(2).to_string());
200 winRect.y = StrToInt(vArgs[1].subview(2).to_string());
201 winRect.width = StrToInt(vArgs[2].subview(2).to_string());
202 winRect.height = StrToInt(vArgs[3].subview(2).to_string());
203
204 int currDisplay = wxNOT_FOUND;
205 wxRect dispdim;
206
207 // Find the correct display
208 for (size_t i = 0; i < wxDisplay::GetCount(); i++)
209 {
210 dispdim = wxDisplay(i).GetGeometry();
211
212 if (dispdim.Contains(winRect.x+10, winRect.y+10))
213 {
214 currDisplay = i;
215 break;
216 }
217 }
218
219 g_logger.info("User-selected display: " + toString(currDisplay) + " @ {x=" + toString(winRect.x) + " y=" + toString(winRect.y)+"}");
220
221 if (currDisplay == wxNOT_FOUND)
222 {
223 sWinSize = "{}";
224 return winRect;
225 }
226
227 winRect.width = std::min(dispdim.width-winRect.x+dispdim.x, winRect.width);
228 winRect.height = std::min(dispdim.height-winRect.y+dispdim.y, winRect.height);
229
230 g_logger.info("Final window dimensions: w=" + toString(winRect.width) + " h=" + toString(winRect.height));
231
232 if (winRect.width < 200 || winRect.height < 200)
233 sWinSize = "{}";
234 }
235
236 return winRect;
237}
238
239
240//----------------------------------------------------------------------
252{
253 #ifdef DO_LOG
255 #endif // DO_LOG
256
257 g_logger.push_info("NEW INSTANCE STARTUP");
258 g_logger.push_info("NumeRe v " + sVersion + " (var. " + AutoVersion::UBUNTU_VERSION_STYLE + ")");
260 g_logger.info("Starting up.");
261
262 wxString sInstanceLocation = wxStandardPaths::Get().GetDataDir();
263 sInstanceLocation.Replace(":\\", "~");
264 sInstanceLocation.Replace("\\", "~");
265
266 g_logger.debug("Creating single instance checker.");
267 m_singlinst = new wxSingleInstanceChecker("NumeRe::" + sInstanceLocation + "::" + wxGetUserId(), wxGetHomeDir());
268 m_DDEServer = nullptr;
269
270 // Avoid starting up a second instance
271 if (m_singlinst->IsAnotherRunning())
272 {
273 // Create a new client
274 wxLogNull ln; // own error checking implemented -> avoid debug warnings
275 DDE::Client* client = new DDE::Client;
276 DDE::Connection* connection = (DDE::Connection*)client->MakeConnection("localhost", DDE_SERVICE, DDE_TOPIC);
277
278 if (connection)
279 {
280 // don't eval here just forward the whole command line to the other instance
281 wxString cmdLine;
282
283 for (int i = 1 ; i < argc; ++i)
284 cmdLine += wxString(argv[i]) + ' ';
285
286 if (!cmdLine.IsEmpty())
287 {
288 // escape openings and closings so it is easily possible to find the end on the rx side
289 cmdLine.Replace(_T("("), _T("\\("));
290 cmdLine.Replace(_T(")"), _T("\\)"));
291 connection->Execute(_T("[CmdLine({") + cmdLine + _T("})]"));
292 }
293
294 connection->Disconnect();
295 delete connection;
296 }
297
298 // free memory DDE-/IPC-clients
299 delete client;
300 delete m_singlinst;
301 return false;
302 }
303
304
305 std::setlocale(LC_ALL, "C");
306 wxFileName f(wxStandardPaths::Get().GetExecutablePath());
307
308 wxInitAllImageHandlers();
309 wxBitmap splashImage;
310 wxSplashScreen* splash = nullptr;
311 g_logger.debug("Loading splash image.");
312
313 if (splashImage.LoadFile(f.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR)+"icons\\splash.png", wxBITMAP_TYPE_PNG))
314 splash = new wxSplashScreen(splashImage, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 0, nullptr, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
315
316 g_findReplace = nullptr;
317
318 g_logger.info("Creating graphical user interface.");
319
320 // Create and initialize the main frame. Will also
321 // include loading the configuration, loading existing
322 // caches and preparing the editor.
323 NumeReWindow* NumeReMainFrame = new NumeReWindow("NumeRe: Framework für Numerische Rechnungen (v" + sVersion + ")", wxDefaultPosition, wxDefaultSize);
324
325 g_logger.debug("Starting DDE server instance.");
326 // Create the DDE server for the first (main)
327 // instance of the application
328 m_DDEServer = new DDE::Server(NumeReMainFrame);
329 m_DDEServer->Create(DDE_SERVICE);
330
331 g_logger.debug("Determining window size.");
332
333 if (NumeReMainFrame->getOptions()->getSetting(SETTING_B_SAVEWINDOWSIZE).active())
334 {
335 std::string sWinSize = NumeReMainFrame->getOptions()->getSetting(SETTING_S_WINDOWSIZE).stringval();
336 g_logger.info("User-selected window size: " + sWinSize);
337 wxRect winRect = determineWindowSize(sWinSize);
338
339 if (sWinSize != "{}")
340 NumeReMainFrame->SetSize(winRect);
341 else
342 NumeReMainFrame->Maximize();
343 }
344 else
345 NumeReMainFrame->Maximize();
346
347 g_logger.debug("Showing main frame.");
348 NumeReMainFrame->Show(true);
349
350 // Passed commandline items
351 wxArrayString wxArgV;
352 for (int i = 0; i < argc; i++)
353 {
354 wxArgV.Add(argv[i]);
355 }
356
357 // force the history window to perform a
358 // page down to scroll to its actually
359 // last position
360 NumeReMainFrame->forceHistoryPageDown();
361 NumeReMainFrame->EvaluateCommandLine(wxArgV);
362 NumeReMainFrame->Ready();
363 g_logger.info("NumeRe ready.");
364
365 // Destroy the splash image once the window
366 // is ready
367 if (splash)
368 splash->Destroy();
369
370 // Tip of the day
371 if (NumeReMainFrame->showTipAtStartup)
372 {
373 g_logger.debug("Showing tip of the day.");
374 wxArrayString DialogText;
375 DialogText.Add(_guilang.get("GUI_TIPOTD_HEAD"));
376 DialogText.Add(_guilang.get("GUI_TIPOTD_DYK"));
377 DialogText.Add(_guilang.get("GUI_TIPOTD_NEXT"));
378 DialogText.Add(_guilang.get("GUI_TIPOTD_STAS"));
379 DialogText.Add(_guilang.get("GUI_TIPOTD_CLOSE"));
380 NumeReMainFrame->updateTipAtStartupSetting(ShowTip(NumeReMainFrame, NumeReMainFrame->tipProvider, DialogText));
381 }
382
383 delete NumeReMainFrame->tipProvider;
384 NumeReMainFrame->tipProvider = nullptr;
385
386 if (NumeReMainFrame->m_UnrecoverableFiles.length())
387 {
388 g_logger.warning("The files '" + NumeReMainFrame->m_UnrecoverableFiles + "' could not be restored.");
389 NumeReMainFrame->Refresh();
390 NumeReMainFrame->Update();
391 wxMessageBox(_guilang.get("GUI_DLG_SESSION_RECREATIONERROR", NumeReMainFrame->m_UnrecoverableFiles), _guilang.get("GUI_DLG_SESSION_ERROR"), wxICON_ERROR);
392 }
393
394 return true;
395}
396
397
402{
403}
404
405
414{
415 if (m_singlinst)
416 delete m_singlinst;
417
418 if (m_DDEServer)
419 delete m_DDEServer;
420
421 return 0;
422}
423
424
435{
436 try
437 {
438 throw;
439 }
440 catch (std::exception& e)
441 {
442 g_logger.error(std::string("Unexpected exception: ") + e.what());
443 wxMessageBox(std::string("An unexpected exception was caught. If it is reproducable, consider informing us about this issue. Message: ") + e.what(), "Exception caught");
444 }
445 catch (SyntaxError& e)
446 {
447 g_logger.error("Unexpected exception: " + toString((int)e.errorcode) + ", message: " + _guilang.get("ERR_NR_" + toString((int)e.errorcode) + "_0_*", e.getToken(), toString(e.getIndices()[0]), toString(e.getIndices()[1]), toString(e.getIndices()[2]), toString(e.getIndices()[3])) + ", expression: " + e.getExpr() + ", token: " + e.getToken());
448 wxMessageBox("An unexpected exception was caught. If it is reproducable, consider informing us about this issue. Code: " + toString((int)e.errorcode) + ", message: " + _guilang.get("ERR_NR_" + toString((int)e.errorcode) + "_0_*", e.getToken(), toString(e.getIndices()[0]), toString(e.getIndices()[1]), toString(e.getIndices()[2]), toString(e.getIndices()[3])) + ", expression: " + e.getExpr() + ", token: " + e.getToken(), "Exception caught");
449 }
451 {
452 g_logger.error("Unexpected exception: " + e.GetMsg());
453 wxMessageBox("An unexpected exception was caught. If it is reproducable, consider informing us about this issue. Message: " + e.GetMsg(), "Exception caught");
454 }
455 catch ( ... )
456 {
457 throw;
458 }
459
460 return true;
461}
462
463//----------------------------------------------------------------------
464
465
466
467
480NumeReWindow::NumeReWindow(const wxString& title, const wxPoint& pos, const wxSize& size)
481 : wxFrame((wxFrame *)nullptr, -1, title, pos, size)
482{
483 // should be approximately 80x15 for the terminal
484 SetMinSize(wxSize(1024, 768));
485
486 m_debugViewer = nullptr;
487 m_currentView = nullptr;
488 m_statusBar = nullptr;
489
491 m_multiRowState = false;
492 m_sessionSaved = false;
495 m_appStarting = true;
496
497 g_logger.debug("Creating new file watcher.");
498 m_watcher = new Filewatcher();
499 m_watcher->SetOwner(this);
500
501 g_logger.debug("Creating icon manager.");
503
504 // Show a log window for all debug messages
505#ifdef _DEBUG
506 logWindow = new wxLogWindow(this, "Debug messages");
507 wxLog::SetActiveTarget(logWindow);
508#endif
509
510 wxString programPath = getProgramFolder();
511
512 SetIcon(getStandardIcon());
513
514 m_remoteMode = true;
515
516 g_logger.debug("Creating window elements.");
517 // Create the main frame splitters
518 m_splitProjectEditor = new wxSplitterWindow(this, ID_SPLITPROJECTEDITOR, wxDefaultPosition, wxDefaultSize, wxBORDER_THEME);
519 m_splitEditorOutput = new ProportionalSplitterWindow(m_splitProjectEditor, ID_SPLITEDITOROUTPUT, 0.75, wxDefaultPosition, wxDefaultSize, wxSP_3DSASH);
520 m_splitCommandHistory = new ProportionalSplitterWindow(m_splitEditorOutput, wxID_ANY, 0.75, wxDefaultPosition, wxDefaultSize, wxSP_3DSASH);
521
522 // Create the different notebooks
524 m_book->SetTopParent(this);
525 m_noteTerm = new ViewerBook(m_splitCommandHistory, wxID_ANY, wxDefaultPosition, wxDefaultSize);
526 m_treeBook = new ViewerBook(m_splitProjectEditor, wxID_ANY, wxDefaultPosition, wxDefaultSize);
527
528 // Prepare the application settings
529 m_options = new Options();
530
531 // Create container and the contained terminal
532 m_termContainer = new wxTermContainer(m_splitCommandHistory, ID_CONTAINER_TERM, wxDefaultPosition, wxDefaultSize, wxBORDER_THEME);
533 g_logger.debug("Creating terminal and starting kernel session.");
534 m_terminal = new NumeReTerminal(m_termContainer, ID_TERMINAL, m_options, programPath, wxPoint(0, 0));
537 m_terminal->SetParent(this);
538
539 // Get the character height from the terminal
542
543 g_logger.info("Initializing options.");
544 // Fetch legacy settings, if available
546
547 _guilang.setTokens("<>="+getProgramFolder().ToStdString()+";");
548
549 g_logger.info("Loading GUI language files.");
551 _guilang.loadStrings(true);
552 else
553 _guilang.loadStrings(false);
554
555 // Prepare the options dialog
556 m_optionsDialog = new OptionsDialog(this, m_options, ID_OPTIONSDIALOG, _guilang.get("GUI_DLG_OPTIONS"));
557
558 // Create the contents of file and symbols tree
559 m_filePanel = new TreePanel(m_treeBook, wxID_ANY);
560 m_fileTree = new FileTree(m_filePanel, ID_PROJECTTREE, wxDefaultPosition, wxDefaultSize, wxTR_TWIST_BUTTONS | wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxTR_FULL_ROW_HIGHLIGHT);
561 TreeSearchCtrl* fileSearchCtrl = new TreeSearchCtrl(m_filePanel, wxID_ANY, _guilang.get("GUI_SEARCH_FILES"), _guilang.get("GUI_SEARCH_CALLTIP_TREE"), m_fileTree);
562 m_filePanel->AddWindows(fileSearchCtrl, m_fileTree);
563 m_treeBook->AddPage(m_filePanel, _guilang.get("GUI_FILETREE"));
564
565 m_functionPanel = new TreePanel(m_treeBook, wxID_ANY);
566 m_functionTree = new FileTree(m_functionPanel, ID_FUNCTIONTREE, wxDefaultPosition, wxDefaultSize, wxTR_TWIST_BUTTONS | wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxTR_FULL_ROW_HIGHLIGHT | wxTR_HIDE_ROOT);
567 TreeSearchCtrl* functionSearchCtrl = new TreeSearchCtrl(m_functionPanel, wxID_ANY, _guilang.get("GUI_SEARCH_SYMBOLS"), _guilang.get("GUI_SEARCH_CALLTIP_TREE"), m_functionTree, true);
568 m_functionPanel->AddWindows(functionSearchCtrl, m_functionTree);
569 m_treeBook->AddPage(m_functionPanel, _guilang.get("GUI_FUNCTIONTREE"));
570 m_treeBook->Hide();
571 wxImageList* fileIcons = m_iconManager->GetImageList();
572
573 // Sets the list, but doesn't take control of it away
574 m_fileTree->SetImageList(fileIcons);
575 m_functionTree->SetImageList(fileIcons);
576
577 int idxFolderOpen = m_iconManager->GetIconIndex("FOLDEROPEN");
578
579 wxTreeItemId rootNode = m_fileTree->AddRoot(_guilang.get("GUI_TREE_WORKSPACE"), m_iconManager->GetIconIndex("WORKPLACE"));
580 m_projectFileFolders[0] = m_fileTree->AppendItem(rootNode, _guilang.get("GUI_TREE_DATAFILES"), idxFolderOpen);
581 m_projectFileFolders[1] = m_fileTree->AppendItem(rootNode, _guilang.get("GUI_TREE_SAVEDFILES"), idxFolderOpen);
582 m_projectFileFolders[2] = m_fileTree->AppendItem(rootNode, _guilang.get("GUI_TREE_SCRIPTS"), idxFolderOpen);
583 m_projectFileFolders[3] = m_fileTree->AppendItem(rootNode, _guilang.get("GUI_TREE_PROCEDURES"), idxFolderOpen);
584 m_projectFileFolders[4] = m_fileTree->AppendItem(rootNode, _guilang.get("GUI_TREE_PLOTS"), idxFolderOpen);
585
586 g_logger.debug("Preparing function tree.");
588
589#if wxUSE_DRAG_AND_DROP
592#endif //wxUSE_DRAG_AND_DROP
593
594 m_currentPage = 0;
595 m_fileNum = 0;
596
597 m_appClosing = false;
598 m_setSelection = false;
599
600 m_statusBar = new NumeReStatusbar(this);
601 SetStatusBar(m_statusBar);
602
603 // Redirect the menu help strings to the
604 // second status bar field
605 SetStatusBarPane(1);
606
607 SendSizeEvent();
608
609 m_updateTimer = new wxTimer(this, ID_STATUSTIMER);
610 m_fileEventTimer = new wxTimer(this, ID_FILEEVENTTIMER);
611
612 m_splitEditorOutput->Initialize(m_book);
615 m_splitProjectEditor->Show();
616 m_splitEditorOutput->Show();
617 m_splitCommandHistory->Show();
618 m_book->Show();
619 m_history = new NumeReHistory(this, m_options, m_noteTerm, -1, m_terminal->getSyntax(), m_terminal, wxDefaultPosition, wxDefaultSize);
622
623 m_noteTerm->AddPage(m_history, _guilang.get("GUI_HISTORY"));
624 m_noteTerm->AddPage(m_varViewer, _guilang.get("GUI_VARVIEWER"));
625 m_noteTerm->AddPage(m_procedureViewer, _guilang.get("GUI_PROCEDUREVIEWER"));
626
627 wxMilliSleep(250);
628
631
632 g_logger.info("Evaluating options.");
634
636 {
640 }
641
642 // Recreate the last session or
643 // create a new empty file
644 g_logger.info("Preparing session.");
646
648
649 // TO BE INVESTIGATED: For some reason we have to
650 // set the procedure list twice to function it correctly
652
653 // bind the event after the loading of the files - FIX for Win10 1803
654 Connect(wxEVT_FSWATCHER, wxFileSystemWatcherEventHandler(NumeReWindow::OnFileSystemEvent));
655
656 m_filterNSCRFiles = _guilang.get("GUI_FILTER_SCRIPTS") + " (*.nscr)|*.nscr";
657 m_filterNPRCFiles = _guilang.get("GUI_FILTER_PROCEDURES") + " (*.nprc)|*.nprc";
658 m_filterNLYTFiles = _guilang.get("GUI_FILTER_LAYOUTS") + "(*.nlyt)|*.nlyt";
659 m_filterExecutableFiles = _guilang.get("GUI_FILTER_EXECUTABLES") + " (*.nscr, *.nprc)|*.nscr;*.nprc";
660 m_filterNumeReFiles = _guilang.get("GUI_FILTER_NUMEREFILES") + " (*.ndat, *.nscr, *.nprc, *.nlyt)|*.ndat;*.nscr;*.nprc;*.nlyt";
661 m_filterDataFiles = _guilang.get("GUI_FILTER_DATAFILES");
662 m_filterImageFiles = _guilang.get("GUI_FILTER_IMAGEFILES") + " (*.png, *.jpeg, *.eps, *.svg, *.gif, *.tiff)|*.png;*.jpg;*.jpeg;*.eps;*.svg;*.gif;*.tif;*.tiff";
663 m_filterTeXSource = _guilang.get("GUI_FILTER_TEXSOURCE") + " (*.tex)|*.tex";
664 m_filterNonsource = _guilang.get("GUI_FILTER_NONSOURCE");
665 m_filterSupportedFiles = _guilang.get("GUI_FILTER_ALLSUPPORTEDFILES");
666
667 // If this ever gets ported to Linux, we'd probably want to add
668 // Linux library extensions here (.a, .so). The other issue is that
669 // the remote file dialog only looks in ~, which might need to be changed.
670 m_filterAllFiles = _guilang.get("GUI_FILTER_ALLFILES") + " (*.*)|*.*";
671
672 g_findReplace = nullptr;
673
676 g_pageSetupData = new wxPageSetupDialogData(*g_printData);
677
678 m_appStarting = false;
679
680 //Msgbox
681 NumeRe::DataBase tipDataBase;
682
683 if (m_options->useCustomLangFiles() && fileExists(m_options->ValidFileName("<>/user/docs/hints.ndb", ".ndb")))
684 tipDataBase.addData("<>/user/docs/hints.ndb");
685 else
686 tipDataBase.addData("<>/docs/hints.ndb");
687
688 tipProvider = new MyTipProvider(tipDataBase.getColumn(0));
690 g_logger.info("Graphical user interface ready.");
691}
692
693
703{
704 delete g_printData;
705 delete g_pageSetupData;
706
707 if(g_findReplace != nullptr)
708 {
709 delete g_findReplace;
710 }
711
712 if (m_updateTimer)
713 {
714 delete m_updateTimer;
715 m_updateTimer = nullptr;
716 }
717
719 {
720 delete m_fileEventTimer;
721 m_fileEventTimer = nullptr;
722 }
723
724 if (m_optionsDialog)
725 delete m_optionsDialog;
726
727 if (m_options)
728 delete m_options;
729
730 if (m_iconManager)
731 delete m_iconManager;
732
733 if (m_watcher)
734 delete m_watcher;
735}
736
737
748{
751}
752
753
762{
763 wxStandardPaths systemPaths = wxStandardPaths::Get();
764 wxString appPath = systemPaths.GetExecutablePath();
765 wxFileName fullProgramPath(appPath);
766 return fullProgramPath.GetPath();
767}
768
769
780void NumeReWindow::AddToHistory(const wxString& sCommand)
781{
782 m_history->AddToHistory(sCommand);
783}
784
785
795wxString NumeReWindow::GetDocContent(wxString docid)
796{
797 return m_terminal->getDocumentation(docid.ToStdString());
798}
799
800
808std::vector<std::string> NumeReWindow::GetDocIndex()
809{
810 return m_terminal->getDocIndex();
811}
812
813
823{
824 m_history->PageDown();
825}
826
827
835std::vector<std::string> NumeReWindow::getPathDefs()
836{
837 return m_terminal->getPathSettings();
838}
839
840
851void NumeReWindow::addToReloadBlackList(const wxString& sFilename)
852{
853 for (size_t i = 0; i < vReloadBlackList.size(); i++)
854 {
855 if (vReloadBlackList[i] == sFilename)
856 return;
857 }
858
859 vReloadBlackList.push_back(sFilename);
860}
861
862
872void NumeReWindow::removeFromReloadBlackList(const wxString& sFilename)
873{
874 for (size_t i = 0; i < vReloadBlackList.size(); i++)
875 {
876 if (vReloadBlackList[i] == sFilename)
877 {
878 vReloadBlackList.erase(vReloadBlackList.begin()+i);
879 return;
880 }
881 }
882}
883
884
895bool NumeReWindow::isOnReloadBlackList(wxString sFilename)
896{
897 sFilename = replacePathSeparator(sFilename.ToStdString());
898
899 for (size_t i = 0; i < vReloadBlackList.size(); i++)
900 {
901 if (vReloadBlackList[i] == sFilename)
902 return true;
903 }
904
905 return false;
906}
907
908
921{
922 // Open up the configuration file, assumed to be located
923 // in the program's root directory
924 wxString path = wxStandardPaths::Get().GetExecutablePath();
925
926 // Construct a file name class from the path
927 wxFileName configName(path.substr(0, path.rfind('\\')+1), "numeregui.ini");
928
929 // Prepare the configuration file
930 wxFileConfig m_config("numeregui", wxEmptyString, configName.GetFullPath());
931
932 // Depending on whether the file exists, load the contents
933 // or use the default values
934 if (configName.FileExists())
935 {
936 bool printInColor = (m_config.Read("Miscellaneous/PrintInColor", "true") == "true");
937 int printStyle = printInColor ? wxSTC_PRINT_COLOURONWHITE : wxSTC_PRINT_BLACKONWHITE;
938 m_options->SetPrintStyle(printStyle);
939
940 std::map<std::string, SettingsValue>& mSettings = m_options->getSettings();
941
942 mSettings[SETTING_B_TOOLBARTEXT].active() = (m_config.Read("Interface/ShowToolbarText", "false") == "true");
943 mSettings[SETTING_B_PATHSONTABS].active() = (m_config.Read("Interface/ShowPathsOnTabs", "false") == "true");
944 mSettings[SETTING_B_PRINTLINENUMBERS].active() = (m_config.Read("Miscellaneous/PrintLineNumbers", "false") == "true");
945 mSettings[SETTING_B_SAVESESSION].active() = (m_config.Read("Miscellaneous/SaveSession", "false") == "true");
946 mSettings[SETTING_B_SAVEBOOKMARKS].active() = (m_config.Read("Miscellaneous/SaveBookmarksInSession", "false") == "true");
947 mSettings[SETTING_B_FORMATBEFORESAVING].active() = (m_config.Read("Miscellaneous/FormatBeforeSaving", "false") == "true");
948 mSettings[SETTING_B_USEREVISIONS].active() = (m_config.Read("Miscellaneous/KeepBackups", "true") == "true");
949 mSettings[SETTING_B_FOLDLOADEDFILE].active() = (m_config.Read("Interface/FoldDuringLoading", "false") == "true");
950 mSettings[SETTING_B_HIGHLIGHTLOCALS].active() = (m_config.Read("Styles/HighlightLocalVariables", "false") == "true");
951 mSettings[SETTING_B_LINESINSTACK].active() = (m_config.Read("Debugger/ShowLineNumbersInStackTrace", "true") == "true");
952 mSettings[SETTING_B_MODULESINSTACK].active() = (m_config.Read("Debugger/ShowModulesInStackTrace", "true") == "true");
953 mSettings[SETTING_B_PROCEDUREARGS].active() = (m_config.Read("Debugger/ShowProcedureArguments", "true") == "true");
954 mSettings[SETTING_B_GLOBALVARS].active() = (m_config.Read("Debugger/ShowGlobalVariables", "false") == "true");
955
956 int debuggerFocusLine = 10;
957 m_config.Read("Debugger/FocusLine", &debuggerFocusLine, 10);
958 m_options->SetDebuggerFocusLine(debuggerFocusLine);
959
960 wxFont font;
961 wxString nativeInfo;
962 m_config.Read("Styles/EditorFont", &nativeInfo, "Consolas 10");
963 font.SetNativeFontInfoUserDesc(nativeInfo);
965
966 wxString latexroot;
967 m_config.Read("Miscellaneous/LaTeXRoot", &latexroot, "C:/Program Files");
968 m_options->SetLaTeXRoot(latexroot);
969
970 int terminalHistory = 300;
971 m_config.Read("Miscellaneous/TerminalHistory", &terminalHistory, 300);
972 if (terminalHistory >= 100 && terminalHistory <= 1000)
973 m_options->SetTerminalHistorySize(terminalHistory);
974 else
976
977 int caretBlinkTime = 500;
978 m_config.Read("Interface/CaretBlinkTime", &caretBlinkTime, 500);
979 if (caretBlinkTime >= 100 && caretBlinkTime <= 1000)
980 m_options->SetCaretBlinkTime(caretBlinkTime);
981 else
983
984 // Read the color codes from the configuration file,
985 // if they exist
987
988 // Read the analyzer config from the configuration file,
989 // if it exists
991
992 // Inform the kernel about updated settings
994
995 m_config.DeleteAll();
996 }
997}
998
999
1010{
1011 // create the initial blank open file or recreate the last session
1012 if (wxFileExists(getProgramFolder()+"\\numere.session") && m_options->GetSaveSession())
1013 {
1014 g_logger.info("Reopening files from last session.");
1015
1016 // Inform the application that the editor
1017 // settings do not have to be copied during
1018 // the session recovery
1020 NewFile();
1021 std::ifstream if_session;
1022 std::vector<std::string> vSessionFile;
1023 std::string sLine;
1024 std::string sFileName;
1025 int activefile = 0;
1026 int nId = 0;
1027 int nLine = 0;
1028 int nSetting = 0;
1029 std::string sBookmarks;
1030 bool modifiedFile = false;
1031 if_session.open((getProgramFolder().ToStdString()+"\\numere.session").c_str());
1032
1033 // Is the session file available and readable? Then
1034 // recreate the last session from this file
1035 if (if_session.is_open())
1036 {
1037 // Read the session file completely
1038 while (!if_session.eof())
1039 {
1040 getline(if_session, sLine);
1041
1042 // Ignore comments
1043 if (!sLine.length() || sLine.front() == '#')
1044 continue;
1045
1046 // store the active file ID
1047 if (sLine.substr(0,12) == "ACTIVEFILEID")
1048 {
1049 activefile = StrToInt(sLine.substr(sLine.find('\t')+1));
1050 continue;
1051 }
1052
1053 vSessionFile.push_back(sLine);
1054 }
1055
1056 // Close the session file
1057 if_session.close();
1058
1059 // Decode the session file
1060 for (size_t i = 0; i < vSessionFile.size(); i++)
1061 {
1062 // copy the current fileinfo
1063 sLine = vSessionFile[i];
1064
1065 // check for the "modified" attribute
1066 if (sLine.front() == '*')
1067 {
1068 sLine.erase(0,1);
1069 modifiedFile = true;
1070 }
1071 else
1072 modifiedFile = false;
1073
1074 // create filename and current line
1075 sFileName = sLine.substr(0, sLine.find('\t'));
1076
1077 // erase until id
1078 sLine.erase(0, sLine.find('\t')+1);
1079 nId = StrToInt(sLine.substr(0, sLine.find('\t')));
1080
1081 // erase until position
1082 sLine.erase(0, sLine.find('\t')+1);
1083 nLine = StrToInt(sLine.substr(0, sLine.find('\t')));
1084
1085 // Search for settings
1086 if (sLine.find('\t') != std::string::npos)
1087 {
1088 // erase until setting
1089 sLine.erase(0, sLine.find('\t')+1);
1090 nSetting = StrToInt(sLine.substr(0, sLine.find('\t')));
1091 }
1092 else
1093 nSetting = 0;
1094
1095 // Search for bookmarks
1096 if (sLine.find('\t') != std::string::npos && m_options->GetSaveBookmarksInSession())
1097 sBookmarks = sLine.substr(sLine.rfind('\t')+1);
1098 else
1099 sBookmarks.clear();
1100
1101 // create the files
1102 //
1103 // This is a new file
1104 if (sFileName == "<NEWFILE>")
1105 {
1106 if (vSessionFile.size() != 1)
1107 {
1108 NewFile();
1110 }
1111
1112 m_book->getCurrentEditor()->GotoPos(nLine);
1114 continue;
1115 }
1116
1117 // Recreate the file if it exists
1118 if (wxFileExists(sFileName))
1119 {
1120 OpenSourceFile(wxArrayString(1, sFileName));
1121 NumeReEditor* currentEd = m_book->getCurrentEditor();
1122 currentEd->GotoPos(nLine);
1123 currentEd->ToggleSettings(nSetting);
1124 currentEd->EnsureVisible(currentEd->LineFromPosition(nLine));
1125 currentEd->setBookmarks(toIntVector(sBookmarks));
1126 }
1127 else
1128 {
1129 // If it not exists, inform the user
1130 // that we were not able to load it
1131 if (!modifiedFile)
1132 {
1133 m_UnrecoverableFiles += sFileName + "\n";
1134 }
1135
1136 int nUnloadableID = nId;
1137
1138 // Move the active file ID if necessary
1139 if (nUnloadableID < activefile)
1140 activefile--;
1141 }
1142 }
1143
1144 // Select the active file
1145 if (activefile >= (int)m_book->GetPageCount())
1146 m_book->SetSelection(m_book->GetPageCount()-1);
1147 else
1148 m_book->SetSelection(activefile);
1149 }
1150
1151 // Inform the application that we are finished
1152 // recreating the session
1154 }
1155 else
1156 {
1157 // Simply create a new empty file
1158 NewFile();
1159 }
1160}
1161
1162
1173void NumeReWindow::OnClose(wxCloseEvent &event)
1174{
1175 m_appClosing = true;
1176 g_logger.info("Closing NumeRe.");
1177
1178
1179 if (!CloseAllFiles())
1180 {
1181 if (event.CanVeto())
1182 event.Veto(true);
1183 return;
1184 }
1185
1186 // double check in case something went wrong
1188 {
1189 if (event.CanVeto())
1190 {
1191 event.Veto (true);
1192 }
1193
1194 return;
1195 }
1196
1197 if (m_updateTimer)
1198 {
1199 m_updateTimer->Stop();
1200 }
1201
1202 if (m_fileEventTimer)
1203 m_fileEventTimer->Stop();
1204
1205 if (m_terminal->IsWorking())
1206 {
1208
1210 {
1214 }
1215 else
1216 {
1220 }
1221
1223 {
1224 wxRect winRect = GetScreenRect();
1225
1226 if (IsMaximized())
1228 else
1229 m_options->getSetting(SETTING_S_WINDOWSIZE).stringval() = wxString::Format("{x=%d,y=%d,w=%d,h=%d}",
1230 winRect.x, winRect.y,
1231 winRect.width, winRect.height);
1232 }
1233
1234 // Update the settings for the last time
1236 wxMilliSleep(200);
1237
1238 g_logger.info("Stopping Kernel.");
1240 wxMilliSleep(200);
1241 }
1242
1243 if (m_debugViewer != nullptr)
1244 m_debugViewer->Destroy();
1245
1246
1247 if (m_history)
1248 {
1249 g_logger.info("Saving command line history.");
1251 }
1252
1253 // Close all windows to avoid calls to the map afterwards
1255
1256 Destroy();
1257}
1258
1259
1270void NumeReWindow::OnMenuEvent(wxCommandEvent &event)
1271{
1272 int id = event.GetId();
1273
1274 switch(id)
1275 {
1278 {
1279 FileNameTreeData* data = static_cast <FileNameTreeData* > (m_fileTree->GetItemData(m_clickedTreeItem));
1280 OnExecuteFile(data->filename.ToStdString(), id);
1281 break;
1282 }
1284 {
1285 FileNameTreeData* data = static_cast <FileNameTreeData* > (m_fileTree->GetItemData(m_clickedTreeItem));
1286
1287 wxArrayString fnames;
1288 fnames.Add(data->filename);
1289 OpenSourceFile(fnames);
1290 break;
1291 }
1293 {
1294 FileNameTreeData* data = static_cast <FileNameTreeData* > (m_functionTree->GetItemData(m_clickedTreeItem));
1295 wxString command;
1296 if (data->isCommand)
1297 command = (data->tooltip).substr(0, (data->tooltip).find(' ')) + " ";
1298 else if (data->isFunction)
1299 command = (data->tooltip).substr(0, (data->tooltip).find('(')+1);
1300 else if (data->isConstant)
1301 command = (data->tooltip).substr(0, (data->tooltip).find(' '));
1302 else if (data->isMethod)
1303 {
1304 size_t dot = (data->tooltip).find('.');
1305 size_t endPos = (data->tooltip).find_first_of("( ", dot);
1306
1307 if ((data->tooltip)[endPos] == '(')
1308 endPos++;
1309
1310 command = (data->tooltip).substr(dot, endPos-dot);
1311 }
1312
1314 edit->InsertText(edit->GetCurrentPos(), command);
1315 edit->GotoPos(edit->GetCurrentPos()+command.length());
1316 break;
1317 }
1319 {
1320 FileNameTreeData* data = static_cast <FileNameTreeData* > (m_functionTree->GetItemData(m_clickedTreeItem));
1321 std::string command;
1322 if (data->isCommand)
1323 command = (data->tooltip).substr(0, (data->tooltip).find(' ')).ToStdString() + " ";
1324 else if (data->isFunction)
1325 command = (data->tooltip).substr(0, (data->tooltip).find('(')+1).ToStdString();
1326 else if (data->isConstant)
1327 command = (data->tooltip).substr(0, (data->tooltip).find(' ')).ToStdString();
1328 else if (data->isMethod)
1329 {
1330 size_t dot = (data->tooltip).find('.');
1331 size_t endPos = (data->tooltip).find_first_of("( ", dot);
1332
1333 if ((data->tooltip)[endPos] == '(')
1334 endPos++;
1335
1336 command = (data->tooltip).substr(dot, endPos-dot);
1337 }
1338
1339 showConsole();
1340 m_terminal->ProcessInput(command.length(), command);
1341 break;
1342 }
1344 {
1345 FileNameTreeData* data = static_cast <FileNameTreeData* > (m_functionTree->GetItemData(m_clickedTreeItem));
1346 std::string command = (data->tooltip).substr(0, (data->tooltip).find(' ')).ToStdString();
1347 //openHTML(m_terminal->getDocumentation(command));
1348 ShowHelp(command);
1349 break;
1350 }
1352 {
1353 FileNameTreeData* data = static_cast <FileNameTreeData* > (m_functionTree->GetItemData(m_clickedTreeItem));
1354 wxMessageBox(data->tooltip, "DESCRIPTION", wxICON_INFORMATION, this);
1355 break;
1356 }
1358 {
1359 FileNameTreeData* data = static_cast <FileNameTreeData*> (m_fileTree->GetItemData(m_clickedTreeItem));
1360 openImage(wxFileName(data->filename));
1361 break;
1362 }
1364 deleteFile();
1365 break;
1368 break;
1371 break;
1373 renameFile();
1374 break;
1377 break;
1380 break;
1382 OnCopyAsPath();
1383 break;
1386 break;
1389 break;
1392 break;
1395 break;
1396 case ID_MENU_AUTOINDENT:
1397 {
1399 break;
1400 }
1401 case ID_MENU_LINEWRAP:
1402 {
1403 wxToolBar* t = GetToolBar();
1405
1406 if (m_book->getCurrentEditor(true))
1408
1411 break;
1412 }
1414 {
1416
1417 if (m_book->getCurrentEditor(true))
1419
1420 break;
1421 }
1422 case ID_MENU_USETXTADV:
1423 {
1425
1426 if (m_book->getCurrentEditor(true))
1428
1429 break;
1430 }
1432 {
1433 wxToolBar* t = GetToolBar();
1437 break;
1438 }
1440 {
1441 wxToolBar* t = GetToolBar();
1443
1444 if (m_book->getCurrentEditor(true))
1446
1449 break;
1450 }
1452 {
1455 break;
1456 }
1457 case ID_MENU_AUTOFORMAT:
1458 {
1460 break;
1461 }
1463 {
1465 break;
1466 }
1467 case ID_MENU_GOTOLINE:
1468 {
1469 gotoLine();
1470 break;
1471 }
1473 {
1474 m_book->ToggleWindowStyle(wxNB_MULTILINE);
1475 m_book->SendSizeEvent();
1476 m_book->Refresh();
1477 m_book->getCurrentEditor()->Refresh();
1478
1479 if (m_book->getCurrentEditor(true))
1480 m_book->getCurrentEditor(true)->Refresh();
1481
1483 break;
1484 }
1486 {
1488 break;
1489 }
1491 {
1493 break;
1494 }
1495 case ID_MENU_FOLD_ALL:
1496 {
1498 break;
1499 }
1500 case ID_MENU_UNFOLD_ALL:
1501 {
1503 break;
1504 }
1505 case ID_MENU_UNHIDE_ALL:
1506 {
1508 break;
1509 }
1511 {
1513 break;
1514 }
1516 {
1518 break;
1519 }
1521 {
1523 break;
1524 }
1526 {
1528 break;
1529 }
1531 {
1533 break;
1534 }
1536 {
1538 break;
1539 }
1541 {
1543 break;
1544 }
1546 {
1548 break;
1549 }
1551 {
1552 // only if the file type is matching
1554 break;
1555 }
1557 {
1559 break;
1560 }
1562 {
1564 break;
1565 }
1567 {
1569 break;
1570 }
1572 {
1574 break;
1575 }
1576 case ID_MENU_RUN_LATEX:
1577 {
1578 runLaTeX();
1579 break;
1580 }
1582 {
1583 compileLaTeX();
1584 break;
1585 }
1586 case ID_MENU_NEW_ASK:
1587 {
1589 break;
1590 }
1591 case ID_MENU_NEW_EMPTY:
1592 {
1593 NewFile();
1594 break;
1595 }
1596 case ID_MENU_NEW_SCRIPT:
1597 {
1599 break;
1600 }
1602 {
1604 break;
1605 }
1606 case ID_MENU_NEW_PLUGIN:
1607 {
1609 break;
1610 }
1611 case ID_MENU_NEW_LAYOUT:
1612 {
1614 break;
1615 }
1616
1619 {
1620 OnOpenSourceFile(id);
1621 break;
1622 }
1623
1624 case ID_MENU_SAVE:
1625 {
1626 SaveCurrentFile(false);
1627 break;
1628 }
1629
1632 {
1633 OnSaveSourceFile(id);
1634 break;
1635 }
1636
1637 case ID_NEW_PROJECT:
1638 {
1639 SaveCurrentFile(true);
1640 break;
1641 }
1642
1643 case ID_MENU_CLOSETAB:
1644 {
1645 CloseTab(false);
1646 break;
1647 }
1649 {
1650 CloseTab(true);
1651 break;
1652 }
1654 {
1655 EvaluateTab();
1656 break;
1657 }
1658
1659 case ID_MENU_CLOSEPAGE:
1660 {
1661 if (!m_book->getCurrentEditor())
1662 {
1663 return;
1664 }
1665
1666 CloseFile();
1668 break;
1669 }
1670
1671 case ID_MENU_CLOSEALL:
1672 {
1673 CloseAllFiles();
1674 break;
1675 }
1677 {
1679 break;
1680 }
1682 {
1684 break;
1685 }
1687 {
1688 int tab = GetIntVar(VN_CLICKEDTAB);
1689 m_book->unsplit(tab);
1690 break;
1691 }
1693 {
1694 int tab = GetIntVar(VN_CLICKEDTAB);
1695 m_book->split(tab, true);
1696 break;
1697 }
1699 {
1700 int tab = GetIntVar(VN_CLICKEDTAB);
1701 m_book->split(tab, false);
1702 break;
1703 }
1704
1706 {
1707 toggleConsole();
1708 if (m_termContainer->IsShown())
1709 m_terminal->SetFocus();
1710 break;
1711 }
1712
1714 {
1716 break;
1717 }
1718
1720 {
1721 toggleHistory();
1722 break;
1723 }
1724
1725
1726 case ID_MENU_QUIT:
1727 {
1728 Close(true);
1729 break;
1730 }
1731
1732 case ID_MENU_REDO:
1733 case ID_MENU_UNDO:
1734 {
1735 if(id == ID_MENU_REDO)
1736 m_book->getFocusedEditor()->Redo();
1737 else
1738 m_book->getFocusedEditor()->Undo();
1739
1740 m_book->Refresh();
1741 break;
1742 }
1743
1744 case ID_MENU_COPY:
1745 {
1746 if (m_book->getFocusedEditor()->HasFocus())
1747 m_book->getFocusedEditor()->Copy();
1748 else if (m_terminal->HasFocus())
1750
1751 break;
1752 }
1753
1754 case ID_MENU_CUT:
1755 {
1756 if (m_book->getFocusedEditor()->HasFocus())
1757 m_book->getFocusedEditor()->Cut();
1758 else if (m_terminal->HasFocus())
1760
1761 break;
1762 }
1763
1764 case ID_MENU_PASTE:
1765 {
1766 if (m_book->getFocusedEditor()->HasFocus())
1767 m_book->getFocusedEditor()->Paste();
1768 else if (m_terminal->HasFocus())
1770
1771 break;
1772 }
1773
1774 case ID_MENU_FIND:
1775 case ID_MENU_REPLACE:
1776 {
1777 OnFindReplace(id);
1778 break;
1779 }
1781 {
1783 break;
1784 }
1786 {
1788 break;
1789 }
1790
1791 case ID_MENU_ABOUT:
1792 {
1793 OnAbout();
1794 break;
1795 }
1796
1797 case ID_MENU_OPTIONS:
1798 {
1799 OnOptions();
1800 break;
1801 }
1803 {
1805 _option.getSetting(SETTING_B_DEBUGGER).active() = !_option.useDebugger();
1807 m_terminal->setKernelSettings(_option);
1808 wxToolBar* tb = GetToolBar();
1809 tb->ToggleTool(ID_MENU_TOGGLE_DEBUGGER, _option.useDebugger());
1811 break;
1812 }
1814 {
1816 break;
1817 }
1819 {
1821 break;
1822 }
1824 {
1826 break;
1827 }
1829 {
1831 break;
1832 }
1834 {
1835 OnCreatePackage("");
1836 break;
1837 }
1839 {
1841 break;
1842 }
1844 {
1846 break;
1847 }
1849 {
1851 break;
1852 }
1854 {
1856 repobrowser->SetIcon(GetIcon());
1857 repobrowser->Show();
1858 break;
1859 }
1861 {
1862 std::string packageFile = wxFileSelector(_guilang.get("GUI_SELECT_PACKAGE_FOR_INSTALL"),
1863 m_terminal->getPathSettings()[SCRIPTPATH] + "/packages",
1864 "", "*.nscr", "Packages (*.nscr)|*.nscr", wxFD_OPEN, this).ToStdString();
1865
1866 if (packageFile.length())
1867 m_terminal->pass_command("install \"" + replacePathSeparator(packageFile) + "\"", false);
1868
1869 break;
1870 }
1871
1872 case ID_MENU_PRINT_PAGE:
1873 {
1874 OnPrintPage();
1875 break;
1876 }
1877
1879 {
1881 break;
1882 }
1883
1885 {
1886 OnPrintSetup();
1887 break;
1888 }
1889
1890 case ID_MENU_HELP:
1891 {
1892 OnHelp();
1893 break;
1894 }
1895
1897 {
1899 break;
1900 }
1902 {
1904 break;
1905 }
1907 {
1909 break;
1910 }
1911
1912 case ID_MENU_EXECUTE:
1913 {
1915 {
1916 int tabNum = m_book->GetSelection();
1917 int result = HandleModifiedFile(tabNum, MODIFIEDFILE_COMPILE);
1918
1919 if (result == wxCANCEL)
1920 return;
1921 }
1922
1924 compileLaTeX();
1925 else
1926 {
1927 std::string command = replacePathSeparator((m_book->getCurrentEditor()->GetFileName()).GetFullPath().ToStdString());
1928 OnExecuteFile(command, id);
1929 }
1930
1931 break;
1932 }
1935 break;
1936 }
1937}
1938
1939
1948void NumeReWindow::OnPluginMenuEvent(wxCommandEvent& event)
1949{
1950 size_t id = event.GetId();
1951
1952 auto iter = m_pluginMenuMap.find(id);
1953
1954 if (iter != m_pluginMenuMap.end())
1955 m_terminal->pass_command("$" + iter->second + "()", true);
1956}
1957
1958
1974void NumeReWindow::OnFileSystemEvent(wxFileSystemWatcherEvent& event)
1975{
1976 if (!m_fileTree || m_appStarting)
1977 return;
1978
1979 int type = event.GetChangeType();
1980
1981 // Cache the event types and the event paths, if
1982 // the types match the selection and the path
1983 // does not contain the revisions folders
1984 if ((type == wxFSW_EVENT_CREATE
1985 || type == wxFSW_EVENT_DELETE
1986 || type == wxFSW_EVENT_RENAME
1987 || type == wxFSW_EVENT_MODIFY) && event.GetPath().GetFullPath().find(".revisions") == std::string::npos)
1988 {
1989 m_modifiedFiles.push_back(std::make_pair(type, event.GetPath().GetFullPath()));
1990 m_dragDropSourceItem = wxTreeItemId();
1991 m_fileEventTimer->StartOnce(500);
1992 }
1993}
1994
1995
2006void NumeReWindow::CreateProcedureTree(const std::string& sProcedurePath)
2007{
2008 std::vector<std::string> vFolderTree(1, sProcedurePath);
2009 std::vector<std::string> vProcedureTree;
2010 std::vector<std::string> vCurrentTree;
2011 std::string sPath = sProcedurePath;
2013
2014 // Find every folder first
2015 do
2016 {
2017 sPath += "/*";
2018 vCurrentTree = getFolderList(sPath, _option, 1);
2019
2020 if (vCurrentTree.size())
2021 vFolderTree.insert(vFolderTree.end(), vCurrentTree.begin(), vCurrentTree.end());
2022 }
2023 while (vCurrentTree.size());
2024
2025 // Search through every folder for procedures
2026 for (size_t i = 0; i < vFolderTree.size(); i++)
2027 {
2028 if (vFolderTree[i].substr(vFolderTree[i].length()-3) == "/.." || vFolderTree[i].substr(vFolderTree[i].length()-2) == "/.")
2029 continue;
2030
2031 vCurrentTree = getFileList(vFolderTree[i] + "/*.nprc", _option, 1);
2032
2033 if (vCurrentTree.size())
2034 vProcedureTree.insert(vProcedureTree.end(), vCurrentTree.begin(), vCurrentTree.end());
2035 }
2036
2037 // Remove the leading path part of the procedure path,
2038 // which is the procedure default path
2039 for (size_t i = 0; i < vProcedureTree.size(); i++)
2040 {
2041 if (vProcedureTree[i].substr(0, sProcedurePath.length()) == sProcedurePath)
2042 vProcedureTree[i].erase(0, sProcedurePath.length());
2043
2044 while (vProcedureTree[i].front() == '/' || vProcedureTree[i].front() == '\\')
2045 vProcedureTree[i].erase(0, 1);
2046 }
2047
2048 m_terminal->getSyntax()->setProcedureTree(vProcedureTree);
2049}
2050
2051
2060void NumeReWindow::openImage(wxFileName filename)
2061{
2062 wxString programPath = getProgramFolder();
2063
2064 ViewerFrame* frame = new ViewerFrame(this, "NumeRe-ImageViewer: " + filename.GetName());
2066 wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
2067
2068 ImagePanel* _panel = nullptr;
2069
2070 // Create the image panel
2071 if (filename.GetExt() == "png")
2072 _panel = new ImagePanel(frame, filename.GetFullPath(), wxBITMAP_TYPE_PNG);
2073 else if (filename.GetExt() == "bmp")
2074 _panel = new ImagePanel(frame, filename.GetFullPath(), wxBITMAP_TYPE_BMP);
2075 else if (filename.GetExt() == "gif")
2076 _panel = new ImagePanel(frame, filename.GetFullPath(), wxBITMAP_TYPE_GIF);
2077 else if (filename.GetExt() == "jpg" || filename.GetExt() == "jpeg")
2078 _panel = new ImagePanel(frame, filename.GetFullPath(), wxBITMAP_TYPE_JPEG);
2079 else if (filename.GetExt() == "tif" || filename.GetExt() == "tiff")
2080 _panel = new ImagePanel(frame, filename.GetFullPath(), wxBITMAP_TYPE_TIF);
2081 else
2082 {
2083 delete frame;
2084 delete sizer;
2085 return;
2086 }
2087
2088 // Apply the settings for the image viewer
2089 sizer->Add(_panel, 1, wxEXPAND);
2090 _panel->SetSize(_panel->getRelation()*600,600);
2091 frame->SetSizer(sizer);
2092 frame->SetClientSize(_panel->GetSize());
2093 frame->SetIcon(getStandardIcon());
2094 m_currentView = frame;
2095 frame->Show();
2096 frame->SetFocus();
2097}
2098
2099
2108void NumeReWindow::openPDF(wxFileName filename)
2109{
2110 ShellExecuteA(NULL, "open", filename.GetFullPath().ToStdString().c_str(), "", "", SW_SHOW);
2111}
2112
2113
2123void NumeReWindow::openHTML(wxString HTMLcontent)
2124{
2125 //wxString programPath = getProgramFolder();
2126 //if (!HTMLcontent.length())
2127 // return;
2128 //
2129 //ViewerFrame* frame = new ViewerFrame(this, "NumeRe-Hilfe:");
2130 //frame->CreateStatusBar();
2131 //HelpViewer* html = new HelpViewer(frame, this);
2132 //html->SetRelatedFrame(frame, _guilang.get("DOC_HELP_HEADLINE", "%s"));
2133 //html->SetRelatedStatusBar(0);
2134 //html->SetPage(HTMLcontent);
2135 //frame->SetSize(1000,600);
2136 //frame->SetIcon(getStandardIcon());
2137 //frame->Show();
2138 //frame->SetFocus();
2139}
2140
2141
2152void NumeReWindow::openTable(NumeRe::Container<std::string> _stringTable, const std::string& tableDisplayName, const std::string& sIntName)
2153{
2154 ViewerFrame* frame = new ViewerFrame(this, "NumeRe: " + tableDisplayName);
2156 frame->SetSize(800,600);
2157 TableViewer* grid = new TableViewer(frame, wxID_ANY, frame->CreateStatusBar(3), nullptr, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS | wxBORDER_STATIC);
2158 grid->SetData(_stringTable, tableDisplayName, sIntName);
2159 frame->SetSize(std::min(800u, grid->GetWidth()), std::max(std::min(600u, grid->GetHeight()+50), 300u));
2160 frame->SetIcon(getStandardIcon());
2161 frame->Show();
2162 frame->SetFocus();
2163}
2164
2165
2176void NumeReWindow::openTable(NumeRe::Table _table, const std::string& tableDisplayName, const std::string& sIntName)
2177{
2178 ViewerFrame* frame = new ViewerFrame(this, "NumeRe: " + tableDisplayName);
2180 frame->SetSize(800,600);
2181 TablePanel* panel = new TablePanel(frame, wxID_ANY, frame->CreateStatusBar(3));
2182 panel->SetTerminal(m_terminal);
2183 panel->grid->SetData(_table, tableDisplayName, sIntName);
2184 frame->SetSize(std::min(800u, panel->grid->GetWidth()+200), std::max(std::min(600u, panel->grid->GetHeight()+50), 300u));
2185 frame->SetIcon(getStandardIcon());
2186 frame->Show();
2187 frame->SetFocus();
2188}
2189
2190
2201void NumeReWindow::editTable(NumeRe::Container<std::string> _stringTable, const std::string& tableDisplayName)
2202{
2203 ViewerFrame* frame = new ViewerFrame(this, _guilang.get("GUI_TABLEEDITOR") + " " + tableDisplayName);
2204 frame->SetSize(800,600);
2205 TableEditPanel* panel = new TableEditPanel(frame, wxID_ANY, frame->CreateStatusBar(3));
2206 panel->SetTerminal(m_terminal);
2207 panel->grid->SetData(_stringTable, tableDisplayName, "");
2208 frame->SetSize(std::min(800u, panel->grid->GetWidth()), std::max(std::min(600u, panel->grid->GetHeight()+50), 300u));
2209 frame->SetIcon(getStandardIcon());
2210 frame->Show();
2211 frame->SetFocus();
2212}
2213
2214
2225void NumeReWindow::editTable(NumeRe::Table _table, const std::string& tableDisplayName)
2226{
2227 ViewerFrame* frame = new ViewerFrame(this, _guilang.get("GUI_TABLEEDITOR") + " " + tableDisplayName);
2228 frame->SetSize(800,600);
2229 TableEditPanel* panel = new TableEditPanel(frame, wxID_ANY, frame->CreateStatusBar(3));
2230 panel->SetTerminal(m_terminal);
2231 panel->grid->SetData(_table, tableDisplayName, "");
2232 frame->SetSize(std::min(800u, panel->grid->GetWidth()+200), std::max(std::min(600u, panel->grid->GetHeight()+50), 300u));
2233 frame->SetIcon(getStandardIcon());
2234 frame->Show();
2235 frame->SetFocus();
2236}
2237
2238
2249void NumeReWindow::showTable(const wxString& tableName, const wxString& tableDisplayName)
2250{
2251 if (tableDisplayName == "string()" || tableDisplayName.find("{}") != std::string::npos)
2252 openTable(m_terminal->getStringTable(tableName.ToStdString()), tableDisplayName.ToStdString(), tableName.ToStdString());
2253 else
2254 openTable(m_terminal->getTable(tableName.ToStdString()), tableDisplayName.ToStdString(), tableName.ToStdString());
2255}
2256
2257
2268{
2269 if (window.getType() == NumeRe::WINDOW_GRAPH)
2270 {
2271 showGraph(window);
2272 }
2273 else if (window.getType() == NumeRe::WINDOW_MODAL)
2274 {
2276 {
2277 showFileDialog(window);
2278 }
2280 {
2281 showDirDialog(window);
2282 }
2284 {
2285 showTextEntry(window);
2286 }
2288 {
2289 showMessageBox(window);
2290 }
2292 {
2293 showListDialog(window);
2294 }
2296 {
2297 showSelectionDialog(window);
2298 }
2299 }
2300 else if (window.getType() == NumeRe::WINDOW_CUSTOM)
2301 {
2302 CustomWindow* win = new CustomWindow(this, window);
2304 win->Show();
2305 }
2306}
2307
2308
2318{
2319 GraphViewer* viewer = new GraphViewer(this, "NumeRe: " + window.getGraph()->getTitle(), window.getGraph(), m_terminal);
2320 registerWindow(viewer, WT_GRAPH);
2321
2322 viewer->SetIcon(getStandardIcon());
2323 viewer->Show();
2324 viewer->SetFocus();
2325}
2326
2327
2337{
2338 std::string sExpression = window.getWindowSettings().sExpression;
2339 std::string sDir = prepareStringsForDialog(getNextArgument(sExpression, true));
2340 std::string sDefFile = prepareStringsForDialog(getNextArgument(sExpression, true));
2341 std::string sWildCard = prepareStringsForDialog(getNextArgument(sExpression, true));
2342 wxFileDialog dialog(this, window.getWindowSettings().sTitle, sDir, sDefFile, sWildCard);
2343 dialog.SetIcon(getStandardIcon());
2344 int ret = dialog.ShowModal();
2345
2346 if (ret == wxID_CANCEL)
2348 else
2349 window.updateWindowInformation(NumeRe::STATUS_OK, dialog.GetPath().ToStdString());
2350}
2351
2352
2362{
2363 std::string sExpression = window.getWindowSettings().sExpression;
2364 wxDirDialog dialog(this, window.getWindowSettings().sTitle, prepareStringsForDialog(getNextArgument(sExpression, true)));
2365 dialog.SetIcon(getStandardIcon());
2366 int ret = dialog.ShowModal();
2367
2368 if (ret == wxID_CANCEL)
2370 else
2371 window.updateWindowInformation(NumeRe::STATUS_OK, dialog.GetPath().ToStdString());
2372}
2373
2374
2384{
2385 std::string sExpression = window.getWindowSettings().sExpression;
2386 wxTextEntryDialog dialog(this, prepareStringsForDialog(window.getWindowSettings().sMessage), window.getWindowSettings().sTitle, prepareStringsForDialog(getNextArgument(sExpression, true)));
2387 dialog.SetIcon(getStandardIcon());
2388 int ret = dialog.ShowModal();
2389
2390 if (ret == wxID_CANCEL)
2392 else
2393 {
2394 window.updateWindowInformation(NumeRe::STATUS_OK, dialog.GetValue().ToStdString());
2395 }
2396}
2397
2398
2408{
2409 long style = wxCENTRE;
2410 int nControls = window.getWindowSettings().nControls;
2411
2412 if (nControls & NumeRe::CTRL_CANCELBUTTON)
2413 style |= wxCANCEL;
2414
2415 if (nControls & NumeRe::CTRL_OKBUTTON)
2416 style |= wxOK;
2417
2418 if (nControls & NumeRe::CTRL_YESNOBUTTON)
2419 style |= wxYES_NO;
2420
2421 if (nControls & NumeRe::CTRL_ICONQUESTION)
2422 style |= wxICON_QUESTION;
2423
2424 if (nControls & NumeRe::CTRL_ICONINFORMATION)
2425 style |= wxICON_INFORMATION;
2426
2427 if (nControls & NumeRe::CTRL_ICONWARNING)
2428 style |= wxICON_WARNING;
2429
2430 if (nControls & NumeRe::CTRL_ICONERROR)
2431 style |= wxICON_ERROR;
2432
2433 int ret = wxMessageBox(prepareStringsForDialog(window.getWindowSettings().sMessage), window.getWindowSettings().sTitle, style, this);
2434
2435 if (ret == wxOK)
2437 else if (ret == wxCANCEL)
2439 else if (ret == wxYES)
2441 else
2443}
2444
2445
2455{
2456 std::string sExpression = window.getWindowSettings().sExpression;
2457 wxArrayString choices;
2458
2459 while (sExpression.length())
2460 {
2461 choices.Add(prepareStringsForDialog(getNextArgument(sExpression, true)));
2462 }
2463
2464 wxSingleChoiceDialog dialog(this, prepareStringsForDialog(window.getWindowSettings().sMessage), window.getWindowSettings().sTitle, choices);
2465 dialog.SetIcon(getStandardIcon());
2466 int ret = dialog.ShowModal();
2467
2468 if (ret == wxID_CANCEL)
2470 else
2471 {
2472 window.updateWindowInformation(NumeRe::STATUS_OK, choices[dialog.GetSelection()].ToStdString());
2473 }
2474}
2475
2476
2486{
2487 std::string sExpression = window.getWindowSettings().sExpression;
2488 wxArrayString choices;
2489
2490 while (sExpression.length())
2491 {
2492 choices.Add(prepareStringsForDialog(getNextArgument(sExpression, true)));
2493 }
2494
2495 wxMultiChoiceDialog dialog(this, prepareStringsForDialog(window.getWindowSettings().sMessage), window.getWindowSettings().sTitle, choices);
2496 dialog.SetIcon(getStandardIcon());
2497 int ret = dialog.ShowModal();
2498
2499 if (ret == wxID_CANCEL)
2501 else
2502 {
2503 wxArrayInt selections = dialog.GetSelections();
2504
2505 sExpression.clear();
2506
2507 for (size_t i = 0; i < selections.size(); i++)
2508 {
2509 sExpression += choices[selections[i]].ToStdString() + "\",\"";
2510 }
2511
2512 if (sExpression.length())
2513 sExpression.erase(sExpression.length()-3);
2514
2515 window.updateWindowInformation(NumeRe::STATUS_OK, sExpression);
2516 }
2517}
2518
2519
2529void NumeReWindow::pass_command(const wxString& command, bool isEvent)
2530{
2531 m_terminal->pass_command(command.ToStdString(), isEvent);
2532}
2533
2534
2545void NumeReWindow::evaluateDebugInfo(const std::vector<std::string>& vDebugInfo)
2546{
2547 // initialize the debugger, if necessary and pass the new contents
2548 std::string sTitle = vDebugInfo[0];
2549 std::vector<std::string> vStack;
2550
2551 vStack.insert(vStack.begin(), vDebugInfo.begin()+1, vDebugInfo.end());
2552
2553 // If the debug viewer does not yet exist, create a corresponding
2554 // instance here
2555 if (m_debugViewer == nullptr)
2556 {
2557 m_debugViewer = new DebugViewer(this, m_options, sTitle);
2558 m_debugViewer->SetSize(800, 700);
2559 m_debugViewer->SetIcon(getStandardIcon());
2561 }
2562
2563 // If the debug viewer is not shown, show it
2564 if (!m_debugViewer->IsShown())
2565 m_debugViewer->Show();
2566
2567 // Pass the obtained debugging information to the
2568 // debug viewer
2569 m_debugViewer->setDebugInfo(sTitle, vStack);
2570}
2571
2572
2582{
2583 std::string sFileName = m_book->getCurrentEditor()->GetFileNameAndPath().ToStdString();
2585
2586 std::string sDocFile = docGen.createDocumentation(sFileName);
2587
2588 if (sDocFile.length())
2589 wxMessageBox(_guilang.get("GUI_DLG_LATEX_SUCCESS_MESSAGE", sDocFile), _guilang.get("GUI_DLG_LATEX_SUCCESS"), wxCENTER | wxOK, this);
2590 else
2591 wxMessageBox(_guilang.get("GUI_DLG_LATEX_ERROR_MESSAGE", sFileName), _guilang.get("GUI_DLG_LATEX_ERROR"), wxCENTER | wxOK, this);
2592}
2593
2594
2604{
2605 std::string sFileName = m_book->getCurrentEditor()->GetFileNameAndPath().ToStdString();
2607 std::string sMain = docGen.createFullDocumentation(sFileName);
2608
2609 if (!sMain.length())
2610 {
2611 wxMessageBox(_guilang.get("GUI_DLG_LATEX_ERROR_MESSAGE", sFileName), _guilang.get("GUI_DLG_LATEX_ERROR"), wxCENTER | wxOK, this);
2612 return;
2613 }
2614
2615 sMain += " -interaction=nonstopmode";
2616
2617 if (fileExists((m_options->GetLaTeXRoot() + "/xelatex.exe").ToStdString()))
2618 ShellExecuteA(NULL,
2619 "open",
2620 (m_options->GetLaTeXRoot()+"/xelatex.exe").ToStdString().c_str(),
2621 sMain.c_str(),
2622 sMain.substr(0, sMain.rfind('/')).c_str(),
2623 SW_SHOW);
2624 else
2625 wxMessageBox(_guilang.get("GUI_DLG_NOTEXBIN_ERROR", m_options->GetLaTeXRoot().ToStdString()),
2626 _guilang.get("GUI_DLG_NOTEXBIN"), wxCENTER | wxOK | wxICON_ERROR, this);
2627}
2628
2629
2639{
2641
2642 if (fileType == FILE_TEXSOURCE)
2643 {
2644 wxFileName filename = m_book->getCurrentEditor()->GetFileName();
2645
2646 if (fileExists((m_options->GetLaTeXRoot() + "/xelatex.exe").ToStdString()))
2647 ShellExecuteA(NULL,
2648 "open",
2649 (m_options->GetLaTeXRoot()+"/xelatex.exe").ToStdString().c_str(),
2650 (filename.GetName().ToStdString() + " -interaction=nonstopmode").c_str(),
2651 filename.GetPath().ToStdString().c_str(),
2652 SW_SHOW);
2653 else
2654 wxMessageBox(_guilang.get("GUI_DLG_NOTEXBIN_ERROR", m_options->GetLaTeXRoot().ToStdString()),
2655 _guilang.get("GUI_DLG_NOTEXBIN"), wxCENTER | wxOK | wxICON_ERROR, this);
2656 }
2657}
2658
2659
2670{
2671 FileNameTreeData* data = static_cast<FileNameTreeData*>(m_fileTree->GetItemData(m_clickedTreeItem));
2672
2673 if (wxYES != wxMessageBox(_guilang.get("GUI_DLG_DELETE_QUESTION", data->filename.ToStdString()), _guilang.get("GUI_DLG_DELETE"), wxCENTRE | wxICON_QUESTION | wxYES_NO, this))
2674 return;
2675
2677 m_copiedTreeItem = 0;
2678
2679 Recycler _recycler;
2680 _recycler.recycle(data->filename.c_str());
2681}
2682
2683
2693{
2694 FileNameTreeData* target_data = static_cast<FileNameTreeData*>(m_fileTree->GetItemData(m_clickedTreeItem));
2695 FileNameTreeData* source_data = static_cast<FileNameTreeData*>(m_fileTree->GetItemData(m_copiedTreeItem));
2696 wxFileName target_filename = target_data->filename;
2697 wxFileName source_filename = source_data->filename;
2698
2699 target_filename.SetName(source_filename.GetName());
2700 target_filename.SetExt(source_filename.GetExt());
2701
2702 if (wxFileExists(target_filename.GetFullPath()))
2703 {
2704 wxMessageBox(_guilang.get("GUI_DLG_COPY_ERROR"), _guilang.get("GUI_DLG_COPY"), wxCENTRE | wxICON_ERROR | wxOK, this);
2705 return;
2706 }
2707
2708 wxCopyFile(source_filename.GetFullPath(), target_filename.GetFullPath());
2709 m_copiedTreeItem = 0;
2710}
2711
2712
2726{
2727 FileNameTreeData* data = static_cast<FileNameTreeData*>(m_fileTree->GetItemData(m_clickedTreeItem));
2728 wxFileName target_filename = data->filename;
2729 wxFileName source_filename = target_filename;
2730 wxTextEntryDialog textentry(this, _guilang.get("GUI_DLG_RENAME_QUESTION"), _guilang.get("GUI_DLG_RENAME"), target_filename.GetName());
2731 int retval = textentry.ShowModal();
2732
2733 if (retval == wxID_CANCEL)
2734 return;
2735
2736 target_filename.SetName(textentry.GetValue());
2737
2738 if (wxFileExists(target_filename.GetFullPath()))
2739 {
2740 wxMessageBox(_guilang.get("GUI_DLG_RENAME_ERROR"), _guilang.get("GUI_DLG_RENAME"), wxCENTRE | wxICON_ERROR | wxOK, this);
2741 return;
2742 }
2743
2744 VersionControlSystemManager manager(this);
2745
2746 if (manager.hasRevisions(source_filename.GetFullPath()))
2747 {
2748 std::unique_ptr<FileRevisions> revisions(manager.getRevisions(source_filename.GetFullPath()));
2749
2750 if (revisions.get())
2751 revisions->renameFile(source_filename.GetFullName(), target_filename.GetFullName(), manager.getRevisionPath(target_filename.GetFullPath()));
2752 }
2753
2754 wxRenameFile(source_filename.GetFullPath(), target_filename.GetFullPath());
2755 UpdateLocationIfOpen(source_filename, target_filename);
2756}
2757
2758
2769{
2770 std::string fileName = replacePathSeparator(getTreePath(m_clickedTreeItem).ToStdString());
2771
2772 if (fileName.length() && wxTheClipboard->Open())
2773 {
2774 // Add the path to the clipboard
2775 wxTheClipboard->SetData(new wxTextDataObject("\"" + fileName + "\""));
2776 wxTheClipboard->Close();
2777 }
2778}
2779
2780
2790{
2791 wxString fileName = getTreeFolderPath(m_clickedTreeItem);
2792
2793 if (fileName.length())
2794 ShellExecute(nullptr, nullptr, fileName.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
2795}
2796
2797
2806{
2807 FileNameTreeData* data = static_cast<FileNameTreeData*>(m_fileTree->GetItemData(m_clickedTreeItem));
2808 wxString filename = data->filename;
2809 VersionControlSystemManager manager(this);
2810 FileRevisions* revisions = manager.getRevisions(filename);
2811
2812 // Only display the dialog, if the FileRevisions object exists
2813 if (revisions)
2814 {
2815 RevisionDialog* dialog = new RevisionDialog(this, revisions, filename);
2816 dialog->Show();
2817 }
2818}
2819
2820
2829{
2831 wxString filename = edit->GetFileNameAndPath();
2832 VersionControlSystemManager manager(this);
2833 FileRevisions* revisions = manager.getRevisions(filename);
2834
2835 // Only display the dialog, if the FileRevisions object exists
2836 if (revisions)
2837 {
2838 RevisionDialog* dialog = new RevisionDialog(this, revisions, edit->GetFileNameAndPath());
2839 dialog->Show();
2840 }
2841}
2842
2843
2852{
2853 FileNameTreeData* data = static_cast<FileNameTreeData*>(m_fileTree->GetItemData(m_clickedTreeItem));
2854 wxString filename = data->filename;
2855 VersionControlSystemManager manager(this);
2856 std::unique_ptr<FileRevisions> revisions(manager.getRevisions(filename));
2857
2858 // Only do something, if the FileRevisions object exists
2859 if (revisions.get())
2860 {
2861 // Display a text entry dialog to provide the user to
2862 // enter a comment for the new tag
2863 wxTextEntryDialog textdialog(this, _guilang.get("GUI_DLG_REVISIONDIALOG_PROVIDETAGCOMMENT"), _guilang.get("GUI_DLG_REVISIONDIALOG_PROVIDETAGCOMMENT_TITLE"), wxEmptyString, wxCENTER | wxOK | wxCANCEL);
2864 int ret = textdialog.ShowModal();
2865
2866 if (ret == wxID_OK)
2867 {
2868 // Create the tag, if the user clicked on OK
2869 revisions->tagRevision(revisions->getCurrentRevision(), textdialog.GetValue());
2870 }
2871 }
2872}
2873
2874
2885{
2886 wxString fileName = getTreeFolderPath(m_clickedTreeItem);
2887
2888 if (!fileName.length())
2889 return;
2890
2891 wxTextEntryDialog textentry(this, _guilang.get("GUI_DLG_NEWFOLDER_QUESTION"), _guilang.get("GUI_DLG_NEWFOLDER"), _guilang.get("GUI_DLG_NEWFOLDER_DFLT"));
2892 int retval = textentry.ShowModal();
2893
2894 if (retval == wxID_CANCEL)
2895 return;
2896
2897 if (textentry.GetValue().length())
2898 {
2899 wxString foldername = fileName + "\\" + textentry.GetValue();
2900 wxMkdir(foldername);
2901 }
2902}
2903
2904
2914{
2915 FileNameTreeData* data = static_cast<FileNameTreeData*>(m_fileTree->GetItemData(m_clickedTreeItem));
2916
2917 if (wxYES != wxMessageBox(_guilang.get("GUI_DLG_DELETE_QUESTION", data->filename.ToStdString()), _guilang.get("GUI_DLG_DELETE"), wxCENTRE | wxICON_QUESTION | wxYES_NO, this))
2918 return;
2919
2921 m_copiedTreeItem = 0;
2922
2923 Recycler _recycler;
2924 _recycler.recycle(data->filename.ToStdString().c_str());
2925 return;
2926}
2927
2928
2939void NumeReWindow::EvaluateCommandLine(wxArrayString& wxArgV)
2940{
2941 g_logger.info("Evaluating command line arguments.");
2942 wxArrayString filestoopen;
2943 wxString ext;
2944
2945 for (size_t i = 1; i < wxArgV.size(); i++)
2946 {
2947 if (wxArgV[i].find('.') == std::string::npos)
2948 continue;
2949
2950 if (wxArgV[i].find(".exe") != std::string::npos)
2951 continue;
2952
2953 ext = toLowerCase(wxArgV[i].substr(wxArgV[i].rfind('.')).ToStdString());
2954
2955 // Scripts: run or open?
2956 if (ext == ".nscr")
2957 {
2958 if (i+1 < wxArgV.size() && wxArgV[i+1] == "-e")
2959 {
2960 m_terminal->pass_command("start \"" + replacePathSeparator(wxArgV[i].ToStdString()) + "\"", false);
2961 i++;
2962 }
2963 else
2964 filestoopen.Add(wxArgV[i]);
2965 }
2966
2967 // Window-Layouts: run or open?
2968 if (ext == ".nlyt")
2969 {
2970 if (i+1 < wxArgV.size() && wxArgV[i+1] == "-e")
2971 {
2972 m_terminal->pass_command("window \"" + replacePathSeparator(wxArgV[i].ToStdString()) + "\"", false);
2973 i++;
2974 }
2975 else
2976 filestoopen.Add(wxArgV[i]);
2977 }
2978
2979 // Package creator projects
2980 if (ext == ".npkp")
2981 OnCreatePackage(wxArgV[i]);
2982
2983 // Procedures: run or open?
2984 if (ext == ".nprc")
2985 {
2986 if (i+1 < wxArgV.size() && wxArgV[i+1] == "-e")
2987 {
2988 m_terminal->pass_command("$'" + replacePathSeparator(wxArgV[i].substr(0, wxArgV[i].rfind('.')).ToStdString()) + "'()", false);
2989 i++;
2990 }
2991 else
2992 filestoopen.Add(wxArgV[i]);
2993 }
2994
2995 // Usual text files
2996 if (ext == ".dat"
2997 || ext == ".nhlp"
2998 || ext == ".xml"
2999 || ext == ".txt"
3000 || ext == ".tex")
3001 filestoopen.Add(wxArgV[i]);
3002
3003 // Data files
3004 if (ext == ".ods"
3005 || ext == ".ibw"
3006 || ext == ".csv"
3007 || ext == ".jdx"
3008 || ext == ".jcm"
3009 || ext == ".dx"
3010 || ext == ".xls"
3011 || ext == ".xlsx"
3012 || ext == ".labx"
3013 || ext == ".ndat")
3014 m_terminal->pass_command("append \"" + replacePathSeparator(wxArgV[i].ToStdString()) + "\"", false);
3015 }
3016
3017 if (filestoopen.size())
3018 OpenSourceFile(filestoopen);
3019}
3020
3021
3030void NumeReWindow::NewFile(FileFilterType _filetype, const wxString& defaultfilename)
3031{
3032 if (!m_fileNum)
3033 {
3034 DefaultPage();
3035 return;
3036 }
3037 if (_filetype == FILE_NONSOURCE)
3038 {
3039 m_fileNum += 1;
3040
3041 //wxString locationPrefix = "(?) ";
3042
3043 wxString noname = _guilang.get("GUI_NEWFILE_UNTITLED") + " " + wxString::Format ("%d", m_fileNum);
3044 NumeReEditor* edit = m_book->createEditor(noname);
3045 //edit->SetSyntax(m_terminal->getSyntax());
3046
3047 #if wxUSE_DRAG_AND_DROP
3048 edit->SetDropTarget(new NumeReDropTarget(this, edit, NumeReDropTarget::EDITOR));
3049 #endif
3050
3051 edit->SetText("\r\n");
3052 int settings = CopyEditorSettings(_filetype);
3053
3054 edit->EmptyUndoBuffer();
3055 m_currentPage = m_book->GetPageCount()-1;
3056 edit->ToggleSettings(settings);
3057 m_book->ChangeSelection(m_currentPage);
3058 m_book->SetSelection(m_currentPage);
3059 }
3060 else if (_filetype == FILE_DIFF)
3061 {
3062 wxString filename = defaultfilename;
3063
3064 std::vector<std::string> vPaths = m_terminal->getPathSettings();
3065
3066 m_fileNum += 1;
3067
3068 // Create a new editor
3069 NumeReEditor* edit = m_book->createEditor("");
3070 edit->SetText("DIFF");
3071 int settings = CopyEditorSettings(_filetype);
3072
3073 // Set the corresponding full file name
3074 edit->SetFilename(wxFileName(vPaths[SAVEPATH], filename), false);
3075
3076 m_currentPage = m_book->GetPageCount()-1;
3078
3079 // Add a new tab for the editor
3081 edit->ToggleSettings(settings);
3082 m_book->ChangeSelection(m_currentPage);
3083 m_book->SetSelection(m_currentPage);
3084 }
3085 else
3086 {
3087 wxString filename;
3088 wxString folder;
3089 wxTextEntryDialog* textentry;
3090
3091 // If no default file name was passed, ask
3092 // the user
3093 if (!defaultfilename.length())
3094 {
3095 if (_filetype == FILE_NSCR)
3096 textentry = new wxTextEntryDialog(this, _guilang.get("GUI_DLG_NEWNSCR_QUESTION"), _guilang.get("GUI_DLG_NEWNSCR"), _guilang.get("GUI_DLG_NEWNSCR_DFLT"));
3097 else if (_filetype == FILE_NLYT)
3098 textentry = new wxTextEntryDialog(this, _guilang.get("GUI_DLG_NEWNLYT_QUESTION"), _guilang.get("GUI_DLG_NEWNLYT"), _guilang.get("GUI_DLG_NEWNLYT_DFLT"));
3099 else if (_filetype == FILE_NPRC)
3100 textentry = new wxTextEntryDialog(this, _guilang.get("GUI_DLG_NEWNPRC_QUESTION"), _guilang.get("GUI_DLG_NEWNPRC"), _guilang.get("GUI_DLG_NEWNPRC_DFLT"));
3101 else
3102 textentry = new wxTextEntryDialog(this, _guilang.get("GUI_DLG_NEWPLUGIN_QUESTION"), _guilang.get("GUI_DLG_NEWPLUGIN"), _guilang.get("GUI_DLG_NEWPLUGIN_DFLT"));
3103
3104 int retval = textentry->ShowModal();
3105
3106 if (retval == wxID_CANCEL)
3107 {
3108 delete textentry;
3109 return;
3110 }
3111
3112 // Get the file name, if the user didn't hit "Cancel"
3113 filename = textentry->GetValue();
3114 delete textentry;
3115 }
3116 else
3117 filename = defaultfilename;
3118
3119 // Remove the dollar sign, if there is one
3120 if (filename.find('$') != std::string::npos)
3121 filename.erase(filename.find('$'),1);
3122
3123 // Remove the path parts from the file name
3124 // These are either the tilde, the slash or the
3125 // backslash
3126 if (filename.find('~') != std::string::npos)
3127 {
3128 folder = filename.substr(0, filename.rfind('~')+1);
3129 filename.erase(0, filename.rfind('~')+1);
3130 }
3131
3132 if (filename.find('/') != std::string::npos)
3133 {
3134 if (folder.length())
3135 folder += "/" + filename.substr(0, filename.rfind('/')+1);
3136 else
3137 folder = filename.substr(0, filename.rfind('/')+1);
3138
3139 filename.erase(0, filename.rfind('/')+1);
3140 }
3141
3142 if (filename.find('\\') != std::string::npos)
3143 {
3144 if (folder.length())
3145 folder += "/" + filename.substr(0, filename.rfind('\\')+1);
3146 else
3147 folder = filename.substr(0, filename.rfind('\\')+1);
3148
3149 filename.erase(0, filename.rfind('\\')+1);
3150 }
3151
3152 // Replace all path separators
3153 if (folder.length())
3154 {
3155 while (folder.find('~') != std::string::npos)
3156 folder[folder.find('~')] = '\\';
3157 while (folder.find('/') != std::string::npos)
3158 folder[folder.find('/')] = '\\';
3159 }
3160
3161 if (folder == "main\\" && _filetype == FILE_NPRC)
3162 folder.clear();
3163 else
3164 folder.insert(0,"\\");
3165
3166 // Clean the file and folder names for procedures -
3167 // we only allow alphanumeric characters
3168 if (_filetype == FILE_NPRC)
3169 {
3170 // Clean the folders
3171 for (size_t i = 0; i < folder.length(); i++)
3172 {
3173 if (!isalnum(folder[i]) && folder[i] != '_' && folder[i] != '\\' && folder[i] != ':')
3174 folder[i] = '_';
3175 }
3176
3177 // Clean the file
3178 for (size_t i = 0; i < filename.length(); i++)
3179 {
3180 if (!isalnum(filename[i]) && filename[i] != '_')
3181 filename[i] = '_';
3182 }
3183 }
3184
3185 // Prepare the template file
3186 wxString template_file, dummy, timestamp;
3187
3188 // Search the correct filename
3189 if (_filetype == FILE_NSCR)
3190 dummy = "tmpl_script.nlng";
3191 else if (_filetype == FILE_NLYT)
3192 dummy = "tmpl_layout.nlng";
3193 else if (_filetype == FILE_PLUGIN)
3194 dummy = "tmpl_plugin.nlng";
3195 else
3196 dummy = "tmpl_procedure.nlng";
3197
3198 timestamp = getTimeStamp(false);
3199
3200 // Get the template file contents
3201 if (m_options->useCustomLangFiles() && wxFileExists(getProgramFolder() + "\\user\\lang\\"+dummy))
3202 GetFileContents(getProgramFolder() + "\\user\\lang\\"+dummy, template_file, dummy);
3203 else
3204 GetFileContents(getProgramFolder() + "\\lang\\"+dummy, template_file, dummy);
3205
3206 // Replace the tokens in the file
3207 template_file.Replace("%%1%%", filename);
3208 template_file.Replace("%%2%%", timestamp);
3209
3210 // Determine the file extension
3211 if (_filetype == FILE_NSCR)
3212 filename += ".nscr";
3213 else if (_filetype == FILE_NLYT)
3214 filename += ".nlyt";
3215 else if (_filetype == FILE_PLUGIN)
3216 filename = "plgn_" + filename + ".nscr";
3217 else if (_filetype == FILE_NPRC)
3218 filename += ".nprc";
3219
3220 std::vector<std::string> vPaths = m_terminal->getPathSettings();
3221
3222 m_fileNum += 1;
3223
3224 // Create a new editor
3225 NumeReEditor* edit = m_book->createEditor("");
3226 edit->SetText(template_file);
3227
3228 int settings = CopyEditorSettings(_filetype);
3229
3230 // Set the corresponding full file name
3231 if (_filetype == FILE_NSCR || _filetype == FILE_PLUGIN || _filetype == FILE_NLYT)
3232 edit->SetFilename(wxFileName(vPaths[SCRIPTPATH] + folder, filename), false);
3233 else if (_filetype == FILE_NPRC)
3234 edit->SetFilename(wxFileName(vPaths[PROCPATH] + folder, filename), false);
3235 else
3236 edit->SetFilename(wxFileName(vPaths[SAVEPATH] + folder, filename), false);
3237
3238 m_currentPage = m_book->GetPageCount()-1;
3240
3241 // Jump to the predefined template position
3242 edit->GotoPipe();
3243
3244 edit->SetUnsaved();
3245 edit->EmptyUndoBuffer();
3246
3247 // Add a new tab for the editor
3249 edit->ToggleSettings(settings);
3250 m_book->ChangeSelection(m_currentPage);
3251 m_book->SetSelection(m_currentPage);
3252 }
3253}
3254
3255
3266void NumeReWindow::ShowRevision(const wxString& revisionName, const wxString& revisionContent)
3267{
3268 NewFile(FILE_DIFF, revisionName);
3270 edit->SetText(revisionContent);
3271 edit->EmptyUndoBuffer();
3272 edit->SetUnsaved();
3273 edit->UpdateSyntaxHighlighting(true);
3274}
3275
3276
3287{
3289 {
3290 int settings = m_book->getCurrentEditor()->getSettings();
3291
3292 if (_fileType != FILE_NSCR && _fileType != FILE_NPRC && _fileType != FILE_MATLAB && _fileType != FILE_PLUGIN && _fileType != FILE_XML)
3293 {
3295 settings &= ~NumeReEditor::SETTING_INDENTONTYPE;
3296
3297 if (settings & NumeReEditor::SETTING_USEANALYZER)
3298 settings &= ~NumeReEditor::SETTING_USEANALYZER;
3299 }
3300 else
3301 {
3302 if (settings & NumeReEditor::SETTING_USETXTADV)
3303 settings &= ~NumeReEditor::SETTING_USETXTADV;
3304 }
3305
3306 return settings;
3307 }
3308
3309 return 0;
3310}
3311
3312
3322{
3323 wxString template_file, dummy;
3324 dummy = "tmpl_defaultpage.nlng";
3325
3326 if (m_options->useCustomLangFiles() && wxFileExists(getProgramFolder() + "\\user\\lang\\"+dummy))
3327 GetFileContents(getProgramFolder() + "\\user\\lang\\"+dummy, template_file, dummy);
3328 else
3329 GetFileContents(getProgramFolder() + "\\lang\\"+dummy, template_file, dummy);
3330
3331 m_fileNum += 1;
3332
3333 NumeReEditor* edit = m_book->createEditor(_guilang.get("GUI_EDITOR_TAB_WELCOMEPAGE"));
3334
3335#if wxUSE_DRAG_AND_DROP
3336 edit->SetDropTarget(new NumeReDropTarget(this, edit, NumeReDropTarget::EDITOR));
3337#endif
3338
3339 edit->LoadFileText(template_file);
3340 edit->defaultPage = true;
3341 edit->SetReadOnly(true);
3343 m_currentPage = m_book->GetPageCount()-1;
3344 m_book->SetSelection(m_currentPage);
3345}
3346
3347
3359{
3360 // no pages - null out the current ed pointer
3361 // You know, this should really never happen with the current design
3362 // 3/11/04: Unless, of course, we're closing out the program...
3363 if (m_book->GetPageCount() == 0)
3364 {
3365 m_currentPage = -1;
3367 return;
3368 }
3369
3370 // no page passed in
3371 if (pageNr == -1)
3372 {
3373 pageNr = m_book->GetSelection();
3374 }
3375
3376 if ((int)m_book->GetPageCount() <= pageNr)
3377 {
3378 pageNr = m_book->GetPageCount() - 1;
3379 }
3380
3381 // activate the selected page
3382 if (pageNr >= 0)
3383 {
3385
3386 if (edit->AutoCompActive())
3387 edit->AutoCompCancel();
3388
3389 if (edit->CallTipActive())
3390 edit->AdvCallTipCancel();
3391
3392 m_currentPage = pageNr;
3393 edit = m_book->getEditor(m_currentPage); // might need adaptions for the procedure viewer
3394 m_book->SetSelection(pageNr);
3395
3396 //if (!m_book->GetMouseFocus())
3397 edit->SetFocus();
3398 }
3399 else
3400 {
3401 m_currentPage = -1;
3402 }
3403
3404 // Set the current editor in the procedure viewer,
3405 // but avoid refreshing during closing the application
3408 else
3410
3411 m_book->Refresh();
3412
3413 if (m_book->getCurrentEditor() != nullptr)
3414 {
3416
3423
3424 edit->Refresh();
3425
3426 wxString tabText = m_book->GetPageText(m_currentPage);
3427 // set the title of the main window according the current opened file
3428 UpdateWindowTitle(tabText);
3429
3430 // else assume unsaved file and don't change anything
3431 }
3432}
3433
3434
3445{
3446 int tab = GetIntVar(VN_CLICKEDTAB);
3447 CloseFile(tab, !force);
3448 m_book->Refresh();
3449}
3450
3451
3461{
3462 int tab = GetIntVar(VN_CLICKEDTAB);
3463
3464 // Close all pages left from the current tab
3465 while (tab)
3466 {
3467 CloseFile(0);
3468 tab--;
3469 }
3470
3471 // Close all pages right from the current tab
3472 while (m_book->GetPageCount() > 1)
3473 CloseFile(1);
3474
3475 m_book->Refresh();
3476}
3477
3478
3488{
3489 int tab = GetIntVar(VN_CLICKEDTAB);
3490 NumeReEditor* edit = m_book->getEditor(tab);
3491 wxFileName filename = edit->GetFileName();
3492 wxExecute("explorer " + filename.GetPath(), wxEXEC_ASYNC, nullptr, nullptr);
3493}
3494
3495
3505{
3506 int tab = GetIntVar(VN_CLICKEDTAB);
3507 NumeReEditor* edit = m_book->getEditor(tab);
3508
3509 if (!edit->HasBeenSaved() || edit->Modified())
3510 {
3511 int result = HandleModifiedFile(tab, MODIFIEDFILE_COMPILE);
3512
3513 if (result == wxCANCEL)
3514 return;
3515 }
3516
3517 std::string command = replacePathSeparator((edit->GetFileName()).GetFullPath().ToStdString());
3518 OnExecuteFile(command, 0);
3519}
3520
3521
3531void NumeReWindow::CloseFile(int pageNr, bool askforsave)
3532{
3533 if (pageNr == -1)
3534 {
3535 pageNr = m_book->GetSelection();
3536 }
3537
3538 if (askforsave)
3539 {
3540 // gives the user a chance to save if the file has been modified
3541 int modifiedFileResult = HandleModifiedFile(pageNr, MODIFIEDFILE_CLOSE);
3542
3543 // a wxYES result is taken care of inside HandleModifiedFile, and a
3544 // wxNO is handled implicitly by the fact that the file isn't saved.
3545 if(modifiedFileResult == wxCANCEL)
3546 {
3547 return;
3548 }
3549 }
3550
3551 if (m_book->GetPageCount() > 0)
3552 {
3554
3555 g_logger.info("Closing file '" + edit->GetFileNameAndPath().ToStdString() + "'.");
3556 wxFileName currentFileName;
3557 m_terminal->clearBreakpoints(edit->GetFileNameAndPath().ToStdString());
3558
3559 if ((m_book->GetPageCount() > 1) || m_appClosing)
3560 {
3561 currentFileName = edit->GetFileName();
3562 //NumeReEditor* pEdit = static_cast <NumeReEditor* >(m_book->GetPage(pageNr));
3563 m_book->DeletePage (pageNr);
3564 m_watcher->Remove(currentFileName);
3565 }
3566 // closing out the last buffer, reset it to act as a new one
3567 else
3568 {
3569 m_fileNum = 1;
3570 m_watcher->Remove(edit->GetFileName());
3571 //wxString locationPrefix = "(?) ";
3572 wxString noname = _guilang.get("GUI_NEWFILE_UNTITLED") + " " + wxString::Format ("%d", m_fileNum);
3573 m_book->SetPageText (pageNr, noname);
3574 edit->ResetEditor();
3575 edit->SetText("\r\n");
3576 edit->EmptyUndoBuffer();
3577 }
3578
3579 if(m_book->GetPageCount() > 0)
3580 {
3581 if(currentFileName.IsOk())
3582 {
3583 int newSelectedPageNum = GetPageNum(currentFileName);
3584 PageHasChanged(newSelectedPageNum);
3585 }
3586 }
3587 }
3588}
3589
3590
3600{
3601 int cnt = m_book->GetPageCount();
3602 std::ofstream of_session;
3603 NumeReEditor* edit;
3604 std::string sSession = "# numere.session: Session save file. Do not edit!\n# ACTIVEFILE\tFILEID\nACTIVEFILEID\t" + toString(m_book->GetSelection()) + "\n# FILENAME\t\tFILEID\t\tCHARPOSITION\t\tSETTING\t\tBOOKMARKS\n";
3605
3606 for (int i = 0; i < cnt; i++)
3607 {
3608 edit = m_book->getEditor(i);
3609
3610 if (edit->defaultPage)
3611 continue;
3612
3613 // gives the user a chance to save if the file has been modified
3614 int nReturn = HandleModifiedFile(i, MODIFIEDFILE_CLOSE);
3615
3616 if (nReturn == wxCANCEL)
3617 return false;
3618
3619 if (edit->Modified())
3620 sSession += "*";
3621
3622 if (edit->GetFileNameAndPath().length())
3623 {
3624 g_logger.info("Adding file '" + edit->GetFileNameAndPath().ToStdString() + "' to the session backup.");
3625 sSession += edit->GetFileNameAndPath().ToStdString()
3626 + "\t" + toString(i)
3627 + "\t" + toString(edit->GetCurrentPos())
3628 + "\t" + toString(edit->getSettings())
3629 + (m_options->GetSaveBookmarksInSession() ? "\t" + toString(edit->getBookmarks()) + "\n" : "\n");
3630 }
3631 else
3632 {
3633 sSession += "<NEWFILE>\t" +toString(i) + "\t" + toString(edit->GetCurrentPos()) + "\n";
3634 }
3635 }
3636
3637 g_logger.debug("Closing files.");
3638
3639 for (int i = 0; i < cnt; i++)
3640 {
3641 CloseFile(-1, false);
3642 }
3643
3645 {
3646 g_logger.debug("Writing session file.");
3647 of_session.open((getProgramFolder().ToStdString()+"/numere.session").c_str(), std::ios_base::out | std::ios_base::trunc);
3648
3649 if (of_session.is_open())
3650 {
3651 of_session << sSession;
3652 }
3653
3654 m_sessionSaved = true;
3655 }
3656
3658
3659 return true;
3660}
3661
3662
3675int NumeReWindow::GetPageNum(wxFileName fn, bool compareWholePath, int startingTab)
3676{
3677 NumeReEditor *edit;
3678 int numPages = m_book->GetPageCount();
3679 wxString filename = fn.GetFullName();
3680
3681 for (int pageNum = startingTab; pageNum < numPages; pageNum++)
3682 {
3683 edit = m_book->getEditor(pageNum);
3684
3685 bool fileMatches = false;
3686
3687 if(compareWholePath)
3688 {
3689 fileMatches = (edit->GetFileName() == fn);
3690 }
3691 else
3692 {
3693 fileMatches = (edit->GetFilenameString() == filename);
3694 }
3695 if (fileMatches)
3696 {
3697 return pageNum;
3698 }
3699 }
3700
3701 return -1;
3702}
3703
3704
3715void NumeReWindow::OnPageChange (wxAuiNotebookEvent& event)
3716{
3717 if (!m_setSelection)
3718 {
3721 }
3722}
3723
3724
3736{
3737 NumeReEditor *edit = m_book->getEditor(pageNr);
3738
3739 if (!edit)
3740 {
3741 return wxCANCEL;
3742 }
3743
3744 if (edit->Modified())
3745 {
3746 wxString saveMessage = "The file ";
3747 wxString fileName = edit->GetFileNameAndPath();
3748
3749 // the file hasn't been saved yet, grab the "<untitled> #" bit from the tab
3750 if(fileName == wxEmptyString)
3751 {
3752 int selectedTab = m_book->GetSelection();
3753 wxString tabText = m_book->GetPageText(selectedTab);
3754
3755 int idx = tabText.Index('*');
3756
3757 if(idx != wxNOT_FOUND)
3758 {
3759 tabText.Remove(idx, 1);
3760 }
3761
3762 // remove the (R), (L), or (?) from the tab
3763 wxRegEx reLocationPrefix("\\((R|L|\\?)\\) ");
3764 reLocationPrefix.Replace(&tabText, wxEmptyString);
3765
3766 fileName = tabText;
3767 }
3768 //saveMessage += fileName;
3769
3770 //saveMessage << " has unsaved changes. ";
3771 saveMessage = _guilang.get("GUI_UNSAVEDFILE", fileName.ToStdString());
3772 /*
3773 if(closingFile)
3774 {
3775 saveMessage += "closed?";
3776 }
3777 else
3778 {
3779 saveMessage += "reloaded?";
3780 }
3781 */
3782
3783 switch(fileAction)
3784 {
3785 case MODIFIEDFILE_CLOSE:
3786 {
3787 saveMessage += " " +_guilang.get("GUI_UNSAVEDFILE_CLOSE");//"Do you want to save them before the file is closed?";
3788 break;
3789 }
3791 {
3792 saveMessage += "Do you want to save them before the file is reloaded?";
3793 break;
3794 }
3796 {
3797 saveMessage += " " + _guilang.get("GUI_UNSAVEDFILE_EXECUTE");
3798 break;
3799 }
3800 }
3801
3802 int options = wxYES_NO | wxICON_QUESTION | wxCANCEL;
3803
3804 /*if(fileAction != MODIFIEDFILE_COMPILE)
3805 {
3806 options |= wxCANCEL;
3807 }*/
3808
3809 int result = m_options->getSetting(SETTING_B_AUTOSAVEEXECUTION).active() ? wxYES : wxNO;
3810
3812 result = wxMessageBox (saveMessage, _guilang.get("GUI_SAVE_QUESTION"), options);//wxYES_NO | wxCANCEL | wxICON_QUESTION);
3813
3814 if (result == wxYES)
3815 {
3816 size_t selection = m_book->GetSelection();
3817 m_book->ChangeSelection(pageNr);
3818 // only do a Save As if necessary
3819 SaveCurrentFile(false);
3820 m_book->ChangeSelection(selection);
3821 m_book->getCurrentEditor()->SetFocus();
3822
3823 if (edit->Modified())
3824 {
3825 wxString errorMessage = fileName + " could not be saved!";
3826 wxMessageBox (errorMessage, "File not closed",
3827 wxOK | wxICON_EXCLAMATION);
3828 m_book->getCurrentEditor()->Refresh();
3829 }
3830 }
3831
3832 return result;
3833 }
3834 // if I'm here, doesn't matter if I return wxNO or wxYES, just as long as it's not wxCANCEL
3835 return wxNO;
3836}
3837
3838
3855{
3856 wxArrayString fnames;
3857
3858 if (!m_book->getCurrentEditor())
3859 return fnames;
3860
3861 wxString filterString = ConstructFilterString(filterType);
3862
3863 wxFileDialog dlg (this, _(_guilang.get("GUI_DLG_OPEN")), "", "", filterString, wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR);
3864
3865 if (dlg.ShowModal() != wxID_OK)
3866 return fnames;
3867
3868 m_book->getCurrentEditor()->SetFocus();
3869 dlg.GetPaths (fnames);
3870
3871 return fnames;
3872}
3873
3874
3885void NumeReWindow::OpenFileByType(const wxFileName& filename)
3886{
3887 if (filename.GetExt() == "nscr"
3888 || filename.GetExt() == "nprc"
3889 || filename.GetExt() == "nhlp"
3890 || filename.GetExt() == "nlng"
3891 || filename.GetExt() == "nlyt"
3892 || filename.GetExt() == "txt"
3893 || filename.GetExt() == "dat"
3894 || filename.GetExt() == "log"
3895 || filename.GetExt() == "m"
3896 || filename.GetExt() == "cpp"
3897 || filename.GetExt() == "cxx"
3898 || filename.GetExt() == "c"
3899 || filename.GetExt() == "hpp"
3900 || filename.GetExt() == "hxx"
3901 || filename.GetExt() == "h"
3902 || filename.GetExt() == "xml"
3903 || filename.GetExt() == "tex"
3904 || filename.GetExt() == "diff")
3905 {
3906 wxArrayString filesToOpen;
3907 filesToOpen.Add(filename.GetFullPath());
3908 OpenSourceFile(filesToOpen);
3909 CallAfter(&NumeReWindow::setEditorFocus);
3910 }
3911 else if (filename.GetExt() == "png"
3912 || filename.GetExt() == "jpeg"
3913 || filename.GetExt() == "jpg"
3914 || filename.GetExt() == "bmp"
3915 || filename.GetExt() == "gif"
3916 || filename.GetExt() == "tif"
3917 || filename.GetExt() == "tiff")
3918 {
3919 openImage(filename);
3920 CallAfter(&NumeReWindow::setViewerFocus);
3921 }
3922 else if (filename.GetExt() == "pdf")
3923 openPDF(filename);
3924 else if (filename.GetExt() == "npkp")
3925 OnCreatePackage(filename.GetFullPath());
3926 else
3927 {
3928 wxString path = "load \"" + replacePathSeparator(filename.GetFullPath().ToStdString()) + "\" -app -ignore";
3929 showConsole();
3930 m_terminal->pass_command(path.ToStdString(), false);
3931 }
3932}
3933
3934
3944void NumeReWindow::OpenFilesFromList(const wxArrayString& filenameslist)
3945{
3946 for (size_t i = 0; i < filenameslist.size(); i++)
3947 {
3948 OpenFileByType(wxFileName(filenameslist[i]));
3949 }
3950}
3951
3952
3963void NumeReWindow::OpenSourceFile(wxArrayString fnames, unsigned int nLine, int nOpenFileFlag)
3964{
3965 int firstPageNr = -1;
3966 wxString fileContents = wxEmptyString;
3967 wxString fileNameNoPath;
3968
3969 for (size_t n = 0; n < fnames.GetCount(); n++)
3970 {
3971 fileNameNoPath = wxEmptyString;
3972 wxFileName newFileName(fnames[n]);
3973 int pageNr = GetPageNum(newFileName);
3974
3975 if (!GetFileContents(fnames[n], fileContents, fileNameNoPath))
3976 return;
3977
3978 if (nOpenFileFlag & OPENFILE_BLACKLIST_ADD)
3979 addToReloadBlackList(fnames[n]);
3980
3981 if (nOpenFileFlag & OPENFILE_BLACKLIST_REMOVE)
3982 removeFromReloadBlackList(fnames[n]);
3983
3984 // filename is already open
3985 if (pageNr >= 0)
3986 {
3987 if (nLine)
3988 {
3989 PageHasChanged(pageNr);
3990 m_book->getFocusedEditor()->FocusOnLine(nLine, true);
3991 }
3992 else
3993 {
3994 // Reload if required (or simply do nothing)
3995 if (nOpenFileFlag & (OPENFILE_FORCE | OPENFILE_BLACKLIST_REMOVE))
3996 {
3997 m_setSelection = true;
3998 m_book->SetSelection (pageNr);
3999 m_setSelection = false;
4000 m_currentPage = pageNr;
4001
4002 NumeReEditor* edit = m_book->getEditor(m_currentPage); // Needs work for the syntax highlighting
4003 edit->LoadFileText(fileContents);
4005
4006 if (m_book->getCurrentEditor(true))
4008 }
4009 else
4010 PageHasChanged(pageNr);
4011 }
4012 }
4013 else
4014 {
4015 g_logger.info("Loading file '" + fnames[n].ToStdString() + "'.");
4016 FileFilterType _fileType;
4017
4018 if (fnames[n].rfind(".nscr") != std::string::npos)
4019 _fileType = FILE_NSCR;
4020 else if (fnames[n].rfind(".nprc") != std::string::npos)
4021 _fileType = FILE_NPRC;
4022 else if (fnames[n].rfind(".xml") != std::string::npos || fnames[n].rfind(".nhlp") != std::string::npos)
4023 _fileType = FILE_XML;
4024 else
4025 _fileType = FILE_NOTYPE;
4026
4028
4029 // current buffer is empty and untouched, so load the file into it
4030 if ((!edit->Modified()
4031 && !edit->HasBeenSaved()
4032 && (edit->GetText().IsEmpty() || edit->GetText() == "\r\n")) || edit->defaultPage )
4033 {
4034 edit->LoadFileText(fileContents);
4035 edit->SetFilename(newFileName, m_remoteMode);
4037 }
4038 // need to create a new buffer for the file
4039 else
4040 {
4041 NumeReEditor *edit = m_book->createEditor("");
4042#if wxUSE_DRAG_AND_DROP
4043 edit->SetDropTarget(new NumeReDropTarget(this, edit, NumeReDropTarget::EDITOR));
4044#endif
4045 edit->LoadFileText(fileContents);
4046 int settings = CopyEditorSettings(_fileType);
4047 m_currentPage = m_book->GetPageCount()-1;
4048 edit->SetFilename(newFileName, m_remoteMode);
4049 edit->ToggleSettings(settings);
4051 m_book->SetSelection(m_currentPage);
4052 }
4053
4055
4057 {
4059
4060 if (m_book->getCurrentEditor(true))
4062 }
4063
4064 m_watcher->Add(newFileName);
4065
4066 if (nLine)
4067 {
4068 m_book->getFocusedEditor()->GotoLine(nLine);
4069 m_book->getFocusedEditor()->EnsureVisible(nLine);
4070 }
4071 }
4072
4073 if (firstPageNr < 0)
4074 firstPageNr = m_currentPage;
4075
4076 }
4077
4078 // show the active tab, new or otherwise
4079 if (firstPageNr >= 0)
4080 PageHasChanged(firstPageNr);
4081
4082 m_book->getCurrentEditor()->SetFocus();
4083}
4084
4085
4098bool NumeReWindow::GetFileContents(wxString fileToLoad, wxString &fileContents, wxString &fileName)
4099{
4100 wxFileName fn(fileToLoad);
4101 wxFile file(fileToLoad);
4102
4103 if (!file.IsOpened())
4104 {
4105 return false;
4106 }
4107
4108 long lng = file.Length();
4109
4110 if (lng > 0)
4111 {
4112 file.ReadAll(&fileContents, wxConvAuto(wxFONTENCODING_CP1252));
4113 }
4114
4115 fileName = fn.GetFullName();
4116 return true;
4117}
4118
4119
4128{
4129 wxTreeItemId retVal = m_dragDropSourceItem;
4130 m_dragDropSourceItem = wxTreeItemId();
4131 return retVal;
4132}
4133
4134
4144wxString NumeReWindow::getTreePath(const wxTreeItemId& itemId)
4145{
4146 if (!itemId.IsOk())
4147 return wxString();
4148
4149 FileNameTreeData* data = static_cast<FileNameTreeData*>(m_fileTree->GetItemData(itemId));
4150 wxString pathName;
4151
4152 if (!data)
4153 {
4154 std::vector<std::string> vPaths = m_terminal->getPathSettings();
4155
4156 for (size_t i = 0; i <= PLOTPATH-2; i++)
4157 {
4158 if (itemId == m_projectFileFolders[i])
4159 {
4160 pathName = vPaths[i+2];
4161 break;
4162 }
4163 }
4164 }
4165 else
4166 pathName = data->filename;
4167
4168 return pathName;
4169}
4170
4180wxString NumeReWindow::getTreeFolderPath(const wxTreeItemId& itemId)
4181{
4182 if (!itemId.IsOk())
4183 return wxString();
4184
4185 FileNameTreeData* data = static_cast<FileNameTreeData*>(m_fileTree->GetItemData(itemId));
4186 wxString pathName;
4187
4188 if (!data)
4189 {
4190 std::vector<std::string> vPaths = m_terminal->getPathSettings();
4191
4192 for (size_t i = 0; i <= PLOTPATH-2; i++)
4193 {
4194 if (itemId == m_projectFileFolders[i])
4195 {
4196 pathName = vPaths[i+2];
4197 break;
4198 }
4199 }
4200 }
4201 else if (data->isDir)
4202 pathName = data->filename;
4203
4204 return pathName;
4205}
4206
4207
4216{
4217 if (m_statusBar)
4218 m_statusBar->Ready();
4219
4220 if (m_debugViewer)
4221 {
4223
4224 for (size_t i = 0; i < m_book->GetPageCount(); i++)
4225 {
4226 NumeReEditor* edit = m_book->getEditor(i);
4227 edit->MarkerDeleteAll(MARKER_FOCUSEDLINE);
4228 }
4229 }
4230
4231 wxToolBar* tb = GetToolBar();
4232 tb->EnableTool(ID_MENU_EXECUTE, true);
4233 tb->EnableTool(ID_MENU_STOP_EXECUTION, false);
4234
4236}
4237
4238
4247{
4248 if (m_statusBar)
4249 m_statusBar->Busy();
4250
4251 wxToolBar* tb = GetToolBar();
4252 tb->EnableTool(ID_MENU_EXECUTE, false);
4253 tb->EnableTool(ID_MENU_STOP_EXECUTION, true);
4254}
4255
4256
4267{
4268 m_remoteMode = false;
4270 bool doSaveAs = saveas || !edit->HasBeenSaved();
4271
4272 if (doSaveAs)
4273 {
4274 wxString filename;
4275 wxString filterString = ConstructFilterString(edit->getFileType());
4276
4277 // the last item in a filter's list will be the default extension if none is given
4278 // ie, right now, .cpp is the default extension for C++ files
4279 wxString title = _guilang.get("GUI_DLG_SAVEAS");
4280 std::vector<std::string> vPaths = m_terminal->getPathSettings();
4281 int i = 0;
4282
4283 if (edit->getFileType() == FILE_NSCR)
4284 i = SCRIPTPATH;
4285 else if (edit->getFileType() == FILE_NPRC)
4286 i = PROCPATH;
4287 else if (edit->getFileType() == FILE_DATAFILES
4288 || edit->getFileType() == FILE_TEXSOURCE
4289 || edit->getFileType() == FILE_NONSOURCE)
4290 i = SAVEPATH;
4291
4292 // Create the file dialog
4293 wxFileDialog dlg (this, title, vPaths[i], edit->GetFileName().GetName(), filterString,
4294 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR);
4295
4296 // Select the correct filter string depending on the
4297 // file extensions
4298 wxString sExt = edit->GetFileName().GetExt();
4299
4300 if (edit->getFileType() == FILE_NSCR && sExt == "nlyt")
4301 dlg.SetFilterIndex(1);
4302 else if (edit->getFileType() == FILE_DATAFILES)
4303 {
4304 if (sExt == "dat")
4305 dlg.SetFilterIndex(0);
4306 else if (sExt == "txt")
4307 dlg.SetFilterIndex(1);
4308 else if (sExt == "csv")
4309 dlg.SetFilterIndex(2);
4310 else if (sExt == "jdx"
4311 || sExt == "dx"
4312 || sExt == "jcm")
4313 dlg.SetFilterIndex(3);
4314 }
4315 else if (edit->getFileType() == FILE_NONSOURCE)
4316 {
4317 if (sExt == "txt")
4318 dlg.SetFilterIndex(0);
4319 else if (sExt == "log")
4320 dlg.SetFilterIndex(1);
4321 }
4322
4323 // ie, user clicked cancel
4324 if (dlg.ShowModal() != wxID_OK)
4325 return false;
4326
4327 if (edit->GetFileName().IsOk())
4328 m_watcher->Remove(edit->GetFileName());
4329
4330 filename = dlg.GetPath();
4331 m_watcher->Add(wxFileName(filename));
4332
4333 // Append the correct file extension
4334 if (filename.find('.') == std::string::npos || filename.find('.', filename.rfind('\\')) == std::string::npos)
4335 {
4336 if (edit->getFileType() == FILE_NSCR)
4337 filename += ".nscr";
4338 else if (edit->getFileType() == FILE_NPRC)
4339 filename += ".nprc";
4340 else if (edit->getFileType() == FILE_DATAFILES)
4341 {
4342 if (edit->GetFilenameString().find('.') != std::string::npos)
4343 filename += edit->GetFilenameString().substr(edit->GetFilenameString().rfind('.'));
4344 else
4345 filename += ".dat";
4346 }
4347 else if (edit->getFileType() == FILE_TEXSOURCE)
4348 filename += ".tex";
4349 else if (edit->getFileType() == FILE_NONSOURCE)
4350 {
4351 if (edit->GetFilenameString().find('.') != std::string::npos)
4352 filename += edit->GetFilenameString().substr(edit->GetFilenameString().rfind('.'));
4353 else
4354 filename += ".txt";
4355 }
4356 }
4357
4358 wxFileName fn(filename);
4359 edit->SetFilename(fn, false);
4360
4361 if (m_book->getCurrentEditor(true))
4362 m_book->getCurrentEditor(true)->SetFilename(fn, false);
4363 }
4364
4365 if (SaveTab(m_book->GetSelection()))
4366 UpdateWindowTitle(m_book->GetPageText(m_book->GetSelection()));
4367
4368 return true;
4369}
4370
4371
4381{
4382 NumeReEditor* edit = m_book->getEditor(tab); // Might need adaption for the filename
4383 wxString filename = edit->GetFileNameAndPath();
4384
4385 // Make the folder, if it doesn't exist
4386 std::string sPath = filename.ToStdString();
4387 sPath = replacePathSeparator(sPath);
4388 sPath.erase(sPath.rfind('/'));
4389 FileSystem _fSys;
4390 _fSys.setPath(sPath, true, getProgramFolder().ToStdString());
4391
4392 m_filesLastSaveTime[filename] = time(0);
4393
4394 if (!edit->SaveFile(filename))
4395 {
4396 wxMessageBox(_guilang.get("GUI_DLG_SAVE_ERROR"), _guilang.get("GUI_DLG_SAVE"), wxCENTRE | wxOK | wxICON_ERROR, this);
4397 return false;
4398 }
4399
4400 edit->SetSavePoint();
4402
4403 m_book->SetTabText(tab, filename);
4404 m_book->Refresh();
4405
4406 return true;
4407}
4408
4409
4418bool NumeReWindow::SaveAll(bool refreshLibrary)
4419{
4420 int currentTab = m_book->GetSelection();
4421
4422 for (size_t i = 0; i < m_book->GetPageCount(); i++)
4423 {
4424 NumeReEditor* edit = m_book->getEditor(i);
4425
4426 if (edit->Modified())
4427 {
4428 if (edit->HasBeenSaved())
4429 {
4430 if (SaveTab(i) && (int)i == currentTab)
4431 UpdateWindowTitle(m_book->GetPageText(i));
4432
4433 continue;
4434 }
4435
4436 // Change with event
4437 m_book->SetSelection(i);
4438 SaveCurrentFile(false);
4439 }
4440 }
4441
4442 // Change with event
4443 if (currentTab != m_book->GetSelection())
4444 m_book->SetSelection(currentTab);
4445
4446 if (refreshLibrary)
4447 {
4448 std::vector<std::string> vPaths = m_terminal->getPathSettings();
4449 // Refresh lib
4452 }
4453
4454 return true;
4455}
4456
4457
4468std::vector<std::string> NumeReWindow::getFileForInstaller(const std::string& sFileName)
4469{
4470 std::ifstream file(sFileName.c_str());
4471 std::string sTargetFileName = sFileName;
4472
4473 std::vector<std::string> vPaths = m_terminal->getPathSettings();
4474 std::vector<std::string> vContents;
4475
4476 for (size_t i = LOADPATH; i < PATH_LAST; i++)
4477 {
4478 if (sTargetFileName.substr(0, vPaths[i].length()) == vPaths[i])
4479 {
4480 switch (i)
4481 {
4482 case LOADPATH:
4483 sTargetFileName = "<loadpath>" + sTargetFileName.substr(vPaths[i].length());
4484 break;
4485 case SAVEPATH:
4486 sTargetFileName = "<savepath>" + sTargetFileName.substr(vPaths[i].length());
4487 break;
4488 case SCRIPTPATH:
4489 sTargetFileName = "<scriptpath>" + sTargetFileName.substr(vPaths[i].length());
4490 break;
4491 case PROCPATH:
4492 sTargetFileName = "<procpath>" + sTargetFileName.substr(vPaths[i].length());
4493 break;
4494 case PLOTPATH:
4495 sTargetFileName = "<plotpath>" + sTargetFileName.substr(vPaths[i].length());
4496 break;
4497 }
4498
4499 break;
4500 }
4501 }
4502
4503 if (!file.good())
4504 return vContents;
4505
4506 vContents.push_back("<file name=\"" + sTargetFileName + "\">");
4507
4508 std::string currLine;
4509
4510 while (!file.eof())
4511 {
4512 std::getline(file, currLine);
4513 vContents.push_back(currLine);
4514 }
4515
4516 vContents.push_back("<endfile>");
4517
4518 return vContents;
4519}
4520
4521
4533{
4534 wxString filterString;
4535 switch(filterType)
4536 {
4538 filterString = m_filterExecutableFiles;
4539 filterString += "|";
4540 filterString += m_filterNSCRFiles;
4541 filterString += "|";
4542 filterString += m_filterNPRCFiles;
4543 filterString += "|";
4544 filterString += m_filterNLYTFiles;
4545 break;
4546 case FILE_NSCR:
4547 filterString = m_filterNSCRFiles;
4548 filterString += "|" + m_filterNLYTFiles;
4549 break;
4550 case FILE_NPRC:
4551 filterString = m_filterNPRCFiles;
4552 break;
4553 case FILE_NUMERE:
4554 filterString = m_filterNumeReFiles;
4555 break;
4556 case FILE_IMAGEFILES:
4557 filterString = m_filterImageFiles;
4558 break;
4559 case FILE_DATAFILES:
4560 filterString = m_filterDataFiles;
4561 break;
4562 case FILE_TEXSOURCE:
4563 filterString = m_filterTeXSource;
4564 break;
4565 case FILE_NONSOURCE:
4566 filterString = m_filterNonsource;
4567 break;
4570 break;
4571 case FILE_ALLFILES:
4572 default:
4573 break;
4574 }
4575 if (filterString.length())
4576 filterString += "|";
4577 filterString += m_filterAllFiles;
4578 return filterString;
4579}
4580
4581
4582// my "I need to try something out, I'll stick it in here" function
4583void NumeReWindow::Test(wxCommandEvent& WXUNUSED(event))
4584{
4585}
4586
4587
4598void NumeReWindow::OnIdle(wxIdleEvent &event)
4599{
4600 if (m_updateTimer && !m_updateTimer->IsRunning ())
4601 {
4602 m_updateTimer->Start (250, wxTIMER_ONE_SHOT);
4603
4604 }
4605 event.Skip();
4606}
4607
4608
4619void NumeReWindow::OnStatusTimer(wxTimerEvent &WXUNUSED(event))
4620{
4621 if (m_updateTimer)
4622 {
4623 m_updateTimer->Stop();
4627 }
4628}
4629
4630
4641void NumeReWindow::OnFileEventTimer(wxTimerEvent& event)
4642{
4643 // store current selection
4644 int selection = m_book->GetSelection();
4645 NumeReEditor* focusedEd = m_book->getFocusedEditor();
4646
4647 // Copy data and clear the cache
4648 std::vector<std::pair<int,wxString> > modifiedFiles = m_modifiedFiles;
4649 m_modifiedFiles.clear();
4650
4651 // Create the relevant objects
4653 VersionControlSystemManager manager(this);
4654 bool refreshProcedureLibrary = false;
4655 std::vector<std::string> vPaths = m_terminal->getPathSettings();
4656 std::array<bool, PATH_LAST-LOADPATH> pathsToRefresh;
4657
4658 // Fill the refresh indicator with false values
4659 pathsToRefresh.fill(false);
4660
4661 g_logger.info("File event handler: catched " + toString(modifiedFiles.size()) + " file events.");
4662
4663 // Go through all cached events
4664 for (size_t i = 0; i < modifiedFiles.size(); i++)
4665 {
4666 wxFileName filename(modifiedFiles[i].second);
4667
4668 if (modifiedFiles[i].first == wxFSW_EVENT_DELETE
4669 || modifiedFiles[i].first == wxFSW_EVENT_CREATE
4670 || modifiedFiles[i].first == wxFSW_EVENT_RENAME)
4671 {
4672 // These event types require refreshing of
4673 // the created file trees and the procedure
4674 // library, if necessary
4675 std::string sEventpath = replacePathSeparator(modifiedFiles[i].second.ToStdString());
4676
4677 for (size_t j = LOADPATH; j < vPaths.size(); j++)
4678 {
4679 if (sEventpath.find(replacePathSeparator(vPaths[j])) != std::string::npos)
4680 {
4681 pathsToRefresh[j-LOADPATH] = true;
4682 break;
4683 }
4684 }
4685
4686 // Mark the procedure library as to be
4687 // refreshed
4688 if (sEventpath.substr(sEventpath.length()-5) == ".nprc"
4689 || sEventpath.substr(sEventpath.length()-5) == ".nscr")
4690 refreshProcedureLibrary = true;
4691
4692 }
4693 else if (modifiedFiles[i].first == wxFSW_EVENT_MODIFY)
4694 {
4695 // Ignore modified directories
4696 if (!filename.GetExt().length() && wxFileName::DirExists(modifiedFiles[i].second))
4697 continue;
4698
4699 // This event type indicate, that files might have
4700 // to be reloaded and that the procedure library
4701 // should be refreshed as well.
4702 //
4703 // Mark the procedure library as to be
4704 // refreshed
4705 if (modifiedFiles[i].second.substr(modifiedFiles[i].second.length()-5) == ".nprc"
4706 || modifiedFiles[i].second.substr(modifiedFiles[i].second.length()-5) == ".nscr")
4707 refreshProcedureLibrary = true;
4708
4709 // Ignore files, which have been saved by NumeRe
4710 // currently and therefore are result of a modify
4711 // event
4712 auto iter = m_filesLastSaveTime.find(modifiedFiles[i].second);
4713
4714 if (iter != m_filesLastSaveTime.end()
4715 && (iter->second == 0 || time(0) - iter->second < 5))
4716 {
4717 g_logger.info("Ignored '" + modifiedFiles[i].second.ToStdString()
4718 + "' due to last modification time difference: " + toString((int)(time(0) - iter->second)));
4719 continue;
4720 }
4721 else if (iter != m_filesLastSaveTime.end())
4722 g_logger.info("Reloading '" + modifiedFiles[i].second.ToStdString()
4723 + "' due to last modification time difference: " + toString((int)(time(0) - iter->second)));
4724
4725 // Ignore also files, whose modification time differs
4726 // more than two seconds from the current time. Older
4727 // modifications are likely to be metadata updates
4728 // done by the OS and do not require any refresh
4729 //
4730 // GetModificationTime() fails if the file is not readable
4731 // therefore we check this first
4732 {
4733 wxLogNull logNull;
4734
4735 if (filename.IsDir()
4736 || !filename.IsFileReadable()
4737 || !filename.GetModificationTime().IsValid()
4738 || (wxDateTime::Now() - filename.GetModificationTime()).GetSeconds() > 2)
4739 continue;
4740 }
4741
4742 // Add a new revision in the list of revisions that
4743 // the file was modified from the outside. Files with
4744 // a revision list, will therefore never lose their
4745 // changes, even if the user disagrees with the reloading
4746 if (manager.hasRevisions(modifiedFiles[i].second) && m_options->GetKeepBackupFile())
4747 {
4748 std::unique_ptr<FileRevisions> revisions(manager.getRevisions(modifiedFiles[i].second));
4749 g_logger.info("Adding external revision to '" + modifiedFiles[i].second.ToStdString() + "'.");
4750
4751 if (revisions.get())
4752 revisions->addExternalRevision(modifiedFiles[i].second);
4753 }
4754
4755 // Ignore files on the current blacklist
4756 if (isOnReloadBlackList(modifiedFiles[i].second))
4757 continue;
4758
4759 reloadFileIfOpen(modifiedFiles[i].second, false);
4760 }
4761 }
4762
4763 // Now refresh all folders, which have been marked
4764 // as to be refreshed
4765 for (size_t i = 0; i < pathsToRefresh.size(); i++)
4766 {
4767 if (pathsToRefresh[i])
4768 {
4769 m_fileTree->DeleteChildren(m_projectFileFolders[i]);
4770 LoadFilesToTree(vPaths[i+LOADPATH], fileType[i], m_projectFileFolders[i]);
4771 }
4772 }
4773
4774 g_logger.debug("All necessary file trees have been refreshed.");
4775
4776 // Now refresh the procedure library
4777 if (refreshProcedureLibrary)
4778 {
4779 g_logger.info("Refreshing procedure library.");
4782 }
4783
4784 // go back to previous selection
4785 if (m_book->GetSelection() != selection)
4786 {
4787 m_book->SetSelection(selection);
4788
4789 if (focusedEd)
4790 focusedEd->SetFocus();
4791 }
4792}
4793
4794
4804{
4805 wxToolBar* tb = GetToolBar();
4806
4807 if (!tb->GetToolEnabled(ID_MENU_STOP_EXECUTION))
4808 {
4809 tb->EnableTool(ID_MENU_EXECUTE, true);
4810 tb->EnableTool(ID_MENU_STOP_EXECUTION, false);
4811 }
4812
4813 if (!m_book->getCurrentEditor())
4814 return;
4815
4820 {
4821 tb->EnableTool(ID_MENU_ADDEDITORBREAKPOINT, true);
4822 tb->EnableTool(ID_MENU_REMOVEEDITORBREAKPOINT, true);
4823 tb->EnableTool(ID_MENU_CLEAREDITORBREAKPOINTS, true);
4824 tb->EnableTool(ID_MENU_USEANALYZER, true);
4826 tb->EnableTool(ID_MENU_INDENTONTYPE, true);
4828 }
4829 else
4830 {
4831 tb->EnableTool(ID_MENU_ADDEDITORBREAKPOINT, false);
4832 tb->EnableTool(ID_MENU_REMOVEEDITORBREAKPOINT, false);
4833 tb->EnableTool(ID_MENU_CLEAREDITORBREAKPOINTS, false);
4834 tb->EnableTool(ID_MENU_USEANALYZER, false);
4835 tb->ToggleTool(ID_MENU_USEANALYZER, false);
4836 tb->EnableTool(ID_MENU_INDENTONTYPE, false);
4837 tb->ToggleTool(ID_MENU_INDENTONTYPE, false);
4838 }
4839
4840 if (m_book->getCurrentEditor()->GetFileName().GetExt() == "m")
4841 {
4842 tb->EnableTool(ID_MENU_INDENTONTYPE, true);
4844 }
4845
4847}
4848
4849
4859{
4860 if (m_statusBar == NULL)
4861 return;
4862
4863 int pageCount = m_book->GetPageCount();
4864
4865 if (pageCount < 1)
4866 return;
4867
4868 wxString tabText = m_book->GetPageText(m_book->GetSelection());
4869 wxString filename;
4870 wxString filetype;
4871 std::string sExt = "";
4872
4874 NumeReEditor* focusEd = m_book->getFocusedEditor();
4875
4876 filename = currEd->GetFileNameAndPath();
4877
4878 if (currEd->defaultPage)
4879 filename = _guilang.get("GUI_STATUSBAR_WELCOMEPAGE");
4880
4881 if (filename.find('.') != std::string::npos)
4882 sExt = filename.substr(filename.rfind('.')+1).ToStdString();
4883
4884
4885 if (tabText.StartsWith("<"))
4886 {
4887 filename = _guilang.get("GUI_STATUSBAR_UNSAVEDFILE");
4888 filetype = "N/A";
4889 }
4890 else if (currEd->defaultPage)
4891 filetype = _guilang.get("GUI_STATUSBAR_WELCOMEPAGE_FILETYPE");
4892 else if (sExt.length() && _guilang.get("GUI_STATUSBAR_"+toUpperCase(sExt)) != "GUI_STATUSBAR_"+toUpperCase(sExt))
4893 {
4894 filetype = _guilang.get("GUI_STATUSBAR_"+toUpperCase(sExt));
4895 }
4896 else
4897 {
4898 filetype = _guilang.get("GUI_STATUSBAR_UNKNOWN", sExt);
4899 }
4900
4901 bool isEdReadOnly = currEd->GetReadOnly();
4902
4903 wxString editable = isEdReadOnly ? "Read only" : "Read/Write";
4904
4905 int curLine = focusEd->GetCurrentLine();
4906 int curPos = focusEd->GetColumn(focusEd->GetCurrentPos());
4907 wxString linecol;
4908 linecol.Printf(_(_guilang.get("GUI_STATUSBAR_LINECOL")), curLine+1, curPos+1);
4909
4910 wxString sDebuggerMode = "";
4912 sDebuggerMode = _guilang.get("GUI_STATUSBAR_DEBUGGER_ANALYZER");
4914 sDebuggerMode = _guilang.get("GUI_STATUSBAR_DEBUGGER");
4916 sDebuggerMode = _guilang.get("GUI_STATUSBAR_ANALYZER");
4917
4923}
4924
4925
4934void NumeReWindow::OnUpdateSaveUI()//wxUpdateUIEvent &event)
4935{
4936 bool enable = m_book->getCurrentEditor()->Modified();
4937 int tabNum = m_book->GetSelection();
4938 wxString title = m_book->GetPageText(tabNum);
4939
4940 if (enable)
4941 {
4942 if (title.find("*") == std::string::npos)
4943 {
4944 title += "*";
4945 m_book->SetPageText(tabNum, title);
4946 m_book->Refresh();
4947 UpdateWindowTitle(title);
4948 }
4949 }
4950 else
4951 {
4952 if (title.find("*") != std::string::npos)
4953 {
4954 title.RemoveLast(1);
4955 m_book->SetPageText(tabNum, title);
4956 m_book->Refresh();
4957 UpdateWindowTitle(title);
4958 }
4959 }
4960
4961 GetToolBar()->EnableTool(ID_MENU_SAVE, enable);
4962
4963 wxMenuBar* mb = GetMenuBar();
4964 WXWidget handle = mb->GetHandle();
4965
4966 if (handle != NULL)
4967 {
4968 mb->FindItem(ID_MENU_SAVE)->Enable(enable);
4969 }
4970}
4971
4972
4984void NumeReWindow::SetIntVar(int variableName, int value)
4985{
4986 // figure out which integer I'm setting
4987 int* target = SelectIntVar(variableName);
4988
4989 // assuming we assigned it properly, Set it
4990 if(target != NULL)
4991 {
4992 *target = value;
4993 }
4994}
4995
4996
5007int NumeReWindow::GetIntVar(int variableName)
5008{
5009 int* target = SelectIntVar(variableName);
5010
5011 if(target != NULL)
5012 {
5013 return *target;
5014 }
5015 else
5016 {
5017 return 0;
5018 }
5019}
5020
5021
5032int* NumeReWindow::SelectIntVar(int variableName)
5033{
5034 switch(variableName)
5035 {
5036 case VN_NUMPAGES:
5037 return &m_numPages;
5038 break;
5039 case VN_CURRENTPAGE:
5040 return &m_currentPage;
5041 break;
5042 case VN_CLICKEDTAB:
5043 return &m_clickedTabNum;
5044 break;
5045 default:
5046#ifdef DO_LOG
5047 wxLogDebug("Failed to properly set variable. variableName = %d", variableName);
5048#endif
5049 return NULL;
5050 }
5051}
5052
5053
5064void NumeReWindow::PassImageList(wxImageList* imagelist)
5065{
5066 m_fileTree->AssignImageList(imagelist);
5067}
5068
5069
5081{
5082 // Update the GUI elements by re-constructing them
5083 UpdateToolbar();
5084
5085 // Prepare the contents of the navigators
5086 if (m_fileTree)
5087 {
5088 // If the left sidebar is not shown, display it here.
5089 // Otherwise simply clear the contents of the file
5090 // navigator tree
5091 if (!m_treeBook->IsShown())
5092 {
5094 m_splitProjectEditor->SetMinimumPaneSize(30);
5095 m_treeBook->Show();
5096 }
5097 else
5098 {
5099 for (size_t i = 0; i < 5; i++)
5100 {
5101 m_fileTree->DeleteChildren(m_projectFileFolders[i]);
5102 }
5103 }
5104
5105 // Expand the root node
5106 if (!m_fileTree->IsExpanded(m_fileTree->GetRootItem()))
5107 m_fileTree->Toggle(m_fileTree->GetRootItem());
5108
5109 // Fill the contents to the tree
5110 std::vector<std::string> vPaths = m_terminal->getPathSettings();
5116
5117 // Construct the internal procedure tree
5118 // for the autocompletion feature
5120
5121 // Activate the file system watcher
5122 if (m_watcher)
5123 m_watcher->SetDefaultPaths(vPaths);
5124 }
5125
5126 // Update the syntax highlighting in every
5127 // editor instance
5128 for (int i = 0; i < (int)m_book->GetPageCount(); i++)
5129 {
5130 NumeReEditor* edit = m_book->getEditor(i); // Needs adaption
5132 edit->SetCaretPeriod(m_options->GetCaretBlinkTime());
5133 edit->AnalyseCode();
5134 edit->SetUseTabs(m_options->isEnabled(SETTING_B_USETABS));
5135 }
5136
5137 if (m_debugViewer)
5139
5142
5143 if (m_book->GetSelection() != wxNOT_FOUND)
5144 UpdateWindowTitle(m_book->GetPageText(m_book->GetSelection()));
5145
5146 // Copy the settings in the options object
5147 // into the configuration object
5150}
5151
5152
5162{
5163 wxMenuBar* menuBar = GetMenuBar();
5164
5165 if (!m_appStarting)
5166 return;
5167
5168 if(menuBar != NULL)
5169 {
5170 SetMenuBar(NULL);
5171 delete menuBar;
5172 }
5173
5174 menuBar = new wxMenuBar();
5175 SetMenuBar(menuBar);
5176
5177 // Create new file menu
5178 wxMenu* menuNewFile = new wxMenu();
5179
5180 menuNewFile->Append(ID_MENU_NEW_EMPTY, _guilang.get("GUI_MENU_NEW_EMPTYFILE"), _guilang.get("GUI_MENU_NEW_EMPTYFILE_TTP"));
5181 menuNewFile->AppendSeparator();
5182 menuNewFile->Append(ID_MENU_NEW_SCRIPT, _guilang.get("GUI_MENU_NEW_NSCR"), _guilang.get("GUI_MENU_NEW_NSCR_TTP"));
5183 menuNewFile->Append(ID_MENU_NEW_PROCEDURE, _guilang.get("GUI_MENU_NEW_NPRC"), _guilang.get("GUI_MENU_NEW_NPRC_TTP"));
5184 menuNewFile->Append(ID_MENU_NEW_PLUGIN, _guilang.get("GUI_MENU_NEW_PLUGIN"), _guilang.get("GUI_MENU_NEW_PLUGIN_TTP"));
5185 menuNewFile->Append(ID_MENU_NEW_LAYOUT, _guilang.get("GUI_MENU_NEW_LAYOUT"), _guilang.get("GUI_MENU_NEW_LAYOUT_TTP"));
5186
5187 // Create file menu
5188 wxMenu* menuFile = new wxMenu();
5189
5190 menuFile->Append(wxID_ANY, _guilang.get("GUI_MENU_NEWFILE"), menuNewFile, _guilang.get("GUI_MENU_NEWFILE_TTP"));
5191
5192 menuFile->Append(ID_MENU_OPEN_SOURCE_LOCAL, _guilang.get("GUI_MENU_OPENFILE"), _guilang.get("GUI_MENU_OPENFILE_TTP"));
5193 menuFile->Append(ID_MENU_CLOSEPAGE, _guilang.get("GUI_MENU_CLOSEFILE"), _guilang.get("GUI_MENU_CLOSEFILE_TTP"));
5194 menuFile->Append(ID_MENU_CLOSEALL, _guilang.get("GUI_MENU_CLOSEALLFILES"));
5195 menuFile->AppendSeparator();
5196 menuFile->Append(ID_MENU_SAVE, _guilang.get("GUI_MENU_SAVEFILE"), _guilang.get("GUI_MENU_SAVEFILE_TTP"));
5197 menuFile->Append(ID_MENU_SAVE_SOURCE_LOCAL, _guilang.get("GUI_MENU_SAVEFILEAS"), _guilang.get("GUI_MENU_SAVEFILEAS_TTP"));
5198 menuFile->AppendSeparator();
5199 menuFile->Append(ID_MENU_PRINT_PAGE, _guilang.get("GUI_MENU_PRINT"), _guilang.get("GUI_MENU_PRINT_TTP"));
5200 menuFile->Append(ID_MENU_PRINT_PREVIEW, _guilang.get("GUI_MENU_PRINTPREVIEW"));
5201 menuFile->Append(ID_MENU_PRINT_SETUP, _guilang.get("GUI_MENU_PRINTSETUP"));
5202 menuFile->Append(ID_MENU_QUIT,_guilang.get("GUI_MENU_EXIT"), _guilang.get("GUI_MENU_EXIT_TTP"));
5203
5204 menuBar->Append(menuFile, _guilang.get("GUI_MENU_FILE"));
5205
5206 // Create strip spaces menu
5207 wxMenu* menuStripSpaces = new wxMenu();
5208 menuStripSpaces->Append(ID_MENU_STRIP_SPACES_BOTH, _guilang.get("GUI_MENU_STRIP_BOTH"), _guilang.get("GUI_MENU_STRIP_BOTH_TTP"));
5209 menuStripSpaces->Append(ID_MENU_STRIP_SPACES_FRONT, _guilang.get("GUI_MENU_STRIP_FRONT"), _guilang.get("GUI_MENU_STRIP_FRONT_TTP"));
5210 menuStripSpaces->Append(ID_MENU_STRIP_SPACES_BACK, _guilang.get("GUI_MENU_STRIP_BACK"), _guilang.get("GUI_MENU_STRIP_BACK_TTP"));
5211
5212 // Create edit menu
5213 wxMenu* menuEdit = new wxMenu();
5214
5215 menuEdit->Append(ID_MENU_UNDO, _guilang.get("GUI_MENU_UNDO"));
5216 menuEdit->Append(ID_MENU_REDO, _guilang.get("GUI_MENU_REDO"));
5217 menuEdit->AppendSeparator();
5218 menuEdit->Append(ID_MENU_CUT, _guilang.get("GUI_MENU_CUT"));
5219 menuEdit->Append(ID_MENU_COPY, _guilang.get("GUI_MENU_COPY"));
5220 menuEdit->Append(ID_MENU_PASTE, _guilang.get("GUI_MENU_PASTE"));
5221 menuEdit->AppendSeparator();
5222 menuEdit->Append(ID_MENU_SELECTION_UP, _guilang.get("GUI_MENU_SELECT_UP"), _guilang.get("GUI_MENU_SELECT_UP_TTP"));
5223 menuEdit->Append(ID_MENU_SELECTION_DOWN, _guilang.get("GUI_MENU_SELECT_DOWN"), _guilang.get("GUI_MENU_SELECT_DOWN_TTP"));
5224 menuEdit->AppendSeparator();
5225 menuEdit->Append(ID_MENU_TRANSPOSESELECTION, _guilang.get("GUI_MENU_TRANSPOSESELECTION"), _guilang.get("GUI_MENU_TRANSPOSESELECTION_TTP"));
5226 menuEdit->Append(wxID_ANY, _guilang.get("GUI_MENU_STRIP"), menuStripSpaces);
5227 menuEdit->Append(ID_MENU_SORT_SELECTION_ASC, _guilang.get("GUI_MENU_SORT_ASC"), _guilang.get("GUI_MENU_SORT_ASC_TTP"));
5228 menuEdit->Append(ID_MENU_SORT_SELECTION_DESC, _guilang.get("GUI_MENU_SORT_DESC"), _guilang.get("GUI_MENU_SORT_DESC_TTP"));
5229
5230 menuBar->Append(menuEdit, _guilang.get("GUI_MENU_EDIT"));
5231
5232 // Create search menu
5233 wxMenu* menuSearch = new wxMenu();
5234
5235 menuSearch->Append(ID_MENU_FIND, _guilang.get("GUI_MENU_FIND"));
5236 menuSearch->Append(ID_MENU_REPLACE, _guilang.get("GUI_MENU_REPLACE"));
5237 menuSearch->AppendSeparator();
5238 menuSearch->Append(ID_MENU_FIND_PROCEDURE, _guilang.get("GUI_MENU_FIND_PROCEDURE"), _guilang.get("GUI_MENU_FIND_PROCEDURE_TTP"));
5239 menuSearch->Append(ID_MENU_FIND_INCLUDE, _guilang.get("GUI_MENU_FIND_INCLUDE"), _guilang.get("GUI_MENU_FIND_INCLUDE_TTP"));
5240 menuSearch->Append(ID_MENU_GOTOLINE, _guilang.get("GUI_MENU_GOTOLINE"), _guilang.get("GUI_MENU_GOTOLINE_TTP"));
5241 menuSearch->AppendSeparator();
5242 menuSearch->Append(ID_MENU_BOOKMARK_TOGGLE, _guilang.get("GUI_MENU_BOOKMARK_TOGGLE"));
5243 menuSearch->Append(ID_MENU_BOOKMARK_CLEARMENU, _guilang.get("GUI_MENU_BOOKMARK_CLEAR"));
5244 menuSearch->Append(ID_MENU_BOOKMARK_PREVIOUS, _guilang.get("GUI_MENU_BOOKMARK_PREVIOUS"));
5245 menuSearch->Append(ID_MENU_BOOKMARK_NEXT, _guilang.get("GUI_MENU_BOOKMARK_NEXT"));
5246
5247 menuBar->Append(menuSearch, _guilang.get("GUI_MENU_SEARCH"));
5248
5249 // Create view menu
5250 wxMenu* menuView = new wxMenu();
5251
5252 menuView->Append(ID_MENU_TOGGLE_CONSOLE, _guilang.get("GUI_MENU_TOGGLE_CONSOLE"));
5253 menuView->Append(ID_MENU_TOGGLE_FILETREE, _guilang.get("GUI_MENU_TOGGLE_FILETREE"));
5254 menuView->Append(ID_MENU_TOGGLE_HISTORY, _guilang.get("GUI_MENU_TOGGLE_HISTORY"));
5255 menuView->AppendSeparator();
5256 menuView->Append(ID_MENU_FOLD_ALL, _guilang.get("GUI_MENU_FOLDALL"), _guilang.get("GUI_MENU_FOLDALL_TTP"));
5257 menuView->Append(ID_MENU_UNFOLD_ALL, _guilang.get("GUI_MENU_UNFOLDALL"), _guilang.get("GUI_MENU_UNFOLDALL_TTP"));
5258 menuView->Append(ID_MENU_UNHIDE_ALL, _guilang.get("GUI_MENU_UNHIDEALL"), _guilang.get("GUI_MENU_UNHIDEALL_TTP"));
5259 menuView->AppendSeparator();
5260 m_menuItems[ID_MENU_LINEWRAP] = menuView->Append(ID_MENU_LINEWRAP, _guilang.get("GUI_MENU_LINEWRAP"), _guilang.get("GUI_MENU_LINEWRAP_TTP"), wxITEM_CHECK);
5261 m_menuItems[ID_MENU_DISPCTRLCHARS] = menuView->Append(ID_MENU_DISPCTRLCHARS, _guilang.get("GUI_MENU_DISPCTRLCHARS"), _guilang.get("GUI_MENU_DISPCTRLCHARS_TTP"), wxITEM_CHECK);
5262 m_menuItems[ID_MENU_USETXTADV] = menuView->Append(ID_MENU_USETXTADV, _guilang.get("GUI_MENU_USETXTADV"), _guilang.get("GUI_MENU_USETXTADV_TTP"), wxITEM_CHECK);
5263 //m_menuItems[ID_MENU_TOGGLE_NOTEBOOK_MULTIROW] = menuView->Append(ID_MENU_TOGGLE_NOTEBOOK_MULTIROW, _guilang.get("GUI_MENU_MULTIROW"), _guilang.get("GUI_MENU_MULTIROW_TTP"), wxITEM_CHECK);
5264 m_menuItems[ID_MENU_USESECTIONS] = menuView->Append(ID_MENU_USESECTIONS, _guilang.get("GUI_MENU_USESECTIONS"), _guilang.get("GUI_MENU_USESECTIONS_TTP"), wxITEM_CHECK);
5265
5266 menuBar->Append(menuView, _guilang.get("GUI_MENU_VIEW"));
5267
5268 // Create format menu
5269 wxMenu* menuFormat = new wxMenu();
5270 menuFormat->Append(ID_MENU_AUTOINDENT, _guilang.get("GUI_MENU_AUTOINDENT"), _guilang.get("GUI_MENU_AUTOINDENT_TTP"));
5271 m_menuItems[ID_MENU_INDENTONTYPE] = menuFormat->Append(ID_MENU_INDENTONTYPE, _guilang.get("GUI_MENU_INDENTONTYPE"), _guilang.get("GUI_MENU_INDENTONTYPE_TTP"), wxITEM_CHECK);
5272 menuFormat->Append(ID_MENU_AUTOFORMAT, _guilang.get("GUI_MENU_AUTOFORMAT"), _guilang.get("GUI_MENU_AUTOFORMAT_TTP"));
5273
5274 // Create LaTeX menu
5275 wxMenu* menuLaTeX = new wxMenu();
5276 menuLaTeX->Append(ID_MENU_CREATE_LATEX_FILE, _guilang.get("GUI_MENU_CREATELATEX"), _guilang.get("GUI_MENU_CREATELATEX_TTP"));
5277 menuLaTeX->Append(ID_MENU_RUN_LATEX, _guilang.get("GUI_MENU_RUNLATEX"), _guilang.get("GUI_MENU_RUNLATEX_TTP"));
5278 menuLaTeX->Append(ID_MENU_COMPILE_LATEX, _guilang.get("GUI_MENU_COMPILE_TEX"), _guilang.get("GUI_MENU_COMPILE_TEX_TTP"));
5279
5280 // Create refactoring menu
5281 wxMenu* menuRefactoring = new wxMenu();
5282 menuRefactoring->Append(ID_MENU_RENAME_SYMBOL, _guilang.get("GUI_MENU_RENAME_SYMBOL"), _guilang.get("GUI_MENU_RENAME_SYMBOL_TTP"));
5283 menuRefactoring->Append(ID_MENU_ABSTRAHIZE_SECTION, _guilang.get("GUI_MENU_ABSTRAHIZE_SECTION"), _guilang.get("GUI_MENU_ABSTRAHIZE_SECTION_TTP"));
5284
5285 // Create analyzer menu
5286 wxMenu* menuAnalyzer = new wxMenu();
5287 m_menuItems[ID_MENU_USEANALYZER] = menuAnalyzer->Append(ID_MENU_USEANALYZER, _guilang.get("GUI_MENU_ANALYZER"), _guilang.get("GUI_MENU_ANALYZER_TTP"), wxITEM_CHECK);
5288 menuAnalyzer->Append(ID_MENU_FIND_DUPLICATES, _guilang.get("GUI_MENU_FIND_DUPLICATES"), _guilang.get("GUI_MENU_FIND_DUPLICATES_TTP"));
5289 menuAnalyzer->Append(ID_MENU_SHOW_DEPENDENCY_REPORT, _guilang.get("GUI_MENU_SHOW_DEPENDENCY_REPORT"), _guilang.get("GUI_MENU_SHOW_DEPENDENCY_REPORT_TTP"));
5290 menuAnalyzer->Append(ID_MENU_COMPARE_FILES, _guilang.get("GUI_MENU_COMPARE_FILES"), _guilang.get("GUI_MENU_COMPARE_FILES_TTP"));
5291
5292 // Create exporter menu
5293 wxMenu* menuExporter = new wxMenu();
5294 menuExporter->Append(ID_MENU_EXPORT_AS_HTML, _guilang.get("GUI_MENU_EXPORT_AS_HTML"), _guilang.get("GUI_MENU_EXPORT_AS_HTML_TTP"));
5295 menuExporter->Append(ID_MENU_EXPORT_FORMATTED, _guilang.get("GUI_MENU_EXPORT_FORMATTED"), _guilang.get("GUI_MENU_EXPORT_FORMATTED_TTP"));
5296
5297 // Create tools menu
5298 wxMenu* menuTools = new wxMenu();
5299
5300 menuTools->Append(ID_MENU_OPTIONS, _guilang.get("GUI_MENU_OPTIONS"));
5301 menuTools->AppendSeparator();
5302 menuTools->Append(ID_MENU_EXECUTE, _guilang.get("GUI_MENU_EXECUTE"), _guilang.get("GUI_MENU_EXECUTE_TTP"));
5303 menuTools->Append(wxID_ANY, _guilang.get("GUI_MENU_FORMAT"), menuFormat);
5304 menuTools->Append(wxID_ANY, _guilang.get("GUI_MENU_REFACTORING"), menuRefactoring);
5305 menuTools->Append(ID_MENU_TOGGLE_COMMENT_LINE, _guilang.get("GUI_MENU_COMMENTLINE"), _guilang.get("GUI_MENU_COMMENTLINE_TTP"));
5306 menuTools->Append(ID_MENU_TOGGLE_COMMENT_SELECTION, _guilang.get("GUI_MENU_COMMENTSELECTION"), _guilang.get("GUI_MENU_COMMENTSELECTION_TTP"));
5307 menuTools->AppendSeparator();
5308
5309 menuTools->Append(ID_MENU_CREATE_DOCUMENTATION, _guilang.get("GUI_MENU_CREATE_DOCUMENTATION"), _guilang.get("GUI_MENU_CREATE_DOCUMENTATION_TTP"));
5310 menuTools->Append(wxID_ANY, _guilang.get("GUI_MENU_LATEX"), menuLaTeX);
5311 menuTools->Append(wxID_ANY, _guilang.get("GUI_MENU_EXPORT"), menuExporter);
5312
5313 menuTools->AppendSeparator();
5314 menuTools->Append(wxID_ANY, _guilang.get("GUI_MENU_ANALYSIS"), menuAnalyzer);
5315 m_menuItems[ID_MENU_TOGGLE_DEBUGGER] = menuTools->Append(ID_MENU_TOGGLE_DEBUGGER, _guilang.get("GUI_MENU_DEBUGGER"), _guilang.get("GUI_MENU_DEBUGGER_TTP"), wxITEM_CHECK);
5316
5317 menuBar->Append(menuTools, _guilang.get("GUI_MENU_TOOLS"));
5318
5319 // Create packages menu
5320 wxMenu* menuPackages = new wxMenu();
5321
5322 menuPackages->Append(ID_MENU_PLUGINBROWSER, _guilang.get("GUI_MENU_SHOW_PACKAGE_BROWSER"), _guilang.get("GUI_MENU_SHOW_PACKAGE_BROWSER_TTP"));
5323 menuPackages->AppendSeparator();
5324 menuPackages->Append(ID_MENU_CREATE_PACKAGE, _guilang.get("GUI_MENU_CREATE_PACKAGE"), _guilang.get("GUI_MENU_CREATE_PACKAGE_TTP"));
5325 menuPackages->Append(ID_MENU_INSTALLPLUGINFROMFILE, _guilang.get("GUI_MENU_INSTALL_PACKAGE_FILE"), _guilang.get("GUI_MENU_INSTALL_PACKAGE_FILE_TTP"));
5326 menuPackages->AppendSeparator();
5327 wxMenuItem* item = menuPackages->Append(EVENTID_PLUGIN_MENU_END, _guilang.get("GUI_MENU_NO_PLUGINS_INSTALLED"));
5328 item->Enable(false);
5329 menuBar->Append(menuPackages, "Packages");
5330
5331 // Create help menu
5332 wxMenu *helpMenu = new wxMenu;
5333 helpMenu->Append(ID_MENU_HELP, _guilang.get("GUI_MENU_SHOWHELP"));
5334 helpMenu->Append(ID_MENU_ABOUT, _guilang.get("GUI_MENU_ABOUT"), _guilang.get("GUI_MENU_ABOUT_TTP"));
5335
5336 menuBar->Append(helpMenu, _guilang.get("GUI_MENU_HELP"));
5337
5339
5340 if (edit)
5341 {
5348 }
5349 else
5350 {
5351 m_menuItems[ID_MENU_LINEWRAP]->Check(false);
5352 m_menuItems[ID_MENU_DISPCTRLCHARS]->Check(false);
5353 m_menuItems[ID_MENU_USETXTADV]->Check(false);
5354 m_menuItems[ID_MENU_USESECTIONS]->Check(false);
5355 m_menuItems[ID_MENU_INDENTONTYPE]->Check(false);
5356 m_menuItems[ID_MENU_USEANALYZER]->Check(false);
5357 }
5358
5359 //m_menuItems[ID_MENU_TOGGLE_NOTEBOOK_MULTIROW]->Check(m_multiRowState);
5361
5362 // Update now the package menu (avoids code duplication)
5364}
5365
5366
5375{
5376 int id = GetMenuBar()->FindMenu("Packages");
5377
5378 if (id == wxNOT_FOUND)
5379 return;
5380
5381 // Get menu
5382 wxMenu* menuPackages = GetMenuBar()->GetMenu(id);
5383
5384 // Remove all entries
5385 if (m_pluginMenuMap.size())
5386 {
5387 for (auto iter : m_pluginMenuMap)
5388 menuPackages->Delete(iter.first);
5389
5390 m_pluginMenuMap.clear();
5391 }
5392 else
5393 menuPackages->Delete(EVENTID_PLUGIN_MENU_END);
5394
5395 // Get new map
5396 std::map<std::string,std::string> mMenuMap = m_terminal->getMenuMap();
5397
5398 // Fill the menu with new entries
5399 if (mMenuMap.size())
5400 {
5401 size_t id = EVENTID_PLUGIN_MENU_START;
5402
5403 for (auto iter = mMenuMap.begin(); iter != mMenuMap.end(); ++iter, id++)
5404 {
5405 menuPackages->Append(id, removeMaskedStrings(iter->first));
5406 m_pluginMenuMap[id] = iter->second;
5407 }
5408 }
5409 else
5410 {
5411 wxMenuItem* item = menuPackages->Append(EVENTID_PLUGIN_MENU_END, _guilang.get("GUI_MENU_NO_PLUGINS_INSTALLED"));
5412 item->Enable(false);
5413 }
5414}
5415
5416
5426{
5427 int style = wxTB_FLAT | wxTB_HORIZONTAL;
5428
5429 bool showText = m_options->GetShowToolbarText();
5430 if (showText)
5431 {
5432 style |= wxTB_TEXT;
5433 }
5434
5435 if (GetToolBar() && GetToolBar()->GetWindowStyle() == style)
5436 return;
5437
5438 wxToolBar* t = GetToolBar();
5439 delete t;
5440 SetToolBar(nullptr);
5441 t = CreateToolBar(style);//new wxToolBar(this, -1, wxDefaultPosition, wxDefaultSize, style);
5442
5443 t->AddTool(ID_MENU_NEW_ASK, _guilang.get("GUI_TB_NEW"), wxArtProvider::GetBitmap(wxART_NEW, wxART_TOOLBAR), _guilang.get("GUI_TB_NEW_TTP"), wxITEM_DROPDOWN);
5444 wxMenu* menuNewFile = new wxMenu();
5445 menuNewFile->Append(ID_MENU_NEW_EMPTY, _guilang.get("GUI_MENU_NEW_EMPTYFILE"), _guilang.get("GUI_MENU_NEW_EMPTYFILE_TTP"));
5446 menuNewFile->AppendSeparator();
5447 menuNewFile->Append(ID_MENU_NEW_SCRIPT, _guilang.get("GUI_MENU_NEW_NSCR"), _guilang.get("GUI_MENU_NEW_NSCR_TTP"));
5448 menuNewFile->Append(ID_MENU_NEW_PROCEDURE, _guilang.get("GUI_MENU_NEW_NPRC"), _guilang.get("GUI_MENU_NEW_NPRC_TTP"));
5449 menuNewFile->Append(ID_MENU_NEW_PLUGIN, _guilang.get("GUI_MENU_NEW_PLUGIN"), _guilang.get("GUI_MENU_NEW_PLUGIN_TTP"));
5450 menuNewFile->Append(ID_MENU_NEW_LAYOUT, _guilang.get("GUI_MENU_NEW_LAYOUT"), _guilang.get("GUI_MENU_NEW_LAYOUT_TTP"));
5451 t->SetDropdownMenu(ID_MENU_NEW_ASK, menuNewFile);
5452
5453 t->AddTool(ID_MENU_OPEN_SOURCE_LOCAL, _guilang.get("GUI_TB_OPEN"), wxArtProvider::GetBitmap(wxART_FILE_OPEN, wxART_TOOLBAR), _guilang.get("GUI_TB_OPEN_TTP"));
5454
5455 t->AddTool(ID_MENU_SAVE, _guilang.get("GUI_TB_SAVE"), wxArtProvider::GetBitmap(wxART_FILE_SAVE, wxART_TOOLBAR), _guilang.get("GUI_TB_SAVE_TTP"));
5456
5457 t->AddSeparator();
5458
5459 t->AddTool(ID_MENU_UNDO, _guilang.get("GUI_TB_UNDO"), wxArtProvider::GetBitmap(wxART_UNDO, wxART_TOOLBAR), _guilang.get("GUI_TB_UNDO"));
5460
5461 t->AddTool(ID_MENU_REDO, _guilang.get("GUI_TB_REDO"), wxArtProvider::GetBitmap(wxART_REDO, wxART_TOOLBAR), _guilang.get("GUI_TB_REDO"));
5462
5463 t->AddSeparator();
5464 t->AddTool(ID_MENU_CUT, _guilang.get("GUI_TB_CUT"), wxArtProvider::GetBitmap(wxART_CUT, wxART_TOOLBAR), _guilang.get("GUI_TB_CUT"));
5465 t->AddTool(ID_MENU_COPY, _guilang.get("GUI_TB_COPY"), wxArtProvider::GetBitmap(wxART_COPY, wxART_TOOLBAR), _guilang.get("GUI_TB_COPY"));
5466 t->AddTool(ID_MENU_PASTE, _guilang.get("GUI_TB_PASTE"), wxArtProvider::GetBitmap(wxART_PASTE, wxART_TOOLBAR), _guilang.get("GUI_TB_PASTE"));
5467
5468 t->AddSeparator();
5469 t->AddTool(ID_MENU_FIND, _guilang.get("GUI_TB_SEARCH"), wxArtProvider::GetBitmap(wxART_FIND, wxART_TOOLBAR), _guilang.get("GUI_TB_SEARCH"));
5470 t->AddTool(ID_MENU_REPLACE, _guilang.get("GUI_TB_REPLACE"), wxArtProvider::GetBitmap(wxART_FIND_AND_REPLACE, wxART_TOOLBAR), _guilang.get("GUI_TB_REPLACE"));
5471
5472 t->AddSeparator();
5473 wxBitmap bmIndent(stepnext_xpm);
5474 t->AddTool(ID_MENU_INDENTONTYPE, _guilang.get("GUI_TB_INDENTONTYPE"), bmIndent, _guilang.get("GUI_TB_INDENTONTYPE_TTP"), wxITEM_CHECK);
5475 t->ToggleTool(ID_MENU_INDENTONTYPE, false);
5476 t->EnableTool(ID_MENU_INDENTONTYPE, false);
5477 wxBitmap bmWrapAround(wraparound_xpm);
5478 t->AddTool(ID_MENU_LINEWRAP, _guilang.get("GUI_TB_LINEWRAP"), bmWrapAround, _guilang.get("GUI_TB_LINEWRAP_TTP"), wxITEM_CHECK);
5479
5480 t->AddSeparator();
5481 wxBitmap bmStart(newstart1_xpm);
5482 t->AddTool(ID_MENU_EXECUTE, _guilang.get("GUI_TB_RUN"), bmStart, _guilang.get("GUI_TB_RUN_TTP"));
5483
5484 wxBitmap bmStop(newstop1_xpm);
5485 t->AddTool(ID_MENU_STOP_EXECUTION, _guilang.get("GUI_TB_STOP"), bmStop, _guilang.get("GUI_TB_STOP_TTP"));
5486
5487 t->AddSeparator();
5488
5489 wxBitmap bmStartDebugger(newcontinue1_xpm);
5490 t->AddTool(ID_MENU_TOGGLE_DEBUGGER, _guilang.get("GUI_TB_DEBUGGER"), bmStartDebugger, _guilang.get("GUI_TB_DEBUGGER_TTP"), wxITEM_CHECK);
5492
5493 wxBitmap bmAddBreakpoint(breakpoint_xpm);
5494 t->AddTool(ID_MENU_ADDEDITORBREAKPOINT, _guilang.get("GUI_TB_ADD"), bmAddBreakpoint,
5495 _guilang.get("GUI_TB_ADD_TTP"));
5496
5497 wxBitmap bmRemoveBreakpoint(breakpoint_octagon_disable_xpm);
5498 t->AddTool(ID_MENU_REMOVEEDITORBREAKPOINT, _guilang.get("GUI_TB_REMOVE"), bmRemoveBreakpoint,
5499 _guilang.get("GUI_TB_REMOVE_TTP"));
5500
5501 wxBitmap bmClearBreakpoint(breakpoint_crossed_xpm);
5502 t->AddTool(ID_MENU_CLEAREDITORBREAKPOINTS, _guilang.get("GUI_TB_CLEAR"), bmClearBreakpoint,
5503 _guilang.get("GUI_TB_CLEAR_TTP"));
5504
5505 /*for(int i = ID_DEBUG_IDS_FIRST; i < ID_DEBUG_IDS_LAST; i++)
5506 {
5507 t->EnableTool(i, false);
5508 }*/
5509
5510 t->AddSeparator();
5511 wxBitmap bmAnalyzer(gtk_apply_xpm);
5512 t->AddTool(ID_MENU_USEANALYZER, _guilang.get("GUI_TB_ANALYZER"), bmAnalyzer, _guilang.get("GUI_TB_ANALYZER_TTP"), wxITEM_CHECK);
5513 t->ToggleTool(ID_MENU_USEANALYZER, false);
5514 t->EnableTool(ID_MENU_USEANALYZER, false);
5515
5516 t->AddSeparator();
5517 NumeRe::DataBase db("<>/docs/find.ndb");
5518
5519 if (m_options->useCustomLangFiles() && fileExists(m_options->ValidFileName("<>/user/docs/find.ndb", ".ndb")))
5520 db.addData("<>/user/docs/find.ndb");
5521
5522 t->AddControl(new ToolBarSearchCtrl(t, wxID_ANY, db, this, m_terminal, _guilang.get("GUI_SEARCH_TELLME"), _guilang.get("GUI_SEARCH_CALLTIP_TOOLBAR"), _guilang.get("GUI_SEARCH_CALLTIP_TOOLBAR_HIGHLIGHT")), wxEmptyString);
5523
5524 t->Realize();
5525
5527}
5528
5529
5539{
5540 if (!m_appStarting)
5541 return;
5542
5543 m_termContainer->Show();
5544
5545 if (!m_splitEditorOutput->IsSplit())
5546 {
5548 m_splitEditorOutput->SetMinimumPaneSize(20);
5549
5550 if (!m_splitCommandHistory->IsSplit())
5551 {
5553 }
5554
5556 m_termContainer->Show();
5557 m_noteTerm->Show();
5558 }
5559
5560 m_termContainer->Refresh();
5561 m_book->Refresh();
5562 m_noteTerm->Refresh();
5563}
5564
5565
5575{
5576 if (m_varViewer)
5577 {
5580 }
5581}
5582
5583
5593void NumeReWindow::UpdateWindowTitle(const wxString& filename)
5594{
5595 wxTopLevelWindow::SetTitle(filename + " - NumeRe: Framework für Numerische Rechnungen (v " + sVersion + ")");
5596}
5597
5598
5608{
5609 if (m_termContainer->IsShown())
5610 {
5611 m_termContainer->Hide();
5612 m_noteTerm->Hide();
5615 }
5616 else
5617 {
5619 m_splitEditorOutput->SetMinimumPaneSize(20);
5621 m_termContainer->Show();
5622
5623 if (m_splitCommandHistory->IsSplit())
5624 m_noteTerm->Show();
5625 }
5626
5627 m_book->Refresh();
5628}
5629
5630
5639{
5640 if (m_treeBook->IsShown())
5641 {
5642 m_treeBook->Hide();
5645 }
5646 else
5647 {
5649 m_splitProjectEditor->SetMinimumPaneSize(30);
5650 m_treeBook->Show();
5651 }
5652
5654 m_book->Refresh();
5655}
5656
5657
5668{
5669 if (m_noteTerm->IsShown())
5670 {
5671 m_noteTerm->Hide();
5674 }
5675 else
5676 {
5678 m_noteTerm->Show();
5679 }
5680
5682 m_termContainer->Refresh();
5683 m_noteTerm->Refresh();
5684}
5685
5686
5695{
5696 if (!m_termContainer->IsShown())
5697 toggleConsole();
5698}
5699
5700
5711{
5712 NumeReEditor* focusEd = m_book->getFocusedEditor();
5713 wxTextEntryDialog dialog(this,
5714 _guilang.get("GUI_DLG_GOTO_QUESTION", toString(focusEd->GetLineCount())),
5715 _guilang.get("GUI_DLG_GOTO"));
5716 int ret = dialog.ShowModal();
5717
5718 if (ret == wxID_CANCEL)
5719 return;
5720
5721 int line = StrToInt(dialog.GetValue().ToStdString())-1;
5722
5723 if (line < 0 || line >= focusEd->GetLineCount())
5724 wxMessageBox(_guilang.get("GUI_DLG_GOTO_ERROR"), _guilang.get("GUI_DLG_GOTO"), wxCENTRE | wxICON_ERROR);
5725 else
5726 {
5727 focusEd->GotoLine(line);
5728 focusEd->SetFocus();
5729 }
5730}
5731
5732
5741{
5742 m_book->getCurrentEditor()->SetFocus();
5743}
5744
5745
5754{
5755 m_currentView->SetFocus();
5756}
5757
5758
5768{
5769 wxWindow* focus = wxWindow::FindFocus();
5771 g_logger.info("Refreshing function tree.");
5773 m_functionTree->Refresh();
5774
5775 // Update the syntax colors in the editor windows
5776 for (size_t i = 0; i < m_book->GetPageCount(); i++)
5777 {
5778 m_book->getEditor(i)->UpdateSyntaxHighlighting(true); // Needs adaption
5779 }
5780
5782
5783 if (focus)
5784 focus->SetFocus();
5785}
5786
5787
5798{
5799 return m_book->getCurrentEditor();
5800}
5801
5802
5811static std::vector<std::string> tokenize(std::string sKeyList)
5812{
5813 std::vector<std::string> vKeyList;
5814
5815 while (sKeyList.length())
5816 {
5817 vKeyList.push_back(sKeyList.substr(0, sKeyList.find(' ')));
5818 sKeyList.erase(0, sKeyList.find(' '));
5819
5820 while (sKeyList.front() == ' ')
5821 sKeyList.erase(0,1);
5822 }
5823
5824 return vKeyList;
5825}
5826
5827
5836{
5837 // Insert the plugin and function definitions
5840
5841 // Clear all previously available items
5842 if (!m_functionTree->IsEmpty())
5843 m_functionTree->DeleteAllItems();
5844
5845 int idxFolderOpen = m_iconManager->GetIconIndex("FOLDEROPEN");
5846 int idxFunctions = m_iconManager->GetIconIndex("FUNCTIONS");
5847 int idxCommands = m_iconManager->GetIconIndex("COMMANDS");
5848 int idxConstants = m_iconManager->GetIconIndex("CONSTANTS");
5849 int idxMethods = m_iconManager->GetIconIndex("METHODS");
5850
5851 // Create the root node
5852 wxTreeItemId rootNode = m_functionTree->AddRoot(_guilang.get("GUI_TREE_WORKSPACE"), m_iconManager->GetIconIndex("WORKPLACE"));
5853
5854 // Create the sections
5855 FileNameTreeData* rootData = new FileNameTreeData();
5856 wxTreeItemId commandNode = m_functionTree->AppendItem(rootNode, _guilang.get("GUI_TREE_COMMANDS"),
5857 m_iconManager->GetIconIndex("WORKPLACE"), -1, rootData);
5858
5859 rootData = new FileNameTreeData();
5860 wxTreeItemId functionNode = m_functionTree->AppendItem(rootNode, _guilang.get("GUI_TREE_FUNCTIONS"),
5861 m_iconManager->GetIconIndex("WORKPLACE"), -1, rootData);
5862
5863 rootData = new FileNameTreeData();
5864 wxTreeItemId methodNode = m_functionTree->AppendItem(rootNode, _guilang.get("GUI_TREE_METHODS"),
5865 m_iconManager->GetIconIndex("WORKPLACE"), -1, rootData);
5866
5867 rootData = new FileNameTreeData();
5868 wxTreeItemId constNode = m_functionTree->AppendItem(rootNode, _guilang.get("GUI_TREE_CONSTANTS"),
5869 m_iconManager->GetIconIndex("WORKPLACE"), -1, rootData);
5870
5871 wxTreeItemId currentNode;
5872 std::vector<std::string> vDirList;
5873 std::vector<std::string> vKeyList = tokenize(_guilang.get("GUI_TREE_CMD_KEYLIST"));
5874
5875 // commands
5876 for (size_t i = 0; i < vKeyList.size(); i++)
5877 {
5879 dir->isDir = true;
5880 currentNode = m_functionTree->AppendItem(commandNode, _guilang.get("PARSERFUNCS_LISTCMD_TYPE_" + toUpperCase(vKeyList[i])),
5881 idxFolderOpen, -1, dir);
5882 vDirList = _guilang.getList("PARSERFUNCS_LISTCMD_CMD_*_[" + toUpperCase(vKeyList[i]) + "]");
5883
5884 for (size_t j = 0; j < vDirList.size(); j++)
5885 {
5886 FileNameTreeData* data = new FileNameTreeData();
5887 data->isCommand = true;
5888 data->tooltip = prepareTooltip(vDirList[j]);
5889 m_functionTree->AppendItem(currentNode, vDirList[j].substr(0, vDirList[j].find(' ')), idxCommands, -1, data);
5890 }
5891 }
5892
5893 m_functionTree->Toggle(commandNode);
5894
5895 // functions
5896 vKeyList = tokenize(_guilang.get("GUI_TREE_FUNC_KEYLIST"));
5897
5898 for (size_t i = 0; i < vKeyList.size(); i++)
5899 {
5901 dir->isDir = true;
5902 currentNode = m_functionTree->AppendItem(functionNode, _guilang.get("PARSERFUNCS_LISTFUNC_TYPE_" + toUpperCase(vKeyList[i])),
5903 idxFolderOpen, -1, dir);
5904 vDirList = _guilang.getList("PARSERFUNCS_LISTFUNC_FUNC_*_[" + toUpperCase(vKeyList[i]) + "]");
5905
5906 for (size_t j = 0; j < vDirList.size(); j++)
5907 {
5908 FileNameTreeData* data = new FileNameTreeData();
5909 data->isFunction = true;
5910 data->tooltip = prepareTooltip(vDirList[j]);
5911 m_functionTree->AppendItem(currentNode, vDirList[j].substr(0, vDirList[j].find(')')+1), idxFunctions, -1, data);
5912 }
5913 }
5914
5915 m_functionTree->Toggle(functionNode);
5916
5917 // methods
5918 vKeyList = tokenize(_guilang.get("GUI_TREE_METHOD_KEYLIST"));
5919
5920 for (size_t i = 0; i < vKeyList.size(); i++)
5921 {
5923 dir->isDir = true;
5924 currentNode = m_functionTree->AppendItem(methodNode, _guilang.get("PARSERFUNCS_LISTFUNC_METHODS_TYPE_" + toUpperCase(vKeyList[i])),
5925 idxFolderOpen, -1, dir);
5926 vDirList = _guilang.getList("PARSERFUNCS_LISTFUNC_METHOD_*_[" + toUpperCase(vKeyList[i]) + "]");
5927 std::string sPrefix = vKeyList[i] == "data" ? "TABLE()" : "STRINGVAR";
5928
5929 for (size_t j = 0; j < vDirList.size(); j++)
5930 {
5931 FileNameTreeData* data = new FileNameTreeData();
5932 data->isMethod = true;
5933 data->tooltip = sPrefix + prepareTooltip("." + vDirList[j]);
5934 m_functionTree->AppendItem(currentNode, sPrefix + "." + vDirList[j].substr(0, vDirList[j].find(" ")), idxMethods, -1, data);
5935 }
5936 }
5937
5938 m_functionTree->Toggle(methodNode);
5939
5940 // Constants
5941 vKeyList = tokenize(_guilang.get("GUI_TREE_CONST_KEYLIST"));
5942
5943 for (size_t i = 0; i < vKeyList.size(); i++)
5944 {
5946 dir->isDir = true;
5947 currentNode = m_functionTree->AppendItem(constNode, _guilang.get("PARSERFUNCS_LISTCONST_TYPE_" + toUpperCase(vKeyList[i])),
5948 idxFolderOpen, -1, dir);
5949 vDirList = _guilang.getList("GUI_EDITOR_CALLTIP_CONST_*_[" + toUpperCase(vKeyList[i]) + "]");
5950
5951 for (size_t j = 0; j < vDirList.size(); j++)
5952 {
5953 FileNameTreeData* data = new FileNameTreeData();
5954 data->isConstant = true;
5955 data->tooltip = vDirList[j];
5956 m_functionTree->AppendItem(currentNode, vDirList[j].substr(0, vDirList[j].find(" = ")), idxConstants, -1, data);
5957 }
5958 }
5959
5960 m_functionTree->Toggle(constNode);
5961
5962}
5963
5964
5973std::string NumeReWindow::prepareTooltip(const std::string& sTooltiptext)
5974{
5975 size_t nClosingParens = sTooltiptext.find(')');
5976 std::string sTooltip = sTooltiptext;
5977
5978 if (sTooltiptext.front() == '.')
5979 {
5980 nClosingParens = sTooltip.find(" ");
5981 sTooltip.replace(nClosingParens, sTooltip.find_first_not_of(' ', nClosingParens)-nClosingParens, " -> ");
5982 }
5983 else if (sTooltiptext.find(' ') < nClosingParens && sTooltiptext.find(' ') < sTooltiptext.find('('))
5984 {
5985 nClosingParens = sTooltiptext.find(' ')-1;
5986 sTooltip.replace(nClosingParens+1, sTooltip.find_first_not_of(' ', nClosingParens+1)-nClosingParens-1, " ");
5987 }
5988 else
5989 sTooltip.replace(nClosingParens+1, sTooltip.find_first_not_of(' ', nClosingParens+1)-nClosingParens-1, " -> ");
5990
5991 return sTooltip;
5992}
5993
5994
6003{
6004 wxPrintData* printdata = new wxPrintData();
6005 printdata->SetPaperId(wxPAPER_A4);
6006 printdata->SetBin(wxPRINTBIN_AUTO);
6007 printdata->SetOrientation(wxPORTRAIT);
6008 printdata->SetQuality(wxPRINT_QUALITY_HIGH);
6009 printdata->SetPrinterName(wxEmptyString);
6010 return printdata;
6011}
6012
6013
6026{
6027 if (event.GetId() == ID_PROJECTTREE)
6028 {
6029 VersionControlSystemManager manager(this);
6030 wxTreeItemId clickedItem = event.GetItem();
6031 m_clickedTreeItem = clickedItem;
6032 wxMenu popupMenu;
6033 wxString editableExt = ".dat;.txt;.nscr;.nprc;.dx;.jcm;.jdx;.csv;.log;.tex;.xml;.nhlp;.npkp;.cpp;.cxx;.c;.hpp;.hxx;.h;.m;.nlyt;";
6034 wxString loadableExt = ".dat;.txt;.dx;.jcm;.jdx;.xls;.xlsx;.ods;.ndat;.labx;.ibw;.csv;";
6035 wxString showableImgExt = ".png;.jpeg;.jpg;.gif;.bmp;";
6036
6037 wxString fname_ext = m_fileTree->GetItemText(m_clickedTreeItem);
6038 FileNameTreeData* data = static_cast<FileNameTreeData*>(m_fileTree->GetItemData(m_clickedTreeItem));
6039
6040 if (m_clickedTreeItem == m_fileTree->GetRootItem())
6041 return;
6042
6043 if (!data || data->isDir)
6044 {
6045 popupMenu.Append(ID_MENU_NEW_FOLDER_IN_TREE, _guilang.get("GUI_TREE_PUP_NEWFOLDER"));
6046
6047 if (data)
6048 popupMenu.Append(ID_MENU_REMOVE_FOLDER_FROM_TREE, _guilang.get("GUI_TREE_PUP_REMOVEFOLDER"));
6049
6050 popupMenu.AppendSeparator();
6051 popupMenu.Append(ID_MENU_COPY_AS_PATH, _guilang.get("GUI_TREE_PUP_COPYASPATH"));
6052 popupMenu.AppendSeparator();
6053 popupMenu.Append(ID_MENU_OPEN_IN_EXPLORER, _guilang.get("GUI_TREE_PUP_OPENINEXPLORER"));
6054 wxPoint p = event.GetPoint();
6055 m_fileTree->PopupMenu(&popupMenu, p);
6056 return;
6057 }
6058
6059 fname_ext = fname_ext.substr(fname_ext.rfind('.')).Lower() + ";";
6060
6061 if (loadableExt.find(fname_ext) != std::string::npos)
6062 {
6063 popupMenu.Append(ID_MENU_OPEN_FILE_FROM_TREE, _guilang.get("GUI_TREE_PUP_LOAD"));
6064 popupMenu.Append(ID_MENU_OPEN_FILE_FROM_TREE_TO_TABLE, _guilang.get("GUI_TREE_PUP_LOADTOTABLE"));
6065 }
6066 else if (fname_ext == ".nscr;")
6067 popupMenu.Append(ID_MENU_OPEN_FILE_FROM_TREE, _guilang.get("GUI_TREE_PUP_START"));
6068 else if (fname_ext == ".nprc;")
6069 popupMenu.Append(ID_MENU_OPEN_FILE_FROM_TREE, _guilang.get("GUI_TREE_PUP_RUN"));
6070
6071 if (editableExt.find(fname_ext) != std::string::npos)
6072 popupMenu.Append(ID_MENU_EDIT_FILE_FROM_TREE, _guilang.get("GUI_TREE_PUP_EDIT"));
6073
6074 if (showableImgExt.find(fname_ext) != std::string::npos)
6075 popupMenu.Append(ID_MENU_OPEN_IMAGE_FROM_TREE, _guilang.get("GUI_TREE_PUP_OPENIMAGE"));
6076
6077 if (manager.hasRevisions(data->filename))
6078 {
6079 popupMenu.AppendSeparator();
6080 popupMenu.Append(ID_MENU_SHOW_REVISIONS, _guilang.get("GUI_TREE_PUP_SHOWREVISIONS"));
6081 popupMenu.Append(ID_MENU_TAG_CURRENT_REVISION, _guilang.get("GUI_TREE_PUP_TAGCURRENTREVISION"));
6082 }
6083
6084 popupMenu.AppendSeparator();
6085 popupMenu.Append(ID_MENU_COPY_AS_PATH, _guilang.get("GUI_TREE_PUP_COPYASPATH"));
6086 popupMenu.AppendSeparator();
6087 popupMenu.Append(ID_MENU_DELETE_FILE_FROM_TREE, _guilang.get("GUI_TREE_PUP_DELETEFILE"));
6088 popupMenu.Append(ID_MENU_COPY_FILE_FROM_TREE, _guilang.get("GUI_TREE_PUP_COPYFILE"));
6089
6090 if (m_copiedTreeItem)
6091 popupMenu.Append(ID_MENU_INSERT_FILE_INTO_TREE, _guilang.get("GUI_TREE_PUP_INSERTFILE"));
6092
6093 popupMenu.Append(ID_MENU_RENAME_FILE_IN_TREE, _guilang.get("GUI_TREE_PUP_RENAMEFILE"));
6094
6095 wxPoint p = event.GetPoint();
6096 m_fileTree->PopupMenu(&popupMenu, p);
6097 }
6098 else
6099 {
6100 wxTreeItemId clickedItem = event.GetItem();
6101 m_clickedTreeItem = clickedItem;
6102 wxMenu popupMenu;
6103
6104 FileNameTreeData* data = static_cast<FileNameTreeData*>(m_functionTree->GetItemData(clickedItem));
6105
6106 if (data->isDir)
6107 return;
6108
6109 popupMenu.Append(ID_MENU_INSERT_IN_EDITOR_FROM_TREE, _guilang.get("GUI_TREE_PUP_INSERT_EDITOR"));
6110 popupMenu.Append(ID_MENU_INSERT_IN_CONSOLE_FROM_TREE, _guilang.get("GUI_TREE_PUP_INSERT_CONSOLE"));
6111
6112 if (data->isCommand)
6113 {
6114 popupMenu.AppendSeparator();
6115 popupMenu.Append(ID_MENU_HELP_ON_ITEM, _guilang.get("GUI_TREE_PUP_HELPONITEM", m_functionTree->GetItemText(clickedItem).ToStdString()));
6116 }
6117
6118 wxPoint p = event.GetPoint();
6119 m_functionTree->PopupMenu(&popupMenu, p);
6120 }
6121}
6122
6123
6135{
6136 if (event.GetId() == ID_PROJECTTREE)
6137 {
6138 wxTreeItemId item = event.GetItem();
6139
6140 if(item == m_projectFileFolders[0]
6141 || item == m_projectFileFolders[1]
6142 || item == m_projectFileFolders[2]
6143 || item == m_projectFileFolders[3]
6144 || item == m_projectFileFolders[4])
6145 {
6146 m_fileTree->Toggle(item);
6147 return;
6148 }
6149
6150 wxTreeItemId rootItem = m_fileTree->GetRootItem();
6151
6152 if (item != rootItem)
6153 {
6154 //wxTreeItemId parentItem = m_projectTree->GetItemParent(item);
6155 FileNameTreeData* data = static_cast <FileNameTreeData* > (m_fileTree->GetItemData(item));
6156 wxFileName pathname = data->filename;
6157 if (data->isDir && m_fileTree->HasChildren(item))
6158 {
6159 m_fileTree->Toggle(item);
6160 return;
6161 }
6162 else if (data->filename.find('.') == std::string::npos || data->isDir)
6163 return;
6164
6165 OpenFileByType(pathname);
6166 }
6167 m_book->getCurrentEditor()->Refresh();
6168 m_book->Refresh();
6169 }
6170 else
6171 {
6173 wxTreeItemId item = event.GetItem();
6174 FileNameTreeData* data = static_cast<FileNameTreeData*>(m_functionTree->GetItemData(item));
6175 if (data->isDir)
6176 {
6177 m_functionTree->Toggle(item);
6178 }
6179 else if (data->isCommand)
6180 {
6181 edit->InsertText(edit->GetCurrentPos(), (data->tooltip).substr(0, (data->tooltip).find(' ')+1));
6182 edit->GotoPos(edit->GetCurrentPos()+(data->tooltip).find(' ')+1);
6183 }
6184 else if (data->isFunction)
6185 {
6186 edit->InsertText(edit->GetCurrentPos(), (data->tooltip).substr(0, (data->tooltip).find('(')+1));
6187 edit->GotoPos(edit->GetCurrentPos()+(data->tooltip).find('(')+1);
6188 }
6189 else if (data->isMethod)
6190 {
6191 size_t dot = (data->tooltip).find('.');
6192 size_t endPos = (data->tooltip).find_first_of("( ", dot);
6193
6194 if ((data->tooltip)[endPos] == '(')
6195 endPos++;
6196
6197 edit->InsertText(edit->GetCurrentPos(), (data->tooltip).substr(dot, endPos-dot));
6198 edit->GotoPos(edit->GetCurrentPos()+endPos-dot);
6199 }
6200 else if (data->isConstant)
6201 {
6202 edit->InsertText(edit->GetCurrentPos(), (data->tooltip).substr(0, (data->tooltip).find(' ')));
6203 edit->GotoPos(edit->GetCurrentPos()+(data->tooltip).find(' '));
6204 }
6205 }
6206}
6207
6208
6218void NumeReWindow::OnTreeItemToolTip(wxTreeEvent& event)
6219{
6220 if (event.GetId() == ID_FUNCTIONTREE)
6221 {
6222 wxTreeItemId item = event.GetItem();
6223
6224 FileNameTreeData* data = static_cast<FileNameTreeData*>(m_functionTree->GetItemData(item));
6225
6226 if (data->isDir)
6227 return;
6228 else if (data->isFunction || data->isCommand || data->isMethod)
6229 event.SetToolTip(this->addLinebreaks(data->tooltip));
6230 else if (data->isConstant)
6231 event.SetToolTip(data->tooltip);
6232 }
6233 else
6234 {
6235 wxTreeItemId item = event.GetItem();
6236
6237 FileNameTreeData* data = static_cast<FileNameTreeData*>(m_functionTree->GetItemData(item));
6238
6239 if (!data || data->isDir)
6240 return;
6241
6242 // Show revision count (if any)
6243 VersionControlSystemManager manager(this);
6244
6245 wxFileName pathname = data->filename;
6246 wxString tooltip;
6247
6248 if (pathname.GetExt() == "nprc")
6249 {
6250 NumeRe::CallTip _cTip = NumeRe::addLinebreaks(NumeRe::FindProcedureDefinition((pathname.GetPath() + "\\" + pathname.GetName()).ToStdString(), "$" + pathname.GetName().ToStdString()), 75);
6251
6252 tooltip = _guilang.get("COMMON_FILETYPE_NPRC");
6253
6254 if (manager.hasRevisions(pathname.GetFullPath()))
6255 {
6256 std::unique_ptr<FileRevisions> revisions(manager.getRevisions(pathname.GetFullPath()));
6257
6258 if (revisions.get())
6259 tooltip += " (" + revisions->getCurrentRevision() + ")";
6260 }
6261
6262 tooltip += "\n";
6263 tooltip.append(80u, '-');
6264 tooltip += "\n" + _cTip.sDefinition + "\n" + _cTip.sDocumentation;
6265 }
6266 else
6267 {
6268 tooltip = _guilang.get("COMMON_FILETYPE_" + toUpperCase(pathname.GetExt().ToStdString()));
6269
6270 if (pathname.GetExt() == "ndat")
6271 tooltip += getFileDetails(pathname);
6272
6273 if (manager.hasRevisions(pathname.GetFullPath()))
6274 {
6275 std::unique_ptr<FileRevisions> revisions(manager.getRevisions(pathname.GetFullPath()));
6276
6277 if (revisions.get())
6278 tooltip += "\n(" + revisions->getCurrentRevision() + ")";
6279 }
6280 }
6281
6282 event.SetToolTip(tooltip);
6283 }
6284}
6285
6286
6295void NumeReWindow::OnTreeDragDrop(wxTreeEvent& event)
6296{
6297 if (event.GetId() == ID_FUNCTIONTREE)
6298 {
6299 wxTreeItemId item = event.GetItem();
6300 FileNameTreeData* data = static_cast<FileNameTreeData*>(m_functionTree->GetItemData(item));
6301
6302 if (!data->isCommand && !data->isFunction && !data->isConstant && !data->isMethod)
6303 return;
6304
6305 wxString token = data->tooltip;
6306
6307 if (data->isMethod)
6308 {
6309 size_t dot = token.find('.');
6310 size_t endPos = token.find_first_of("( ", dot);
6311
6312 if (token[endPos] == '(')
6313 endPos++;
6314
6315 token = token.substr(dot, endPos-dot);
6316 }
6317 else
6318 {
6319 token.erase(token.find(' '));
6320
6321 if (token.find('(') != std::string::npos)
6322 token.erase(token.find('(')+1);
6323 else
6324 token += " ";
6325 }
6326
6327 wxTextDataObject _dataObject(token);
6328 wxDropSource dragSource(this);
6329 dragSource.SetData(_dataObject);
6330 dragSource.DoDragDrop(wxDrag_AllowMove);
6331 }
6332 else
6333 {
6334 wxTreeItemId item = event.GetItem();
6335 m_dragDropSourceItem = item;
6336 FileNameTreeData* data = static_cast<FileNameTreeData*>(m_fileTree->GetItemData(item));
6337
6338 if (!data || data->isDir)
6339 return;
6340
6341 wxFileName pathname = data->filename;
6342 wxString dragableExtensions = ";nscr;nprc;ndat;nlyt;txt;dat;log;tex;csv;xls;xlsx;ods;jdx;jcm;dx;labx;ibw;png;jpg;jpeg;gif;bmp;eps;svg;m;cpp;cxx;c;hpp;hxx;h;";
6343
6344 if (dragableExtensions.find(";" + pathname.GetExt().Lower() + ";") != std::string::npos)
6345 {
6346 wxFileDataObject _dataObject;
6347 _dataObject.AddFile(pathname.GetFullPath());
6348 wxDropSource dragSource(this);
6349 dragSource.SetData(_dataObject);
6350 dragSource.DoDragDrop(wxDrag_AllowMove);
6351 }
6352
6353 }
6354}
6355
6356
6367wxString NumeReWindow::addLinebreaks(const wxString& sLine)
6368{
6369 const unsigned int nMAXLINE = 70;
6370
6371 wxString sReturn = sLine;
6372
6373 while (sReturn.find("\\$") != std::string::npos)
6374 sReturn.erase(sReturn.find("\\$"),1);
6375
6376 unsigned int nDescStart = sReturn.find("- ");
6377 unsigned int nIndentPos = 4;//
6378 unsigned int nLastLineBreak = 0;
6379 sReturn.replace(nDescStart, 2,"\n ");
6380 nLastLineBreak = nDescStart;
6381
6382 for (unsigned int i = nDescStart; i < sReturn.length(); i++)
6383 {
6384 if (sReturn[i] == '\n')
6385 nLastLineBreak = i;
6386
6387 if ((i == nMAXLINE && !nLastLineBreak)
6388 || (nLastLineBreak && i - nLastLineBreak == nMAXLINE))
6389 {
6390 for (int j = i; j >= 0; j--)
6391 {
6392 if (sReturn[j] == ' ')
6393 {
6394 sReturn[j] = '\n';
6395 sReturn.insert(j+1, nIndentPos, ' ');
6396 nLastLineBreak = j;
6397 break;
6398 }
6399 else if (sReturn[j] == '-' && j != (int)i)
6400 {
6401 // --> Minuszeichen: nicht immer ist das Trennen an dieser Stelle sinnvoll. Wir pruefen die einfachsten Faelle <--
6402 if (j &&
6403 (sReturn[j-1] == ' '
6404 || sReturn[j-1] == '('
6405 || sReturn[j+1] == ')'
6406 || sReturn[j-1] == '['
6407 || (sReturn[j+1] >= '0' && sReturn[j+1] <= '9')
6408 || sReturn[j+1] == ','
6409 || (sReturn[j+1] == '"' && sReturn[j-1] == '"')
6410 ))
6411 continue;
6412
6413 sReturn.insert(j+1, "\n");
6414 sReturn.insert(j+2, nIndentPos, ' ');
6415 nLastLineBreak = j+1;
6416 break;
6417 }
6418 else if (sReturn[j] == ',' && j != (int)i && sReturn[j+1] != ' ')
6419 {
6420 sReturn.insert(j+1, "\n");
6421 sReturn.insert(j+2, nIndentPos, ' ');
6422 nLastLineBreak = j+1;
6423 break;
6424 }
6425 }
6426 }
6427 }
6428
6429 return sReturn;
6430}
6431
6432
6442wxString NumeReWindow::getFileDetails(const wxFileName& filename)
6443{
6445 return "\n" + getFileInfo(filename.GetFullPath().ToStdString());
6446 else
6447 return "NOTHING";
6448}
6449
6450
6461void NumeReWindow::LoadFilesToTree(wxString fromPath, FileFilterType fileType, wxTreeItemId treeid)
6462{
6463 g_logger.info("Loading files from '" + fromPath.ToStdString() + "' into file tree.");
6464 wxDir currentDir(fromPath);
6465 DirTraverser _traverser(m_fileTree, m_iconManager, treeid, fromPath, fileType);
6466 currentDir.Traverse(_traverser);
6467}
6468
6469
6480void NumeReWindow::OnFindEvent(wxFindDialogEvent& event)
6481{
6482 wxEventType type = event.GetEventType();
6483 wxString findString = event.GetFindString();
6484 long flags = event.GetFlags();
6486 int pos = edit->GetCurrentPos();
6487
6488 if ((type == wxEVT_COMMAND_FIND) ||
6489 (type == wxEVT_COMMAND_FIND_NEXT))
6490 {
6491 pos = FindString(findString, pos, flags, true);
6492
6493 if (pos < 0)
6494 {
6495 wxMessageBox(_guilang.get("GUI_SEARCH_END", findString.ToStdString()),
6496 _guilang.get("GUI_SEARCH_END_HEAD"), wxOK | wxICON_EXCLAMATION, this);
6497 }
6498 }
6499 else if (type == wxEVT_COMMAND_FIND_REPLACE)
6500 {
6501 if ((flags & wxFR_MATCHCASE && edit->GetSelectedText() != findString)
6502 || (!(flags & wxFR_MATCHCASE) && toLowerCase(edit->GetSelectedText().ToStdString()) != toLowerCase(findString.ToStdString())))
6503 {
6504 wxBell();
6505 return;
6506 }
6507
6508 pos = edit->GetSelectionStart();
6509 wxString replaceString = event.GetReplaceString();
6510 edit->ReplaceSelection(replaceString);
6511 edit->EnsureCaretVisible();
6512 edit->SetSelection(pos, pos + replaceString.length());
6513 }
6514 else if (type == wxEVT_COMMAND_FIND_REPLACE_ALL)
6515 {
6516 wxString replaceString = event.GetReplaceString();
6517 if (findString == replaceString)
6518 return;
6519
6520 wxBusyCursor busy;
6521 int count = ReplaceAllStrings(findString, replaceString, flags);
6522
6524 wxMessageBox(_guilang.get("GUI_REPLACE_END", toString(count), findString.ToStdString(), replaceString.ToStdString()), _guilang.get("GUI_REPLACE_END_HEAD"), wxOK, this);
6526 }
6527 else if (type == wxEVT_COMMAND_FIND_CLOSE)
6528 {
6529 if (wxDynamicCast(event.GetEventObject(), wxDialog))
6530 {
6531 ((wxDialog*)event.GetEventObject())->Destroy();
6532 }
6533 g_findReplace = nullptr;
6534 }
6535}
6536
6537
6551int NumeReWindow::FindString(const wxString &findString, int start_pos, int flags, bool highlight)
6552{
6554
6555 if (findString.IsEmpty())
6556 return wxNOT_FOUND;
6557
6558 int stc_flags = 0;
6559 if ((flags & wxFR_MATCHCASE) != 0)
6560 {
6561 stc_flags |= wxSTC_FIND_MATCHCASE;
6562 }
6563 if ((flags & wxFR_WHOLEWORD) != 0)
6564 {
6565 stc_flags |= wxSTC_FIND_WHOLEWORD;
6566 }
6567
6568 int pos = start_pos == -1 ? edit->GetCurrentPos() : start_pos;
6569
6570 if ((flags & wxFR_DOWN) != 0)
6571 {
6572 edit->SetTargetStart(wxMax(0, pos));
6573 edit->SetTargetEnd(wxMax(0, edit->GetTextLength()));
6574 }
6575 else
6576 {
6577 if (labs(edit->GetTargetEnd() - edit->GetTargetStart()) == long(findString.length()))
6578 {
6579 pos -= findString.length() + 1; // doesn't matter if it matches or not, skip it
6580 }
6581
6582 edit->SetTargetStart(wxMax(0, pos));
6583 edit->SetTargetEnd(0);
6584 }
6585
6586 edit->SetSearchFlags(stc_flags);
6587 pos = edit->SearchInTarget(findString);
6588
6589 if (pos >= 0)
6590 {
6591 if (highlight)
6592 {
6593 edit->GotoPos(pos+findString.length());
6594 edit->SetSelection(pos, pos + findString.length());
6595 edit->EnsureLineVisibility(edit->GetCurrentLine());
6596 edit->EnsureCaretVisible();
6597 }
6598 }
6599 else if (flags & wxFR_WRAPAROUND)
6600 {
6601 if ((flags & wxFR_DOWN) && start_pos)
6602 return FindString(findString, 0, flags, highlight);
6603 else if (!(flags & wxFR_DOWN) && start_pos != edit->GetLastPosition())
6604 return FindString(findString, edit->GetLastPosition(), flags, highlight);
6605 }
6606
6607 return pos;
6608}
6609
6610
6623int NumeReWindow::ReplaceAllStrings(const wxString &findString, const wxString &replaceString, int flags)
6624{
6625 int count = 0;
6627
6628 if (findString.IsEmpty() || (findString == replaceString))
6629 return count;
6630
6631 int cursor_pos = edit->GetCurrentPos(); // return here when done
6632 if (flags & wxFR_WRAPAROUND)
6633 {
6634 edit->GotoPos(0);
6635 flags &= flags & ~wxFR_WRAPAROUND;
6636 }
6637 edit->BeginUndoAction();
6638 if (edit->GetSelectedText() == findString)
6639 {
6640 ++count;
6641 edit->ReplaceSelection(replaceString);
6642 }
6643
6644 int pos = FindString(findString, -1, flags, true);
6645
6646 while (pos != -1)
6647 {
6648 ++count;
6649 edit->ReplaceSelection(replaceString);
6650 pos = FindString(findString, -1, flags, true);
6651 }
6652
6653 // return to starting pos or as close as possible
6654 edit->GotoPos(wxMin(cursor_pos, edit->GetLength()));
6655 edit->EndUndoAction();
6656
6657 return count;
6658}
6659
6660
6670{
6671 wxSize scr = wxGetDisplaySize();
6672
6673 // determine position and size (shifting 16 left and down)
6674 wxRect rect = GetRect();
6675 rect.x += 16;
6676 rect.y += 16;
6677 rect.width = wxMin (rect.width, (scr.x - rect.x));
6678 rect.height = wxMin (rect.height, (scr.x - rect.y));
6679
6680 return rect;
6681}
6682
6683
6692void NumeReWindow::FindAndOpenProcedure(const wxString& procedureName)
6693{
6694 m_book->getFocusedEditor()->FindAndOpenProcedure(procedureName);
6695}
6696
6697
6708void NumeReWindow::UpdateLocationIfOpen(const wxFileName& fname, const wxFileName& newFName)
6709{
6710 int num = GetPageNum(fname, true, 0);
6711
6712 if (num != wxNOT_FOUND)
6713 {
6714 NumeReEditor* edit = m_book->getEditor(num); // Might need adaption
6715
6716 if (edit->Modified())
6717 return;
6718
6719 edit->SetFilename(newFName, false);
6720 m_book->SetTabText(num, edit->GetFileNameAndPath());
6721 m_book->Refresh();
6722 UpdateWindowTitle(m_book->GetPageText(m_book->GetSelection()));
6723 }
6724}
6725
6726
6736void NumeReWindow::reloadFileIfOpen(const wxString& fname, bool force)
6737{
6738 NumeReEditor* edit;
6739 wxString fileContents;
6740 wxString fileNameNoPath;
6741
6742 if (!GetFileContents(fname, fileContents, fileNameNoPath))
6743 return;
6744
6745 // Search the file in the list of currently
6746 // opened files
6747 for (size_t j = 0; j < m_book->GetPageCount(); j++)
6748 {
6749 edit = m_book->getEditor(j);
6750
6751 // Found it?
6752 if (edit && edit->GetFileNameAndPath() == fname)
6753 {
6754 g_logger.info("Reloading '" + fname.ToStdString() + "' to editor.");
6755 m_filesLastSaveTime[fname] = 0;
6756
6757 // If the user has modified the file, as
6758 // him to reload the file, otherwise re-
6759 // load automatically
6760 if (edit->IsModified() && !force)
6761 {
6762 m_book->SetSelection(j);
6763 int answer = wxMessageBox(_guilang.get("GUI_DLG_FILEMODIFIED_QUESTION", fname.ToStdString()), _guilang.get("GUI_DLG_FILEMODIFIED"), wxYES_NO | wxICON_QUESTION, this);
6764
6765 if (answer == wxYES)
6766 {
6767 int pos = m_book->getFocusedEditor()->GetCurrentPos();
6768 m_book->getCurrentEditor()->LoadFileText(fileContents);
6769 m_book->getCurrentEditor()->MarkerDeleteAll(MARKER_SAVED);
6770 m_book->getFocusedEditor()->GotoPos(pos);
6771 m_filesLastSaveTime[fname] = time(0);
6772 }
6773 }
6774 else
6775 {
6776 int pos = edit->GetCurrentPos();
6777 edit->LoadFileText(fileContents);
6778 edit->MarkerDeleteAll(MARKER_SAVED);
6779 edit->GotoPos(pos);
6780 m_filesLastSaveTime[fname] = time(0);
6781 }
6782
6783 return;
6784 }
6785 }
6786}
6787
6788
6798void NumeReWindow::registerWindow(wxWindow* window, WindowType type)
6799{
6800 if (m_openedWindows.find(window) == m_openedWindows.end())
6801 m_openedWindows[window] = type;
6802}
6803
6804
6814{
6815 if (m_openedWindows.find(window) != m_openedWindows.end())
6816 m_openedWindows.erase(window);
6817}
6818
6819
6830{
6831 auto iter = m_openedWindows.begin();
6832
6833 while (iter != m_openedWindows.end())
6834 {
6835 if (type == WT_ALL || type == iter->second)
6836 {
6837 // Copy pointer to avoid issues with
6838 // iterator invalidation
6839 wxWindow* w = iter->first;
6840 iter = m_openedWindows.erase(iter);
6841 w->Destroy();
6842 }
6843 else
6844 ++iter;
6845 }
6846}
6847
6848
6857{
6858 return wxIcon(getProgramFolder()+"\\icons\\icon.ico", wxBITMAP_TYPE_ICO);
6859}
6860
6861
6872{
6874
6875 wxWindowList& winlist = GetChildren();
6876
6877 for (size_t win = 0; win < winlist.GetCount(); win++)
6878 {
6879 if (winlist[win]->IsShown() && winlist[win]->GetLabel() == PACKAGE_REPO_BROWSER_TITLE)
6880 {
6881 static_cast<PackageRepoBrowser*>(winlist[win])->DetectInstalledPackages();
6882 }
6883 }
6884}
6885
6886
6897void NumeReWindow::OnSplitterDoubleClick(wxSplitterEvent &event)
6898{
6899 event.Veto();
6900}
6901
6902
6913{
6914 if( id == ID_MENU_OPEN_SOURCE_LOCAL)
6915 m_remoteMode = false;
6916 else if(id == ID_MENU_OPEN_SOURCE_REMOTE)
6917 m_remoteMode = true;
6918
6919 wxArrayString fnames = OpenFile(FILE_SUPPORTEDFILES);
6920
6921 if(fnames.Count() > 0)
6922 OpenFilesFromList(fnames);
6923}
6924
6925
6935{
6936 if( id == ID_MENU_SAVE_SOURCE_LOCAL)
6937 m_remoteMode = false;
6938 else if(id == ID_MENU_SAVE_SOURCE_REMOTE)
6939 m_remoteMode = true;
6940
6941 SaveCurrentFile(true);
6942}
6943
6944
6954void NumeReWindow::OnExecuteFile(const std::string& sFileName, int id)
6955{
6956 if (!sFileName.length())
6957 return;
6958
6959 std::string command = replacePathSeparator(sFileName);
6960 std::vector<std::string> vPaths = m_terminal->getPathSettings();
6961
6962 if (command.rfind(".nprc") != std::string::npos)
6963 {
6965 SaveAll(true);
6966
6967 command.erase(command.rfind(".nprc"));
6968
6969 if (command.substr(0, vPaths[PROCPATH].length()) == vPaths[PROCPATH])
6970 {
6971 command.erase(0, vPaths[PROCPATH].length());
6972
6973 while (command.front() == '/')
6974 command.erase(0, 1);
6975
6976 while (command.find('/') != std::string::npos)
6977 command[command.find('/')] = '~';
6978 }
6979 else
6980 command = "'" + command + "'";
6981
6982 command = "$" + command + "()";
6983 }
6984 else if (command.rfind(".nscr") != std::string::npos)
6985 {
6987 SaveAll(true);
6988
6989 command.erase(command.rfind(".nscr"));
6990
6991 if (command.substr(0, vPaths[SCRIPTPATH].length()) == vPaths[SCRIPTPATH])
6992 command.erase(0, vPaths[SCRIPTPATH].length());
6993
6994 while (command.front() == '/')
6995 command.erase(0, 1);
6996
6997 command = "start \"" + command + "\"";
6998 }
6999 else if (command.rfind(".nlyt") != std::string::npos)
7000 {
7002 SaveAll(true);
7003
7004 command.erase(command.rfind(".nlyt"));
7005
7006 if (command.substr(0, vPaths[SCRIPTPATH].length()) == vPaths[SCRIPTPATH])
7007 command.erase(0, vPaths[SCRIPTPATH].length());
7008
7009 if (command.substr(0, vPaths[PROCPATH].length()) == vPaths[PROCPATH])
7010 command = "<procpath>" + command.substr(vPaths[PROCPATH].length());
7011
7012 while (command.front() == '/')
7013 command.erase(0, 1);
7014
7015 command = "window \"" + command + "\"";
7016 }
7018 command = "load \"" + command + "\" -totable";
7019 else
7020 command = "load \"" + command + "\" -app -ignore";
7021
7022 showConsole();
7023 m_terminal->pass_command(command, false);
7024}
7025
7026
7035{
7037 return;
7038
7040
7041 try
7042 {
7043 DependencyDialog dlg(this,
7044 wxID_ANY,
7045 _guilang.get("GUI_DEPDLG_HEAD", m_book->getCurrentEditor()->GetFilenameString().ToStdString()),
7046 m_book->getCurrentEditor()->GetFileNameAndPath().ToStdString(), procLib);
7047 dlg.ShowModal();
7048 }
7049 catch (SyntaxError& e)
7050 {
7051 wxMessageBox(_guilang.get("ERR_NR_" + toString((int)e.errorcode) + "_0_*", e.getToken(), toString(e.getIndices()[0]), toString(e.getIndices()[1]), toString(e.getIndices()[2]), toString(e.getIndices()[3])), _guilang.get("ERR_NR_HEAD"), wxCENTER | wxICON_ERROR | wxOK);
7052 }
7053
7054}
7055
7056
7066void NumeReWindow::OnCreatePackage(const wxString& projectFile)
7067{
7068 try
7069 {
7072
7073 if (projectFile.length())
7074 dlg.loadProjectFile(projectFile);
7075 else if (edit->getFileType() == FILE_NPRC
7076 || (edit->getFileType() == FILE_NSCR && edit->GetFileName().GetExt() == "nlyt"))
7077 dlg.setMainFile(edit->GetFileNameAndPath());
7078
7079 if (dlg.ShowModal() == wxID_OK)
7080 {
7081 wxString installinfo = dlg.getInstallInfo();
7082 wxString identifier = dlg.getPackageIdentifier();
7083 wxArrayString procedures = dlg.getProcedures();
7084 std::string sProcPath = m_terminal->getPathSettings()[PROCPATH];
7085
7086 // Ensure that the user provided at least a single
7087 // procedure for the new package
7088 if (!procedures.size())
7089 return;
7090
7091 NewFile(FILE_NSCR, "packages/" + identifier);
7092 edit = m_book->getCurrentEditor();
7093
7094 edit->AddText("<install>\r\n" + installinfo + "\r\n");
7095
7096 for (size_t i = 0; i < procedures.size(); i++)
7097 {
7098 std::vector<std::string> contents;
7099
7100 // Get the file's contents
7101 contents = getFileForInstaller(procedures[i].ToStdString());
7102
7103 // Insert the prepared contents
7104 for (size_t j = 0; j < contents.size(); j++)
7105 {
7106 edit->AddText("\t" + contents[j] + "\r\n");
7107 }
7108
7109 edit->AddText("\r\n");
7110 }
7111
7112 if (dlg.includeDocs())
7113 {
7114 wxString template_file, dummy;
7115 GetFileContents(getProgramFolder() + "\\lang\\tmpl_documentation.nlng", template_file, dummy);
7116
7117 // Replace the tokens in the file
7118 template_file.Replace("%%IDENTIFIER%%", identifier);
7119 template_file.Replace("%%PACKAGENAME%%", dlg.getPackageName());
7120 template_file.Replace("%%IDXKEY%%", dlg.getPackageIdentifier());
7121 template_file.Replace("%%KEYWORD%%", dlg.getPackageIdentifier());
7122
7123 edit->AddText(template_file + "\r\n");
7124 }
7125 else if (dlg.getDocFile().length())
7126 {
7127 wxFile docfile(dlg.getDocFile());
7128 wxString fcontents;
7129
7130 if (docfile.ReadAll(&fcontents))
7131 edit->AddText(fcontents + "\r\n");
7132 }
7133
7134 edit->AddText("\treturn;\r\n<endinstall>\r\n");
7135 edit->AddText("\r\nwarn \"" + _guilang.get("GUI_PKGDLG_INSTALLERWARNING", identifier.ToStdString()) + "\"\r\n");
7136 edit->UpdateSyntaxHighlighting(true);
7137 edit->ApplyAutoIndentation(0, edit->GetNumberOfLines());
7138
7139 // Deactivate the indent on type in this case
7142
7143 std::string sPackageName = dlg.getPackageName().ToStdString();
7144
7145 if (wxYES == wxMessageBox(_guilang.get("GUI_PKGDLG_UPDATEINSTALLED", sPackageName),
7146 _guilang.get("GUI_PKGDLG_UPDATEINSTALLED_HEAD"), wxYES_NO | wxICON_QUESTION, this))
7147 {
7148 std::string sPackage = installinfo.ToStdString();
7149 replaceAll(sPackage, "\r\n", " ");
7150 replaceAll(sPackage, "\t", " ");
7151 replaceAll(sPackage, "<info>", "");
7152 replaceAll(sPackage, "<endinfo>", "");
7153
7154 m_terminal->updatePackage(sPackage);
7155 }
7156
7157 // Check, whether this package is already installed and
7158 // ask the user to synchronize the package versions
7159 //const std::vector<Package>& vPackages = m_terminal->getInstalledPackages();
7160 //std::string sPackageName = dlg.getPackageName().ToStdString();
7161 //
7162 //for (const auto& package : vPackages)
7163 //{
7164 // if (package.getName() == sPackageName)
7165 // {
7166 // size_t nInstalledVersion = versionToInt(package.sVersion);
7167 //
7168 // // Compare the installed version with the currently
7169 // // packed version and ask the user, whether we shall
7170 // // synchronize those two
7171 // if (nInstalledVersion < versionToInt(dlg.getPackageVersion().ToStdString())
7172 // && wxYES == wxMessageBox(_guilang.get("GUI_PKGDLG_UPDATEINSTALLED", sPackageName),
7173 // _guilang.get("GUI_PKGDLG_UPDATEINSTALLED_HEAD"), wxYES_NO | wxICON_QUESTION, this))
7174 // {
7175 // std::string sPackage = installinfo.ToStdString();
7176 // replaceAll(sPackage, "\r\n", " ");
7177 // replaceAll(sPackage, "\t", " ");
7178 // replaceAll(sPackage, "<info>", "");
7179 // replaceAll(sPackage, "<endinfo>", "");
7180 //
7181 // m_terminal->updatePackage(sPackage);
7182 // }
7183 //
7184 // break;
7185 // }
7186 //}
7187 }
7188 }
7189 catch (SyntaxError& e)
7190 {
7191 wxMessageBox(_guilang.get("ERR_NR_" + toString((int)e.errorcode) + "_0_*", e.getToken(), toString(e.getIndices()[0]), toString(e.getIndices()[1]), toString(e.getIndices()[2]), toString(e.getIndices()[3])),
7192 _guilang.get("ERR_NR_HEAD"),
7193 wxCENTER | wxICON_ERROR | wxOK);
7194 }
7195}
7196
7197
7206{
7207 // Search first file
7208 std::string file1 = wxFileSelector(_guilang.get("GUI_DLG_COMPARE_FILE_1"), "", wxEmptyString, wxEmptyString,
7209 wxFileSelectorDefaultWildcardStr, wxFD_OPEN | wxFD_FILE_MUST_EXIST, this).ToStdString();
7210
7211 // Abort, if the user clicked cancel
7212 if (!file1.length())
7213 return;
7214
7215 // Search second file
7216 std::string file2 = wxFileSelector(_guilang.get("GUI_DLG_COMPARE_FILE_1"), "", wxEmptyString, wxEmptyString,
7217 wxFileSelectorDefaultWildcardStr, wxFD_OPEN | wxFD_FILE_MUST_EXIST, this).ToStdString();
7218
7219 // Abort, if the user clicked cancel
7220 if (!file2.length())
7221 return;
7222
7223 // Calculate the unified diff of both files
7224 std::string diff = compareFiles(file1, file2);
7225
7226 wxFileName fn1(file1);
7227 wxFileName fn2(file2);
7228
7229 // Show the calculated diff with the names of both files
7230 // as "file name"
7231 ShowRevision(fn1.GetName() + "." + fn1.GetExt() + "-" + fn2.GetName() + "." + fn2.GetExt() + ".diff", diff);
7232}
7233
7234
7244{
7245 if (m_book->getFocusedEditor()->HasSelection())
7246 m_findData.SetFindString(m_book->getFocusedEditor()->GetSelectedText());
7247
7248 if (g_findReplace != nullptr)
7249 {
7250 bool isReplaceDialog = g_findReplace->GetWindowStyle() & wxFR_REPLACEDIALOG;
7251
7252 if ((isReplaceDialog && (id == ID_MENU_REPLACE)) || (!isReplaceDialog && (id == ID_MENU_FIND)))
7253 return;
7254 else
7255 delete g_findReplace;
7256 }
7257 else
7258 m_findData.SetFlags(wxFR_DOWN | wxFR_WRAPAROUND);
7259
7260 bool showFind = (id == ID_MENU_FIND);
7261 int dialogFlags = showFind ? 0 : wxFR_REPLACEDIALOG;
7262 wxString title = showFind ? _guilang.get("GUI_DLG_FIND") : _guilang.get("GUI_DLG_REPLACE");
7263
7264 g_findReplace = new FindReplaceDialog(this, &m_findData, title, dialogFlags);
7265 g_findReplace->Show(true);
7267}
7268
7269
7279{
7282
7283 int result = m_optionsDialog->ShowModal();
7284
7285 if (result == wxID_OK)
7286 {
7292
7293 m_splitEditorOutput->SetCharHeigth(m_terminal->GetCharHeight());
7297
7299 m_termContainer->Refresh();
7300
7301 for (size_t i = 0; i < m_book->GetPageCount(); i++)
7302 {
7303 NumeReEditor* edit = m_book->getEditor(i); // Might need adaption
7304 edit->UpdateSyntaxHighlighting(true);
7306
7307 if (m_book->getEditor(i, true))
7308 {
7309 edit = m_book->getEditor(i, true);
7310 edit->UpdateSyntaxHighlighting(true);
7312 }
7313 }
7314 }
7315
7316 m_book->getCurrentEditor()->SetFocus();
7317}
7318
7319
7328{
7329 m_book->getCurrentEditor()->SetPrintColourMode(m_options->GetPrintStyle());
7330
7331 if (!g_printData->IsOk())
7332 this->OnPrintSetup();
7333
7334 wxPrintDialogData printDialogData( *g_printData);
7335 wxPrinter printer (&printDialogData);
7337
7338 if (!printer.Print (this, &printout, true))
7339 {
7340 if (wxPrinter::GetLastError() == wxPRINTER_ERROR)
7341 {
7342 wxMessageBox (_guilang.get("GUI_PRINT_ERROR"), _guilang.get("GUI_PRINT_ERROR_HEAD"), wxOK | wxICON_WARNING);
7343 return;
7344 }
7345 }
7346
7347 (*g_printData) = printer.GetPrintDialogData().GetPrintData();
7348}
7349
7350
7360{
7361 m_book->getCurrentEditor()->SetPrintColourMode(m_options->GetPrintStyle());
7362
7363 if (!g_printData->IsOk())
7364 this->OnPrintSetup();
7365
7366 wxPrintDialogData printDialogData( *g_printData);
7367 wxPrintPreview *preview = new wxPrintPreview(new NumeRePrintout(m_book->getCurrentEditor(), m_options),
7369 &printDialogData);
7370
7371 if (!preview->Ok())
7372 {
7373 delete preview;
7374 wxMessageBox (_guilang.get("GUI_PREVIEW_ERROR"), _guilang.get("GUI_PREVIEW_ERROR_HEAD"), wxOK | wxICON_WARNING);
7375 return;
7376 }
7377
7378 wxRect rect = DeterminePrintSize();
7379 wxPreviewFrame *frame = new wxPreviewFrame (preview, this, _guilang.get("GUI_PREVIEW_HEAD"));
7380 frame->SetSize (rect);
7381 frame->Centre(wxBOTH);
7382 frame->Initialize();
7383 frame->Show(true);
7384 frame->Maximize();
7385}
7386
7387
7396{
7397 (*g_pageSetupData) = *g_printData;
7398 wxPageSetupDialog pageSetupDialog(this, g_pageSetupData);
7399 pageSetupDialog.ShowModal();
7400 (*g_printData) = pageSetupDialog.GetPageSetupData().GetPrintData();
7401 (*g_pageSetupData) = pageSetupDialog.GetPageSetupData();
7402}
7403
7404
7414{
7415 // Create a list of possible file types
7416 wxArrayString choices;
7417 choices.Add(_guilang.get("GUI_MENU_NEW_EMPTYFILE"));
7418 choices.Add(_guilang.get("GUI_MENU_NEW_NSCR"));
7419 choices.Add(_guilang.get("GUI_MENU_NEW_NPRC"));
7420 choices.Add(_guilang.get("GUI_MENU_NEW_PLUGIN"));
7421 choices.Add(_guilang.get("GUI_MENU_NEW_LAYOUT"));
7422
7423 // Remove obsolete menu string items
7424 for (size_t i = 0; i < choices.size(); i++)
7425 {
7426 if (choices[i].find('\t') != std::string::npos)
7427 choices[i].erase(choices[i].find('\t'));
7428
7429 if (choices[i].find('&') != std::string::npos)
7430 choices[i].erase(choices[i].find('&'), 1);
7431 }
7432
7433 wxSingleChoiceDialog dialog(this, _guilang.get("GUI_TB_NEW_SELECT"), "NumeRe: " + _guilang.get("GUI_TB_NEW"), choices);
7434 dialog.SetIcon(getStandardIcon());
7435 int ret = dialog.ShowModal();
7436
7437 if (ret != wxID_CANCEL)
7438 {
7439 switch (dialog.GetSelection())
7440 {
7441 case 0:
7442 NewFile();
7443 break;
7444 case 1:
7446 break;
7447 case 2:
7449 break;
7450 case 3:
7452 break;
7453 case 4:
7455 break;
7456 }
7457 }
7458}
7459
7460
7469{
7470 ShowHelp("numere");
7471}
7472
7473
7482bool NumeReWindow::ShowHelp(const wxString& sDocId)
7483{
7484 DocumentationBrowser* browser = new DocumentationBrowser(this, _guilang.get("DOC_HELP_HEADLINE", "%s"), this);
7485 registerWindow(browser, WT_DOCVIEWER);
7486 return browser->SetStartPage(sDocId);
7487}
7488
7489
7498{
7499 AboutChameleonDialog acd(this, 10000, _guilang.get("GUI_ABOUT_TITLE"));
7500 acd.ShowModal();
7501}
7502
static wxRect determineWindowSize(std::string &sWinSize)
Static helper function to determine the window size and position if necessary.
std::string removeMaskedStrings(const std::string &sString)
This function removes the escape characters from the passed string.
std::string removeQuotationMarks(const std::string &)
This function simply removes the surrounding quotation marks.
double g_pixelScale
Language _guilang
wxPageSetupData * g_pageSetupData
FindReplaceDialog * g_findReplace
static std::vector< std::string > tokenize(std::string sKeyList)
Static helper function to tokenize the whitespace-separated list of keys.
wxPrintData * g_printData
global print data, to remember settings during the session
std::string prepareStringsForDialog(const std::string &sString)
const std::string sVersion
#define OPENFILE_FORCE
Definition: NumeReWindow.h:45
#define OPENFILE_BLACKLIST_ADD
Definition: NumeReWindow.h:43
#define OPENFILE_BLACKLIST_REMOVE
Definition: NumeReWindow.h:44
#define wxSTC_PRINT_BLACKONWHITE
Definition: Options.h:16
#define wxSTC_PRINT_COLOURONWHITE
Definition: Options.h:19
std::string toLowerCase(const std::string &)
Converts uppercase to lowercase letters.
This class represents a window, which can be created by the user during run-time by using a layout sc...
This is the implementation of the DDE client of any secondary NumeRe instances.
Definition: ipc.hpp:72
This class is an implementation of a DDE connection between DDE::Client and DDE::Server.
Definition: ipc.hpp:54
This class implements the DDE server for the first (main) NumeRe instance.
Definition: ipc.hpp:38
void OnExecutionFinished()
This member function will inform the debugger window that the execution of the current code has ben f...
void setDebugInfo(const wxString &title, const std::vector< std::string > &vStack)
This member function is used from the main window to update the debugger window with the information ...
void updateSettings()
This member function should be called after the user modified the application settings....
void setTerminal(NumeReTerminal *term)
Definition: debugviewer.hpp:60
This class represents a dialog showing the dependencies of a selected procedure file.
void push_info(const std::string &sInfo)
Push a message to the logger, which is not dependend on the logging level and will be shown without a...
Definition: logger.cpp:276
void info(const std::string &sMessage)
Convenience member function.
Definition: logger.hpp:106
void warning(const std::string &sMessage)
Convenience member function.
Definition: logger.hpp:130
void debug(const std::string &sMessage)
Convenience member function.
Definition: logger.hpp:94
void error(const std::string &sMessage)
Convenience member function.
Definition: logger.hpp:142
void setLoggingLevel(Logger::LogLevel lvl)
Change the logging level or completely disable the logger.
Definition: logger.cpp:261
void write_system_information()
A helper function to write the current OS's information to the log file.
Definition: logger.cpp:292
This represents the main frame of the documentation browser, which contains the tabbed layout,...
bool SetStartPage(const wxString &docId)
Public interface to set the start page.
This class handles the creation of LaTeX documentation from code files. It will detect documentation ...
Definition: docgen.hpp:41
std::string createDocumentation(const std::string &sFileName) const
This member function creates a LaTeX documentation from a single file and stores it....
Definition: docgen.cpp:973
std::string createFullDocumentation(const std::string &sFileName) const
This member function creates a LaTeX documentation from the passed file and all dependent files....
Definition: docgen.cpp:994
This class represents the notebook containing all editors of one main pane.
void SetTabText(size_t nTab, const wxString &text)
Set a text for the selected editor tab. Note that this function expects a filepath.
void split(size_t pageNum, bool horizontal)
Split the current editor horizontally or vertically (depending on the flag), if it is not already spl...
void SetShowPathsOrIconsOnTabs(bool showText, bool showIcons)
This member function enables/disables the relative paths or icons on the tab and refreshes the tab te...
NumeReEditor * getEditor(size_t pageNum, bool secondary=false)
Returns a pointer to the embedded editor instance. Will return the left or top editor pointer or the ...
void unsplit(size_t pageNum)
Remove the splitted view.
NumeReEditor * createEditor(const wxString &text)
Create a new editor and add it to a new tab automatically. The passed text is used for the tab name.
NumeReEditor * getCurrentEditor(bool secondary=false)
Returns a pointer to the current viewed editor in this notebook. Will return the left or top editor o...
void SetTopParent(NumeReWindow *window)
NumeReEditor * getFocusedEditor()
Returns a pointer to the current focused editor. This will automatically return the secondary editor,...
This class extends the std::vector for endlessness.
Definition: structures.hpp:838
This class provides the needed functionalities for the file tree and the symbols tree.
Definition: treedata.hpp:42
wxString filename
Definition: treedata.hpp:50
This class implements the basic input/ output file system and provides functionalities to work with f...
Definition: filesystem.hpp:92
std::string ValidFileName(std::string _sFileName, const std::string sExtension=".dat", bool checkExtension=true, bool doCleanPath=true) const
This member function evaluates, whether the passed filename is a valid filename. One may supply a pre...
Definition: filesystem.cpp:280
void setTokens(std::string _sTokens)
This member function may be used to update the path placeholders of the current FileSystem instance.
Definition: filesystem.cpp:694
int setPath(std::string _sPath, bool bMkDir, std::string _sExePath)
This member function may be used to set the preferred file path of the current FileSystem instance.
Definition: filesystem.cpp:443
bool Remove(const wxFileName &path)
Definition: filewatcher.cpp:68
bool Add(const wxFileName &path, int events=wxFSW_EVENT_ALL)
Definition: filewatcher.cpp:50
bool SetDefaultPaths(const std::vector< std::string > &vPaths)
Definition: filewatcher.cpp:34
void set_mode_flag(int flag)
Sets a mode flag (only used to make the cursor invisble).
Definition: utils.cpp:320
NumeReSyntax * getSyntax()
Definition: gterm.hpp:145
std::string getTitle()
int GetIconIndex(wxString iconInfo)
wxImageList * GetImageList()
double getRelation() const
Definition: imagepanel.hpp:45
This class handles the internal language system and returns the language strings of the selected lang...
Definition: language.hpp:38
void addToLanguage(const std::map< std::string, std::string > &_langstrings)
This member function adds the contents of the passed language file into the internal map.
Definition: language.cpp:238
void loadStrings(bool bloadUserFiles=true)
This member function loads the language files to the internal map and replaces the named tokens with ...
Definition: language.cpp:164
std::vector< std::string > getList(const std::string &sMessageScheme) const
This member function returns a vector of language strings matching to the passed identifier containin...
Definition: language.cpp:349
std::string get(const std::string &sMessage, const std::vector< std::string > &vTokens) const
This member function returns the language string for the passed language identifier and replaces all ...
Definition: language.cpp:292
@ LVL_DEBUG
Definition: logger.hpp:53
This class represents the application controller, which will create the main frame of the actual appl...
Definition: NumeReWindow.h:151
virtual bool OnExceptionInMainLoop() override
This handler should be called, if an unhandled exception propagated through the event loop....
DDE::Server * m_DDEServer
Definition: NumeReWindow.h:160
virtual bool OnInit() override
"Main program" equivalent: the program execution "starts" here. If we detect an already instance of N...
wxSingleInstanceChecker * m_singlinst
Definition: NumeReWindow.h:159
~MyApp()
Empty destructor.
virtual int OnExit() override
Called on application shut down. Will free the memory of the IPC class instances.
This class is an implementation of a database. It will handle the *.ndb data format an provides an in...
Definition: database.hpp:37
std::vector< std::string > getColumn(size_t j) const
This member function will return the whole selected column of the database as a vector<string>....
Definition: database.cpp:265
void addData(const std::string &sDataBaseFile)
This member function will use the passed database file name to update its internal contents (i....
Definition: database.cpp:212
This data container is a copy- efficient table to interchange data between Kernel and GUI.
Definition: table.hpp:87
This class represents an abstract window handled by the window manager.
void updateWindowInformation(int status, const std::string &_return)
This public member function can be used to update the stored window information in the window manager...
GraphHelper * getGraph()
WindowType getType() const
const WindowSettings & getWindowSettings() const
The class of the editor window.
Definition: editor.h:53
void sortSelection(bool ascending=true)
Sorts the lines de- or ascending.
Definition: editor.cpp:2425
void AddProcedureDocumentation()
This member function handles the creation of documentation blocks in front of procedure heads.
Definition: editor.cpp:7529
void OnTranspose()
On MenuEvent handler for the transpose functionality of the editor.
Definition: editor.cpp:6871
void SetEditorFont(const wxFont &font)
Changes the editor's font face.
Definition: editor.cpp:2802
void SetUnsaved()
Marks the editor as modified.
Definition: editor.cpp:3556
int getSettings()
Definition: editor.h:232
void ToggleSettings(int _setting)
Enables or disables an editor setting.
Definition: editor.cpp:2835
void OnClearBreakpoints(wxCommandEvent &event)
Definition: editor.cpp:5219
void ApplyAutoIndentation(int nFirstLine=0, int nLastLine=-1)
Wrapper for CodeFormatter.
Definition: editor.cpp:8230
void FindAndOpenProcedure(const wxString &procedurename)
Finds the procedure definition and displays it in the editor.
Definition: editor.cpp:5461
wxString GetFilenameString()
Definition: editor.cpp:4314
bool LoadFileText(wxString fileContents)
Definition: editor.cpp:576
bool SaveFile(const wxString &filename)
Definition: editor.cpp:396
bool InitDuplicateCode()
Displays the duplicated code dialog.
Definition: editor.cpp:6965
void ResetEditor()
Definition: editor.cpp:4356
void MoveSelection(bool down=true)
Definition: editor.h:251
void OnRemoveBreakpoint(wxCommandEvent &event)
Definition: editor.cpp:5201
bool getEditorSetting(EditorSettings _setting)
Returns true, if the selected setting is active.
Definition: editor.cpp:2819
bool Modified()
Returns whether the current file was modified after the last time saved.
Definition: editor.cpp:634
void FoldAll()
Folds all fold markers.
Definition: editor.cpp:2207
void OnExtractFormatted()
On MenuEvent handler for the extract as formatted text functionality of the editor.
Definition: editor.cpp:6929
wxFileName GetFileName()
Definition: editor.cpp:4328
void OnFindIncludeFromMenu()
Global event handler function for finding the included script.
Definition: editor.cpp:6684
void toggleBookmark()
Toggles a bookmark marker on the current line.
Definition: editor.cpp:2391
void ApplyAutoFormat(int nFirstLine=0, int nLastLine=-1)
Wrapper for CodeFormatter.
Definition: editor.cpp:8579
void JumpToBookmark(bool down=true)
Jumps the cursor to the next bookmark in the current file.
Definition: editor.cpp:2242
void AdvCallTipCancel()
Simply closes the calltip and resets its associated variables.
Definition: editor.cpp:1282
@ SETTING_DISPCTRLCHARS
Definition: editor.h:70
@ SETTING_WRAPEOL
Definition: editor.h:69
@ SETTING_USETXTADV
Definition: editor.h:71
@ SETTING_USESECTIONS
Definition: editor.h:74
@ SETTING_USEANALYZER
Definition: editor.h:72
@ SETTING_INDENTONTYPE
Definition: editor.h:73
bool HasBeenSaved()
Definition: editor.cpp:3543
void OnFindProcedureFromMenu()
Global event handler function for finding the procedure definition.
Definition: editor.cpp:6650
void OnExtractAsHTML()
On MenuEvent handler for the extract as HTML functionality of the editor.
Definition: editor.cpp:6897
void OnAddBreakpoint(wxCommandEvent &event)
Definition: editor.cpp:5179
void removeWhiteSpaces(int nType=RM_WS_BOTH)
Removes whitespaces depending on the passed type.
Definition: editor.cpp:2335
void UnfoldAll()
Unfolds all fold markers.
Definition: editor.cpp:2223
FileFilterType getFileType()
Definition: editor.h:290
void ToggleCommentLine()
Toggles a line comment.
Definition: editor.cpp:1968
void SetFilename(wxFileName filename, bool fileIsRemote)
Definition: editor.cpp:4246
void OnAbstrahizeSectionFromMenu()
Global event handler for extracting the selected section.
Definition: editor.cpp:6833
void setBookmarks(const std::vector< int > &vBookmarks)
Set the bookmarks in the editor.
Definition: editor.cpp:2311
bool defaultPage
Definition: editor.h:76
void ToggleCommentSelection()
Toggles block comments in a selection.
Definition: editor.cpp:2096
void AnalyseCode()
Wrapper for the static code analyzer.
Definition: editor.cpp:5443
void EnsureLineVisibility(int line)
Ensures that the selected line is visible and not hidden bei either a code fold or a explicit line hi...
Definition: editor.cpp:5367
void OnRenameSymbolsFromMenu()
Global wrapper for RenameSymbols.
Definition: editor.cpp:6790
void clearBookmarks()
Removes all bookmark markers from the current document.
Definition: editor.cpp:2409
void FocusOnLine(int linenumber, bool showMarker=true)
Definition: editor.cpp:5343
void UpdateSyntaxHighlighting(bool forceUpdate=false)
Definition: editor.cpp:3573
wxString GetFileNameAndPath()
Definition: editor.cpp:4299
void GotoPipe(int nStartPos=0)
Jumps to the predefined template caret position.
Definition: editor.cpp:5144
std::vector< int > getBookmarks()
Returns the line positions of the bookmarks.
Definition: editor.cpp:2287
void OnUnhideAllFromMenu()
Global event handling function to unhide all lines from the main frame's menu.
Definition: editor.cpp:6759
void UpdateSyntaxHighlighting(bool forceUpdate=false)
Update the syntax highlighting to represent the selected syntax colors.
Definition: history.cpp:122
void AddToHistory(const wxString &commandstring)
Add the passed string at the end of the input history.
Definition: history.cpp:453
void saveHistory()
Save the history to the corresponding file.
Definition: history.cpp:390
ProcedureLibrary & getProcedureLibrary()
Definition: kernel.hpp:321
void SetStatus(StatusField field, const wxString &sStatusText)
void setProcedureTree(const std::vector< std::string > &vTree)
Set the procedure tree (used for autocompleting).
Definition: syntax.cpp:182
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
NumeReKernel & getKernel()
Definition: terminal.hpp:192
NumeReVariables getVariableList()
This will return the variable list from the kernel to be shown in the variable viewer.
Definition: terminal.cpp:369
bool IsWorking()
Definition: terminal.hpp:276
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
void cutText()
Implements copy to clip board and deleting the selection.
Definition: terminal.cpp:1553
void EndKernelTask()
This function forces the thread to terminate so that the application may be shut down.
Definition: terminal.cpp:535
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
int getTextHeight()
Definition: terminal.hpp:130
void UpdateLibrary()
Definition: terminal.hpp:240
void copyText()
Implements copy to clip board.
Definition: terminal.cpp:1506
void pasteText()
Implements paste from clip board.
Definition: terminal.cpp:1528
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
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
void UpdateColors()
This member function sets the new colors to the internal pen definitions.
Definition: terminal.cpp:2021
void clearBreakpoints(const std::string &_sFilename)
This member function removes all breakpoints from the passed file.
Definition: terminal.cpp:295
void UpdateSize()
Definition: terminal.cpp:1953
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
std::string getDocumentation(const std::string &sCommand)
Gets the desired documentation article as a HTML string.
Definition: terminal.cpp:310
void SetParent(NumeReWindow *frame)
Definition: terminal.hpp:125
virtual void ProcessInput(int len, const std::string &sData) override
Processes text received from the keybord or clipboard.
Definition: terminal.cpp:2118
void setKernelSettings(const Settings &)
This will pass the new kernel settings to the kernel.
Definition: terminal.cpp:399
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
std::vector< std::string > getPathSettings()
Returns the standard paths as a STL vector.
Definition: terminal.cpp:185
bool SetFont(const wxFont &font)
Definition: terminal.cpp:746
This class is the actual NumeRe main frame. The application's logic is implemented here.
Definition: NumeReWindow.h:177
wxString m_filterNPRCFiles
Definition: NumeReWindow.h:471
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 OnStatusTimer(wxTimerEvent &event)
std::vector< std::string > GetDocIndex()
This member function returns the documentation index as a vector.
void EvaluateTab()
This member function executes the contents of the editor page connected to the selected tab.
EditorNotebook * m_book
Definition: NumeReWindow.h:374
void AddToHistory(const wxString &sCommand)
This function is a wrapper for the corresponding function from the history widget and stores the pass...
void OnPrintPreview()
This member function displays the styled text of the current editor in the print preview window.
void LoadFilesToTree(wxString fromPath, FileFilterType fileType, wxTreeItemId treeid)
This member function loads the file details to the file tree.
void deleteFile()
This member function moves the selected file from the file tree directly to the Windows trash bin,...
void OnPageChange(wxAuiNotebookEvent &event)
void Test(wxCommandEvent &event)
void addToReloadBlackList(const wxString &sFilename)
This member function adds the passed file name to the list of files, which shall not be reloaded auto...
void OnShowRevisions()
This method displays the revision dialog for the selected tree item.
wxString m_filterSupportedFiles
Definition: NumeReWindow.h:480
void unregisterWindow(wxWindow *window)
Removes the passed window form the internal window list (only if it exists).
void NewFile(FileFilterType _filetype=FILE_NONSOURCE, const wxString &defaultfilename="")
void OpenFileByType(const wxFileName &filename)
This member function opens the file with the passed name in the corresponding widget (either editor,...
void insertCopiedFile()
This member function copies the selected file in the file tree to the target location in the file tre...
void Ready()
This member function tells NumeRe that it shall display the "ready" state to the user.
wxString m_filterNonsource
Definition: NumeReWindow.h:479
void OnTagCurrentRevision()
This method allows the user to tag the current active revision of a file.
std::vector< wxString > vReloadBlackList
Definition: NumeReWindow.h:394
void showTable(const wxString &tableName, const wxString &tableDisplayName)
This member function is a wrapper for an event handler of the variable viewer to display the contents...
wxTreeItemId m_copiedTreeItem
Definition: NumeReWindow.h:438
void CloseOtherTabs()
This member function closes all other editor tabs except of the current selected one.
void UpdatePackageMenu()
Updates the package menu after an installation.
void OnCopyAsPath()
The member function copies the path of the selected tree item to the clipboard, so that it can be ins...
void showConsole()
This member function unhides the terminal, if it was hidden before.
MyTipProvider * tipProvider
Definition: NumeReWindow.h:214
void CreateProcedureTree(const std::string &sProcedurePath)
This member function finds every procedure in the default search path and adds them to the syntax aut...
bool GetFileContents(wxString fileToLoad, wxString &fileContents, wxString &fileName)
wxString getTreePath(const wxTreeItemId &itemId)
This member function returns the paths connected to a specific file or directory in the file tree.
wxRect DeterminePrintSize()
void OnRemoveFolder()
This member function moves the selected directory directly to the Windows trash bin,...
wxString m_filterNumeReFiles
Definition: NumeReWindow.h:473
void PassImageList(wxImageList *imagelist)
void OnOpenInExplorer()
This member function uses the Windows shell to open the selected folder in the Windows explorer.
void UpdateTerminalNotebook()
void OnUpdateSaveUI()
wxString ConstructFilterString(FileFilterType filterType)
void SetIntVar(int variableName, int value)
bool m_appStarting
Definition: NumeReWindow.h:460
wxString m_filterNLYTFiles
Definition: NumeReWindow.h:472
bool m_setSelection
Definition: NumeReWindow.h:458
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 FindAndOpenProcedure(const wxString &procedureName)
Wrapper for the corresponding function of the editor.
void UpdateToolbar()
void OnTreeItemActivated(wxTreeEvent &event)
void showWindow(NumeRe::Window &window)
This public member function handles the creation of windows requested by the kernel.
void OnPluginMenuEvent(wxCommandEvent &event)
Handles events, which originate from package menu (i.e. graphical plugins).
void OnOpenSourceFile(int id)
This member function opens a file dialog to let the user choose the files to open in the editor.
void Busy()
This member function tells NumeRe that it shall display the "busy" state to the user.
void runLaTeX()
This member function creates the LaTeX documentation files and uses the Windows shell to run the XeLa...
void UpdateStatusBar()
void notifyInstallationDone()
Notifies all instances of the PackagRepoBrowser to refresh its internal list of installed packages an...
std::vector< std::string > getPathDefs()
This member function returns the standard path definitions as a vector.
TreePanel * m_filePanel
Definition: NumeReWindow.h:390
void compileLaTeX()
This function runs the XeLaTeX compiler on the TeX source in the current editor (if it is a TeX sourc...
bool ShowHelp(const wxString &sDocId)
This member function displays the help page for the selected documentation ID.
wxString m_filterTeXSource
Definition: NumeReWindow.h:478
ViewerBook * m_noteTerm
Definition: NumeReWindow.h:376
void openImage(wxFileName filename)
This member function opens the selected image in the image viewer window.
IconManager * m_iconManager
Definition: NumeReWindow.h:445
wxTreeItemId m_dragDropSourceItem
Definition: NumeReWindow.h:441
void forceHistoryPageDown()
This member function is a simple helper to force that the history displays the last line at start-up.
void OpenSourceFile(wxArrayString fnames, unsigned int nLine=0, int nOpenFileFlag=OPENFILE_NOTHING)
Opens the given list of source files in the editor.
ProcedureViewer * m_procedureViewer
Definition: NumeReWindow.h:384
void removeFromReloadBlackList(const wxString &sFilename)
This member function removes the passed file name from the list of files, which shall not be reloaded...
FileTree * m_functionTree
Definition: NumeReWindow.h:397
wxLogWindow * logWindow
Definition: NumeReWindow.h:370
wxString m_filterImageFiles
Definition: NumeReWindow.h:476
void OnTreeDragDrop(wxTreeEvent &event)
This member function prepares the data to be dragged from one of the both trees.
std::map< wxWindow *, WindowType > m_openedWindows
Definition: NumeReWindow.h:466
void OnFindReplace(int id)
This member function displays the find and replace dialog.
void OnAskForNewFile()
This member function catches the new file toolbar button and asks the user for a specific file type.
void ShowRevision(const wxString &revisionName, const wxString &revisionContent)
This member function creates a new editor page and copies the passed revision contents to this page.
std::string m_UnrecoverableFiles
Definition: NumeReWindow.h:226
void setViewerFocus()
This member function focuses the last opened ImageViewer window.
int CopyEditorSettings(FileFilterType _fileType)
This member function returns the settings from the current editor for the passed FileFilterType.
void OnShowRevisionsFromTab()
This method displays the revision dialog for the selected tab item.
void InitializeProgramOptions()
This member function loads the configuration file available for the graphical user interface.
TreePanel * m_functionPanel
Definition: NumeReWindow.h:391
bool m_sessionSaved
Definition: NumeReWindow.h:457
void showListDialog(NumeRe::Window &window)
This private member function shows a list dialog.
void prepareFunctionTree()
This member function creates the contents of the symbols tree.
std::vector< std::string > getFileForInstaller(const std::string &sLayoutFileName)
This member function obtains the contents of a file and transforms it to be used by an installer scri...
wxTreeItemId m_projectFileFolders[5]
Definition: NumeReWindow.h:434
NumeReWindow(const wxString &title, const wxPoint &pos, const wxSize &size)
NumeReEditor * GetCurrentEditor()
Public access method for accessing the currently viewed editor. Does only return a pointer to the top...
std::map< size_t, std::string > m_pluginMenuMap
Definition: NumeReWindow.h:467
void PageHasChanged(int pageNr=-1)
int ReplaceAllStrings(const wxString &findString, const wxString &replaceString, int flags=-1)
void OnTreeItemRightClick(wxTreeEvent &event)
void prepareSession()
This member function recreates the last session by reading the session file or creates a new empty se...
std::map< wxString, __time64_t > m_filesLastSaveTime
Definition: NumeReWindow.h:482
void showGraph(NumeRe::Window &window)
This private member function displays a graph.
void updateTipAtStartupSetting(bool bTipAtStartup)
This function can be used to deactivate the "Tip of the day" functionality directly from the dialog.
VariableViewer * m_varViewer
Definition: NumeReWindow.h:383
bool m_loadingFilesDuringStartup
Definition: NumeReWindow.h:463
ProportionalSplitterWindow * m_splitCommandHistory
Definition: NumeReWindow.h:404
void OnCompareFiles()
Event handler for comparing two files using the diff functionalities.
FileTree * m_fileTree
Definition: NumeReWindow.h:388
wxIcon getStandardIcon()
This public member function returns the default icon usable by different windows.
bool CloseAllFiles()
void showFileDialog(NumeRe::Window &window)
This private member function displays a file dialog.
wxTreeItemId getDragDropSourceItem()
This member function gets the drag-drop source item, if the source was the file tree.
ProportionalSplitterWindow * m_splitEditorOutput
Definition: NumeReWindow.h:402
void EvaluateCommandLine(wxArrayString &wxArgV)
This member function evaluates the command line passed to this application at startup and evaluates,...
void OnExecuteFile(const std::string &sFileName, int id)
This function executes the file in the current editor.
void UpdateVarViewer()
This member function gets the current variable list from the kernel and updates the variable viewer w...
wxString m_filterDataFiles
Definition: NumeReWindow.h:475
void toggleConsole()
This member function toggles the bottom part of the window containing the terminal and the list view ...
void OnClose(wxCloseEvent &event)
void OnTreeItemToolTip(wxTreeEvent &event)
This member function displays the tooltip requested for the item below the mouse cursor.
void OpenFilesFromList(const wxArrayString &filenameslist)
This member function opens a list of files depending on their type in the correct widget.
Options * getOptions()
Definition: NumeReWindow.h:245
wxString getFileDetails(const wxFileName &filename)
This member function displays extended file informations of NDAT files, if this was enabled in the se...
bool isOnReloadBlackList(wxString sFilename)
This member function returns true, if the passed file name is currently part of the list of files,...
void OnOptions()
This member function displays the settings dialog and performs all necessary updates,...
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 OnIdle(wxIdleEvent &event)
void OnFileEventTimer(wxTimerEvent &event)
This member function handles the events from the file event timer.
void OnCalculateDependencies()
This member function runs the dependency calculating process in the procedure library.
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...
int * SelectIntVar(int variableName)
wxString m_filterExecutableFiles
Definition: NumeReWindow.h:474
wxSplitterWindow * m_splitProjectEditor
Definition: NumeReWindow.h:406
int GetPageNum(wxFileName fn, bool compareWholePath=true, int startingTab=0)
void OpenContainingFolder()
This member function uses the Windows shell to open the containing folder of the selected tab in the ...
OptionsDialog * m_optionsDialog
Definition: NumeReWindow.h:424
wxTreeItemId m_clickedTreeItem
Definition: NumeReWindow.h:436
NumeReStatusbar * m_statusBar
Definition: NumeReWindow.h:399
void renameFile()
This member function renames the selected file in the file tree with a new name provided by the user ...
Filewatcher * m_watcher
Definition: NumeReWindow.h:389
void DefaultPage()
This member function creates a new editor page and copies the contents of the default page template t...
void toggleFiletree()
This member function toggles the left sidebar of the window containing both trees.
std::map< int, wxMenuItem * > m_menuItems
Definition: NumeReWindow.h:464
void pass_command(const wxString &command, bool isEvent=false)
This member function is a wrapper for the corresponding terminal function to pass a command to the ke...
ViewerFrame * m_currentView
Definition: NumeReWindow.h:386
void OnSplitterDoubleClick(wxSplitterEvent &event)
wxTimer * m_updateTimer
Definition: NumeReWindow.h:427
void OnSaveSourceFile(int id)
This member function saves the file in the current editor.
void showSelectionDialog(NumeRe::Window &window)
This private member function shows a selection dialog.
int GetIntVar(int variableName)
wxFindReplaceData m_findData
Definition: NumeReWindow.h:431
void toggleHistory()
This member function toggles the rightmost part of the lower window section containing the history an...
void OnPrintPage()
This member function prints the styled text of the current editor.
void UpdateMenuBar()
void ToolbarStatusUpdate()
NumeReHistory * m_history
Definition: NumeReWindow.h:382
void OnFindEvent(wxFindDialogEvent &event)
void createLaTeXFile()
This member function uses the parsed contents from the current editor to create a new LaTeX file from...
wxString m_filterAllFiles
Definition: NumeReWindow.h:477
wxString getTreeFolderPath(const wxTreeItemId &itemId)
This member function returns the paths connected to a specific directory in the file tree.
NumeReTerminal * m_terminal
Definition: NumeReWindow.h:416
void CloseFile(int pageNr=-1, bool askforsave=true)
Closes a given editor, based on its index in the editor notebook.
DebugViewer * m_debugViewer
Definition: NumeReWindow.h:444
void setEditorFocus()
This member function focuses the editor widget.
void showDirDialog(NumeRe::Window &window)
This private member function displays a directory dialog.
wxPrintData * setDefaultPrinterSettings()
This member function sets the default printer settings.
int HandleModifiedFile(int pageNr, ModifiedFileAction fileAction)
Handle user interaction when closing or reloading an editor.
Options * m_options
Definition: NumeReWindow.h:443
void openPDF(wxFileName filename)
This member function opens a PDF document using the windows shell.
void gotoLine()
This member function opens a text entry dialog, where the user can enter the target line number,...
wxTimer * m_fileEventTimer
Definition: NumeReWindow.h:428
void OnPrintSetup()
This member function displays the printing page setup dialog.
void refreshFunctionTree()
This member function is a simple wrapper for refreshing the contents of the function tree.
void reloadFileIfOpen(const wxString &fname, bool force=false)
Reloads a file if it is open in any editor.
wxString getProgramFolder()
This member function returns the application's root path.
void UpdateWindowTitle(const wxString &filename)
This member function updates the application's window title using the current opened file's name.
void OnMenuEvent(wxCommandEvent &event)
void OnCreatePackage(const wxString &projectFile)
This member function launches the package creator dialog and creates the install file,...
void showMessageBox(NumeRe::Window &window)
This private member function displays a message box.
int FindString(const wxString &findString, int start_pos=-1, int flags=-1, bool highlight=TRUE)
void registerWindow(wxWindow *window, WindowType type)
Registers a new window in the internal map.
bool SaveAll(bool refreshLibrary)
Saves all currently opened files to the harddisk.
wxArrayString OpenFile(FileFilterType filterType)
bool m_multiRowState
Definition: NumeReWindow.h:462
void OnAbout()
This member function displays the "About" dialog.
void OnHelp()
This member function displays the help root page.
wxString GetDocContent(wxString docid)
This member function returns the HTML string containing the documentation for the selected topic/doc ...
ViewerBook * m_treeBook
Definition: NumeReWindow.h:378
void OnFileSystemEvent(wxFileSystemWatcherEvent &event)
This member function handles all events, which result from changes in the file system.
bool showTipAtStartup
Definition: NumeReWindow.h:215
bool SaveTab(int tab)
Saves the file in the selected editor tab.
bool SaveCurrentFile(bool saveas)
Saves the current opened file.
void OnCreateNewFolder()
This member function creates a new folder below the currently selected folder. The name is supplied b...
wxString m_filterNSCRFiles
Definition: NumeReWindow.h:470
wxTermContainer * m_termContainer
Definition: NumeReWindow.h:410
void showTextEntry(NumeRe::Window &window)
This private member function displays a text entry dialog.
wxString addLinebreaks(const wxString &sLine)
This member function adds line break characters to the passed string to stick below a line length of ...
std::vector< std::pair< int, wxString > > m_modifiedFiles
Definition: NumeReWindow.h:465
void UpdateLocationIfOpen(const wxFileName &fname, const wxFileName &newFName)
Updates the editor's and notebook's filename location, if it already opened and not modified.
void CloseTab(bool force)
std::string prepareTooltip(const std::string &sTooltiptext)
This member function prepares the tooltip shown by the symbols tree.
void openHTML(wxString HTMLcontent)
This member function opens a HTML document (a documentation article) in the documentation viewer.
This class represents the settings dialog in memory.
void InitializeDialog()
This class implements an interface of the internal Settings object adapted to be usable from the GUI.
Definition: Options.h:178
static wxFont toFont(const std::string &sFontDescr)
Definition: Options.h:348
int GetPrintStyle() const
Definition: Options.h:235
wxFont GetEditorFont() const
Definition: Options.h:231
void SetEditorFont(wxFont font)
Definition: Options.h:186
@ CONSOLE_STD
Definition: Options.h:279
void readColoursFromConfig(wxFileConfig *_config)
Legacy syntax style import function from file configuration.
Definition: options.cpp:150
bool GetSaveSession() const
Definition: Options.h:245
void SetDebuggerFocusLine(int nLine)
Definition: Options.h:214
void readAnalyzerOptionsFromConfig(wxFileConfig *_config)
Legacy analyzer import function from file configuration.
Definition: options.cpp:205
int GetTerminalHistorySize() const
Definition: Options.h:253
bool GetShowToolbarText() const
Definition: Options.h:239
SyntaxStyles GetSyntaxStyle(size_t i) const
Return the selected syntax style by constructing it from the style string.
Definition: options.cpp:112
bool GetSaveBookmarksInSession() const
Definition: Options.h:247
bool GetFoldDuringLoading() const
Definition: Options.h:267
int GetCaretBlinkTime() const
Definition: Options.h:255
void SetTerminalHistorySize(int size)
Definition: Options.h:194
void SetLaTeXRoot(const wxString &root)
Definition: Options.h:208
bool GetKeepBackupFile() const
Definition: Options.h:251
void SetPrintStyle(int style)
Definition: Options.h:192
void SetCaretBlinkTime(int nTime)
Definition: Options.h:212
wxString GetLaTeXRoot() const
Definition: Options.h:237
This class represents a dialog for creating a package from a set of procedures.
wxArrayString getProcedures()
This member function will create a string array containing the procedure files, which are currently p...
void loadProjectFile(const wxString &filename)
Loads a NumeRe package project file to memory and updates the UI correspondingly.
wxString getPackageIdentifier()
This member function returns the package identifier, which is constructed from the name and only cont...
void setMainFile(const wxString &mainfile)
This function can be used to insert the current mainfile to the dialog. Used by the main window,...
wxString getInstallInfo()
This member function will create the install information section of the package based upon the setted...
bool includeDocs()
This member function returns whether the user selected the "include docs" property.
wxString getPackageName()
This member function returns the name of the package, as been set by the user.
wxString getDocFile()
Returns the user-chosen documentation file.
This class represents a simple browser for the package repository with an install and uninstall capab...
This class manages all already read and possibly pre-parsed procedure files for easier and faster acc...
void setCurrentEditor(NumeReEditor *editor)
This class represents a splitter window, which can controlled using a floating point proportion inste...
void SetCharHeigth(int _charheight)
Change the character height in pixels.
virtual bool SplitVertically(wxWindow *window1, wxWindow *window2, float proportion=0)
Split this window vertically using the selected porportion.
float GetSplitPercentage()
Return the current splitting proportion.
virtual bool SplitHorizontally(wxWindow *window1, wxWindow *window2, float proportion=0)
Split this window horizontally using the selected porportion.
void SetSashPositionFloat(float proportion)
Set the sash position using a floating point proportion.
int recycle(const char *pszPath, bool bDelete=false)
Definition: recycler.cpp:12
This class represents the dialog listing the file revisions of the current selected file.
This class manages the setting values of the internal (kernel) settings of this application.
Definition: settings.hpp:663
std::map< std::string, SettingsValue > & getSettings()
Returns a reference to the internal map of setting values.
Definition: settings.hpp:748
bool showHints() const
Returns, whether the tip-of-the-day shall be displayed to the user at application start-up.
Definition: settings.hpp:935
bool showExtendedFileInfo() const
Returns, whether the file tree or the terminal file explorer shall display extended file information ...
Definition: settings.hpp:966
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 useCustomLangFiles() const
Returns, whether user language files shall be used to override internal language strings.
Definition: settings.hpp:1161
bool useDebugger() const
Returns, whether the debugger is currently active.
Definition: settings.hpp:1150
bool isEnabled(const std::string &option) const
Returns true, if the setting with boolean value type is enabled, false otherwise. If the setting does...
Definition: settings.hpp:810
bool & active()
Returns a reference to a boolean value type setting.
Definition: settings.hpp:556
size_t & value()
Returns a reference to an unsigned int value type setting.
Definition: settings.hpp:573
std::string & stringval()
Returns a reference to a std::string value type setting.
Definition: settings.hpp:590
This class is the immutable (const) version of a string view. It can be constructed from a MutableStr...
Common exception class for all exceptions thrown in NumeRe.
Definition: error.hpp:32
std::string getToken() const
Returns the error token containing additional information about the error.
Definition: error.hpp:438
ErrorCode errorcode
Definition: error.hpp:234
const int * getIndices() const
Returns a pointer to the internal array of 4 error indices.
Definition: error.hpp:458
A table panel with editing functionalities. Creates APPLY and CANCEL buttons and provides their event...
Generic table panel, which also contains all meta UI elements.
void SetTerminal(NumeReTerminal *term)
TableViewer * grid
This class is an adaption of the wxGrid class to present the tabular data in NumeRe's memory and enab...
Definition: tableviewer.hpp:42
void SetData(NumeRe::Container< std::string > &_stringTable, const std::string &sName, const std::string &sIntName)
This member function is the data setter for string and cluster tables.
size_t GetHeight()
size_t GetWidth()
This class specializes the generic search control to be placed in the toolbar and to use the internal...
wxString tooltip
Definition: treedata.hpp:30
void AddWindows(wxWindow *searchbar, wxWindow *tree)
Definition: treepanel.hpp:31
This class specializes the generic search control to interact with a wxTreeCtrl.
void UpdateVariables(const std::vector< std::string > &vVarList, size_t nNumerics, size_t nStrings, size_t nTables, size_t nClusters, size_t nArguments=0, size_t nGlobals=0)
This member function is used to update the variable list, which is displayed by this control.
bool hasRevisions(const wxString &currentFile)
This method detects, whether the selected file has revisions.
Definition: vcsmanager.cpp:90
wxString getRevisionPath(const wxString &currentFilePath)
This method returns the path, where the revisions are stored.
Definition: vcsmanager.cpp:39
FileRevisions * getRevisions(const wxString &currentFile)
This method returns the file revisions as pointer.
Definition: vcsmanager.cpp:68
This class generalizes a set of basic floating window functionalities like being closable by pressing...
Definition: viewerframe.hpp:31
Error class of the parser.
void SetTerminal(NumeReTerminal *terminal)
void SetTerminalHistory(int newSize)
Changes the size of the terminal history buffer.
void SetCaretBlinkTime(int newTime)
Changes the blinking duration of the terminal caret.
std::string compareFiles(const std::string &file1, const std::string &file2)
Compares two files linewise and in binary mode. The differences are returned as a unified diff.
@ MARKER_SAVED
@ MARKER_FOCUSEDLINE
WindowType
This enumeration defines all terminal- closable window types.
@ WT_CUSTOM
@ WT_IMAGEVIEWER
@ WT_DOCVIEWER
@ WT_GRAPH
@ WT_TABLEVIEWER
@ WT_ALL
@ SCRIPTPATH
@ LOADPATH
@ PLOTPATH
@ PATH_LAST
@ PROCPATH
@ SAVEPATH
@ VN_CLICKEDTAB
@ VN_NUMPAGES
@ VN_CURRENTPAGE
FileFilterType
@ FILE_SUPPORTEDFILES
@ FILE_NONSOURCE
@ FILE_CPP
@ FILE_DATAFILES
@ FILE_PLUGIN
@ FILE_ALLFILES
@ FILE_NPRC
@ FILE_XML
@ FILE_TEXSOURCE
@ FILE_NSCR
@ FILE_NUMERE
@ FILE_NOTYPE
@ FILE_NLYT
@ FILE_MATLAB
@ FILE_IMAGEFILES
@ FILE_ALLSOURCETYPES
@ FILE_DIFF
ModifiedFileAction
@ MODIFIEDFILE_CLOSE
@ MODIFIEDFILE_RELOAD
@ MODIFIEDFILE_COMPILE
@ ID_MENU_UNFOLD_ALL
@ ID_STATUSTIMER
@ ID_MENU_TOGGLE_COMMENT_SELECTION
@ ID_MENU_NEW_FOLDER_IN_TREE
@ ID_MENU_CLOSETAB
@ ID_MENU_BOOKMARK_CLEARMENU
@ ID_FILEEVENTTIMER
@ ID_MENU_REPLACE
@ ID_MENU_TOGGLE_HISTORY
@ ID_MENU_TOGGLE_FILETREE
@ ID_MENU_AUTOINDENT
@ ID_MENU_TOGGLE_NOTEBOOK_MULTIROW
@ ID_MENU_OPEN_FILE_FROM_TREE
@ ID_MENU_BOOKMARK_TOGGLE
@ ID_MENU_NEW_PLUGIN
@ ID_MENU_PASTE
@ ID_MENU_INSTALLPLUGINFROMFILE
@ ID_MENU_SORT_SELECTION_DESC
@ ID_MENU_AUTOFORMAT
@ ID_MENU_SAVE_SOURCE_REMOTE
@ ID_OPTIONSDIALOG
@ ID_MENU_COPY
@ ID_MENU_RENAME_SYMBOL
@ ID_MENU_NEW_LAYOUT
@ ID_MENU_RENAME_FILE_IN_TREE
@ ID_SPLITEDITOROUTPUT
@ ID_MENU_RUN_FROM_TAB
@ ID_MENU_TOGGLE_DEBUGGER
@ ID_MENU_FOLD_ALL
@ ID_MENU_ADDEDITORBREAKPOINT
@ ID_MENU_BOOKMARK_PREVIOUS
@ ID_FUNCTIONTREE
@ ID_MENU_REMOVEEDITORBREAKPOINT
@ ID_MENU_FIND
@ ID_MENU_SORT_SELECTION_ASC
@ ID_MENU_PLUGINBROWSER
@ ID_MENU_NEW_ASK
@ ID_SPLITPROJECTEDITOR
@ ID_MENU_COPY_FILE_FROM_TREE
@ ID_CONTAINER_TERM
@ ID_MENU_FIND_INCLUDE
@ ID_MENU_STRIP_SPACES_BOTH
@ ID_MENU_USESECTIONS
@ ID_MENU_CREATE_LATEX_FILE
@ ID_MENU_BOOKMARK_NEXT
@ ID_MENU_INSERT_IN_CONSOLE_FROM_TREE
@ ID_MENU_CREATE_DOCUMENTATION
@ ID_MENU_QUIT
@ ID_MENU_RUN_LATEX
@ ID_MENU_ABOUT
@ ID_MENU_DELETE_FILE_FROM_TREE
@ ID_MENU_CLOSEALL
@ ID_MENU_DISPCTRLCHARS
@ ID_MENU_INDENTONTYPE
@ ID_MENU_CLEAREDITORBREAKPOINTS
@ ID_MENU_SHOW_DESCRIPTION
@ ID_MENU_TRANSPOSESELECTION
@ ID_MENU_NEW_SCRIPT
@ ID_PROJECTTREE
@ ID_MENU_SAVE
@ ID_MENU_STOP_EXECUTION
@ ID_MENU_CREATE_PACKAGE
@ ID_MENU_CLOSETABFORCE
@ ID_MENU_OPEN_FOLDER
@ ID_MENU_EXPORT_FORMATTED
@ ID_MENU_REDO
@ ID_MENU_UNDO
@ ID_MENU_REMOVE_FOLDER_FROM_TREE
@ ID_MENU_OPEN_IN_EXPLORER
@ ID_MENU_EXPORT_AS_HTML
@ ID_MENU_EXECUTE
@ ID_MENU_OPTIONS
@ ID_MENU_USETXTADV
@ ID_MENU_COPY_AS_PATH
@ EVENTID_PLUGIN_MENU_END
@ ID_MENU_NEW_EMPTY
@ ID_MENU_STRIP_SPACES_BACK
@ ID_MENU_TOGGLE_CONSOLE
@ ID_MENU_GOTOLINE
@ ID_MENU_SELECTION_UP
@ ID_MENU_FIND_DUPLICATES
@ ID_MENU_OPEN_SOURCE_LOCAL
@ ID_MENU_INSERT_IN_EDITOR_FROM_TREE
@ EVENTID_PLUGIN_MENU_START
@ ID_MENU_PRINT_SETUP
@ ID_MENU_HELP
@ ID_NEW_PROJECT
@ ID_MENU_OPEN_SOURCE_REMOTE
@ ID_MENU_SHOW_DEPENDENCY_REPORT
@ ID_TERMINAL
@ ID_MENU_PRINT_PAGE
@ ID_MENU_INSERT_FILE_INTO_TREE
@ ID_MENU_UNHIDE_ALL
@ ID_MENU_UNSPLIT_TAB
@ ID_MENU_TAG_CURRENT_REVISION
@ ID_MENU_CLOSEOTHERS
@ ID_MENU_NEW_PROCEDURE
@ ID_MENU_ABSTRAHIZE_SECTION
@ ID_MENU_COMPARE_FILES
@ ID_MENU_EDIT_FILE_FROM_TREE
@ ID_MENU_TOGGLE_COMMENT_LINE
@ EVENTID_MENU_END
@ EVENTID_MENU_START
@ ID_MENU_FIND_PROCEDURE
@ ID_MENU_SELECTION_DOWN
@ ID_MENU_COMPILE_LATEX
@ ID_NOTEBOOK_ED
@ ID_MENU_HELP_ON_ITEM
@ ID_MENU_SAVE_SOURCE_LOCAL
@ ID_MENU_CUT
@ ID_MENU_LINEWRAP
@ ID_MENU_STRIP_SPACES_FRONT
@ ID_MENU_SHOW_REVISIONS_FROM_TAB
@ ID_MENU_SPLIT_TAB_H
@ ID_MENU_SHOW_REVISIONS
@ ID_MENU_SPLIT_TAB_V
@ ID_MENU_CLOSEPAGE
@ ID_MENU_USEANALYZER
@ ID_MENU_OPEN_FILE_FROM_TREE_TO_TABLE
@ ID_MENU_OPEN_IMAGE_FROM_TREE
@ ID_MENU_PRINT_PREVIEW
#define RM_WS_FRONT
Definition: editor.h:37
#define RM_WS_BACK
Definition: editor.h:38
#define RM_WS_BOTH
Definition: editor.h:36
std::string replacePathSeparator(const std::string &)
This function replaces the Windows style path sparators to UNIX style.
#define wxFR_WRAPAROUND
#define DDE_SERVICE
Definition: ipc.hpp:25
#define DDE_TOPIC
Definition: ipc.hpp:24
bool fileExists(const string &)
This function checks, whether the file with the passed file name exists.
Definition: tools.cpp:2500
DetachedLogger g_logger
Definition: logger.cpp:23
static Matrix selection(const MatFuncData &funcData, const MatFuncErrorInfo &errorInfo)
Extracts a selection from a matrix iterating through two matrices simultaneously.
Definition: matfuncs.hpp:3151
#define _T(x)
Definition: muParserDef.h:72
static const long MINOR
Definition: version.h:18
static const long BUILD
Definition: version.h:19
static const long MAJOR
Definition: version.h:17
static const char STATUS[]
Definition: version.h:13
static const char UBUNTU_VERSION_STYLE[]
Definition: version.h:10
CallTip FindProcedureDefinition(const std::string &pathname, const std::string &procedurename)
Search the procedure definition in a global file.
CallTip addLinebreaks(CallTip _cTip, size_t maxLineLength)
Adds the necessary linebreaks to the documentation part of the CallTip to fit inside the desired maxi...
@ CTRL_MESSAGEBOX
@ CTRL_SELECTIONDIALOG
@ CTRL_ICONERROR
@ CTRL_YESNOBUTTON
@ CTRL_FOLDERDIALOG
@ CTRL_TEXTENTRY
@ CTRL_FILEDIALOG
@ CTRL_LISTDIALOG
@ CTRL_ICONQUESTION
@ CTRL_ICONWARNING
@ CTRL_ICONINFORMATION
@ CTRL_CANCELBUTTON
CONSTCD11 std::enable_if<!std::chrono::treat_as_floating_point< T >::value, T >::type trunc(T t) NOEXCEPT
Definition: date.h:1113
#define PACKAGE_REPO_BROWSER_TITLE
#define min(a, b)
Definition: resampler.cpp:34
#define max(a, b)
Definition: resampler.cpp:30
int StrToInt(const std::string &)
Converts a string into an integer.
#define SETTING_B_TOOLBARTEXT
Definition: settings.hpp:76
#define SETTING_B_SAVEBOOKMARKS
Definition: settings.hpp:86
#define SETTING_B_ICONSONTABS
Definition: settings.hpp:78
#define SETTING_V_POS_SASH_T
Definition: settings.hpp:81
#define SETTING_B_USEREVISIONS
Definition: settings.hpp:88
#define SETTING_B_FORMATBEFORESAVING
Definition: settings.hpp:87
#define SETTING_V_POS_SASH_V
Definition: settings.hpp:79
#define SETTING_B_SAVESASHS
Definition: settings.hpp:90
#define SETTING_B_PROCEDUREARGS
Definition: settings.hpp:74
#define SETTING_B_PATHSONTABS
Definition: settings.hpp:77
#define SETTING_B_HIGHLIGHTLOCALS
Definition: settings.hpp:93
#define SETTING_B_USETABS
Definition: settings.hpp:94
#define SETTING_B_SAVEWINDOWSIZE
Definition: settings.hpp:91
#define SETTING_B_LINESINSTACK
Definition: settings.hpp:71
#define SETTING_B_AUTOSAVEEXECUTION
Definition: settings.hpp:89
#define SETTING_S_TERMINALFONT
Definition: settings.hpp:55
#define SETTING_S_WINDOWSIZE
Definition: settings.hpp:82
#define SETTING_B_GLOBALVARS
Definition: settings.hpp:73
#define SETTING_B_MODULESINSTACK
Definition: settings.hpp:72
#define SETTING_B_SAVESESSION
Definition: settings.hpp:85
#define SETTING_B_DEBUGGER
Definition: settings.hpp:34
#define SETTING_B_FOLDLOADEDFILE
Definition: settings.hpp:92
#define SETTING_B_SHOWHINTS
Definition: settings.hpp:39
#define SETTING_B_PRINTLINENUMBERS
Definition: settings.hpp:84
#define SETTING_V_POS_SASH_H
Definition: settings.hpp:80
std::vector< int > toIntVector(std::string sString)
This function converts a std::string into a std::vector, where the string shall be passed as "{x,...
std::string toUpperCase(const std::string &sLowerCase)
Converts lowercase letters to uppercase ones.
std::string getNextArgument(std::string &sArgList, bool bCut)
Definition: tools.cpp:2294
void replaceAll(std::string &sToModify, const char *sToRep, const char *sNewValue, size_t nStart, size_t nEnd)
This function replaces all occurences of the string sToRep in the string sToModify with the new value...
std::string getTimeStamp(bool bGetStamp)
This function simple returns the current time as a default timestamp.
This structure contains the data for a single calltip, which might be shown in the editor or the term...
std::string sDefinition
std::string sDocumentation
This structure combines a vector of declared variables including their values and respective sizes wi...
Definition: kernel.hpp:80
size_t nNumerics
Definition: kernel.hpp:82
size_t nStrings
Definition: kernel.hpp:83
size_t nTables
Definition: kernel.hpp:84
size_t nClusters
Definition: kernel.hpp:85
std::vector< std::string > vVariables
Definition: kernel.hpp:81
wxColour background
Definition: Options.h:29
std::string toString(int)
Converts an integer to a string without the Settings bloat.
bool ShowTip(wxWindow *parent, wxTipProvider *tipProvider, const wxArrayString &text, bool showAtStartUp)
Definition: tipdialog.cpp:141
vector< string > getFileList(const string &sDirectory, const Settings &_option, int nFlags)
This function returns a list of files (including their paths, if nFlags & 1).
Definition: tools.cpp:2853
string getFileInfo(const string &sFileName)
This function opens a NumeRe-Datafile file, reads its header and converts it to a human-readable stri...
Definition: tools.cpp:3446
vector< string > getFolderList(const string &sDirectory, const Settings &_option, int nFlags)
This function returns a list of directories (including their paths, if nFlags & 1).
Definition: tools.cpp:2925
EndlessVector< StringView > getAllArguments(StringView sArgList)
Splits up the complete argument list and returns them as an EndlessVector.
Definition: tools.cpp:2346
END_EVENT_TABLE()