Code::Blocks  SVN r11506
cbeditor.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3  * http://www.gnu.org/licenses/lgpl-3.0.html
4  *
5  * $Revision: 11480 $
6  * $Id: cbeditor.cpp 11480 2018-09-29 07:42:30Z fuscated $
7  * $HeadURL: https://svn.code.sf.net/p/codeblocks/code/trunk/src/sdk/cbeditor.cpp $
8  */
9 
10 #include "sdk_precomp.h"
11 
12 #ifndef CB_PRECOMP
13  #include <wx/app.h>
14  #include <wx/filedlg.h>
15  #include <wx/filename.h>
16  #include <wx/menu.h>
17  #include <wx/notebook.h>
18  #include <wx/wfstream.h>
19 
20  #include "cbeditor.h" // class's header file
21 
22  #include "cbauibook.h"
23  #include "cbplugin.h"
24  #include "cbproject.h"
25  #include "configmanager.h"
26  #include "debuggermanager.h"
27  #include "editorcolourset.h"
28  #include "editormanager.h"
29  #include "globals.h"
30  #include "infowindow.h"
31  #include "logmanager.h"
32  #include "macrosmanager.h" // ReplaceMacros
33  #include "manager.h"
34  #include "pluginmanager.h"
35  #include "projectbuildtarget.h"
36  #include "projectfile.h"
37  #include "projectmanager.h"
38  #include "sdk_events.h"
39 #endif
40 #include "cbstyledtextctrl.h"
41 #include "cbcolourmanager.h"
42 
43 #include <stack>
44 
45 #include <wx/fontutil.h>
46 #include <wx/splitter.h>
47 
48 #include "cbeditorprintout.h"
49 #include "cbdebugger_interfaces.h"
50 #include "editor_hooks.h"
51 #include "encodingdetector.h"
52 #include "filefilters.h"
53 #include "projectfileoptionsdlg.h"
54 
55 const wxString g_EditorModified = _T("*");
56 
57 #define ERROR_STYLE wxSCI_MARK_SMALLRECT
58 #define BOOKMARK_STYLE wxSCI_MARK_ARROW
59 #define BREAKPOINT_STYLE wxSCI_MARK_CIRCLE
60 #define DEBUG_STYLE wxSCI_MARK_ARROW
61 #define DEBUG_STYLE_HIGHLIGHT wxSCI_MARK_BACKGROUND
62 
63 #define BREAKPOINT_OTHER_MARKER 1
64 #define BREAKPOINT_DISABLED_MARKER 2
65 #define BREAKPOINT_MARKER 3
66 #define BOOKMARK_MARKER 4
67 #define ERROR_MARKER 5
68 #define DEBUG_MARKER 6
69 #define DEBUG_MARKER_HIGHLIGHT 7
70 
71 #define C_LINE_MARGIN 0 // Line numbers
72 #define C_MARKER_MARGIN 1 // Bookmarks, Breakpoints...
73 #define C_CHANGEBAR_MARGIN 2
74 #define C_FOLDING_MARGIN 3
75 
76 /* This struct holds private data for the cbEditor class.
77  * It's a paradigm to avoid rebuilding the entire project (as cbEditor is a basic dependency)
78  * for just adding a private var or method.
79  * What happens is that we 've declared a cbEditorInternalData* private member in cbEditor
80  * and define it in the .cpp file (here). Effectively, this means that we can now add/remove
81  * elements from cbEditorInternalData without needing to rebuild the project :)
82  * The cbEditor::m_pData is the variable to use in code. It's the very first thing
83  * constructed and the very last destructed.
84  *
85  * So, if we want to add a new private member in cbEditor, we add it here instead
86  * and access it with m_pData->
87  * e.g. m_pData->lastPosForCodeCompletion
88  * and of course you can add member functions here ;)
89  *
90  * cbEditorInternalData also contains a pointer to the owner cbEditor (named m_pOwner).
91  * Using m_pOwner the struct's member functions can access cbEditor functions
92  * (even private ones - it's a friend).
93  *
94  * The same logic should be used all around the project's classes, gradually.
95  */
97 {
99 
100  cbEditorInternalData(cbEditor* owner, LoaderBase* fileLoader = nullptr)
101  : m_pOwner(owner),
106  m_LastDebugLine(-1),
107  m_useByteOrderMark(false),
111  m_pFileLoader(fileLoader)
112  {
114 
115  if (m_pFileLoader)
116  {
117 #ifdef fileload_measuring
118  wxStopWatch sw;
119 #endif
120  EncodingDetector enc(fileLoader);
121  if (enc.IsOK())
122  {
124  m_useByteOrderMark = enc.UsesBOM();
125  m_encoding = enc.GetFontEncoding();
126  }
127 #ifdef fileload_measuring
128  Manager::Get()->GetLogManager()->DebugLog(F(_T("Encoding via fileloader took : %d ms"),(int)sw.Time()));
129 #endif
130  }
131  }
132 
134  {
135  if (m_pFileLoader)
136  {
137  delete m_pFileLoader;
138  m_pFileLoader = nullptr;
139  }
140  }
141 
142  // funcs
143 
146  {
147  cbStyledTextCtrl* control = m_pOwner->GetControl();
148  // The following code was adapted from the SciTE sourcecode
149 
150  int maxLines = control->GetLineCount();
151  for (int line = 0; line < maxLines; line++)
152  {
153  int lineStart = control->PositionFromLine(line);
154  int lineEnd = control->GetLineEndPosition(line);
155  int i = lineEnd-1;
156  wxChar ch = (wxChar)(control->GetCharAt(i));
157  if (control->GetLexer() == wxSCI_LEX_DIFF)
158  lineStart++;
159  while ((i >= lineStart) && ((ch == _T(' ')) || (ch == _T('\t'))))
160  {
161  i--;
162  ch = (wxChar)(control->GetCharAt(i));
163  }
164  if (i < (lineEnd-1))
165  {
166  control->SetTargetStart(i+1);
167  control->SetTargetEnd(lineEnd);
168  control->ReplaceTarget(_T(""));
169  }
170  }
171  }
172 
175  {
176  cbStyledTextCtrl* control = m_pOwner->GetControl();
177  // The following code was adapted from the SciTE sourcecode
178  int maxLines = control->GetLineCount();
179  int enddoc = control->PositionFromLine(maxLines);
180  if (maxLines <= 1 || enddoc > control->PositionFromLine(maxLines-1))
181  control->InsertText(enddoc, GetEOLStr(m_pOwner->GetControl()->GetEOLMode()));
182  }
183 
186  {
187  cbStyledTextCtrl* control = m_pOwner->GetControl();
188  // The following code was adapted from the SciTE sourcecode
189  control->ConvertEOLs(control->GetEOLMode());
190  }
191 
193  void SetLineNumberColWidth(bool both=true)
194  {
195  ConfigManager* cfg = Manager::Get()->GetConfigManager(_T("editor"));
196 
197  if (cfg->ReadBool(_T("/show_line_numbers"), true))
198  {
199  if (m_pOwner->m_pControl2 && both)
200  {
201  int pixelWidth = m_pOwner->m_pControl->TextWidth(wxSCI_STYLE_LINENUMBER, _T("9"));
202  int pixelWidth2 = m_pOwner->m_pControl2->TextWidth(wxSCI_STYLE_LINENUMBER, _T("9"));
203 
204  if (cfg->ReadBool(_T("/margin/dynamic_width"), false))
205  {
206  int lineNumChars = 1;
207  int lineCount = m_pOwner->m_pControl->GetLineCount();
208 
209  while (lineCount >= 10)
210  {
211  lineCount /= 10;
212  ++lineNumChars;
213  }
214 
215  int lineNumWidth = lineNumChars * pixelWidth + pixelWidth * 0.75;
216 
217  if (lineNumWidth != m_lineNumbersWidth)
218  {
219  m_pOwner->m_pControl->SetMarginWidth(C_LINE_MARGIN, lineNumWidth);
220  m_lineNumbersWidth = lineNumWidth;
221  }
222 
223  lineNumWidth = lineNumChars * pixelWidth2 + pixelWidth2 * 0.75;
224  if (lineNumWidth != m_lineNumbersWidth2)
225  {
226  m_pOwner->m_pControl2->SetMarginWidth(C_LINE_MARGIN, lineNumWidth);
227  m_lineNumbersWidth2 = lineNumWidth;
228  }
229  }
230  else
231  {
232  m_pOwner->m_pControl->SetMarginWidth(C_LINE_MARGIN, pixelWidth * 0.75 + cfg->ReadInt(_T("/margin/width_chars"), 6) * pixelWidth);
233  m_pOwner->m_pControl2->SetMarginWidth(C_LINE_MARGIN, pixelWidth * 0.75 + cfg->ReadInt(_T("/margin/width_chars"), 6) * pixelWidth);
234  }
235  }
236  else
237  {
238  cbStyledTextCtrl* control = m_pOwner->GetControl();
239  int* pLineNumbersWidth = nullptr;
240  if (control == m_pOwner->m_pControl)
241  pLineNumbersWidth = &m_lineNumbersWidth;
242  else
243  pLineNumbersWidth = &m_lineNumbersWidth2;
244 
245  int pixelWidth = control->TextWidth(wxSCI_STYLE_LINENUMBER, _T("9"));
246 
247  if (cfg->ReadBool(_T("/margin/dynamic_width"), false))
248  {
249  int lineNumChars = 1;
250  int lineCount = control->GetLineCount();
251 
252  while (lineCount >= 10)
253  {
254  lineCount /= 10;
255  ++lineNumChars;
256  }
257 
258  int lineNumWidth = lineNumChars * pixelWidth + pixelWidth * 0.75;
259 
260  if (lineNumWidth != *pLineNumbersWidth)
261  {
262  control->SetMarginWidth(C_LINE_MARGIN, lineNumWidth);
263  *pLineNumbersWidth = lineNumWidth;
264  }
265  }
266  else
267  {
268  control->SetMarginWidth(C_LINE_MARGIN, pixelWidth * 0.75 + cfg->ReadInt(_T("/margin/width_chars"), 6) * pixelWidth);
269  }
270  }
271  }
272  else
273  {
274  m_pOwner->m_pControl->SetMarginWidth(C_LINE_MARGIN, 0);
275  if (m_pOwner->m_pControl2 && both)
277  }
278  }
279 
280  void SetFoldingColWidth(bool both=true)
281  {
282  float pointSize = m_pOwner->m_pControl->StyleGetFont(wxSCI_STYLE_DEFAULT).GetPointSize();
283  if (both)
284  {
285  int width = 16 * (pointSize+m_pOwner->m_pControl->GetZoom()) / pointSize;
286  if (width < 1)
287  width = 1;
288  m_pOwner->m_pControl->SetMarginWidth(C_FOLDING_MARGIN, width);
289  if(m_pOwner->m_pControl2)
290  {
291  width = 16 * (pointSize+m_pOwner->m_pControl2->GetZoom()) / pointSize;
292  if (width < 1)
293  width = 1;
294  m_pOwner->m_pControl2->SetMarginWidth(C_FOLDING_MARGIN, width);
295  }
296  }
297  else
298  {
299  int width = 16 * (pointSize+m_pOwner->GetControl()->GetZoom()) / pointSize;
300  if (width < 1)
301  width = 1;
302  m_pOwner->GetControl()->SetMarginWidth(C_FOLDING_MARGIN, width);
303  }
304  }
305 
307  {
308  cbStyledTextCtrl* control = m_pOwner->GetControl();
309  if (!control)
310  return wxEmptyString;
311 
312  wxRegEx reUrl(wxT("***:("
313  "((ht|f)tp(s?)\\:\\/\\/)"
314  "|(www\\.)"
315  ")"
316  "("
317  "([\\w\\-]+(\\.[\\w\\-]+)+)"
318  "|localhost"
319  ")"
320  "(\\/?)([\\w\\-\\.\\?\\,\\'\\/\\\\\\+&amp;%\\$#]*)?"
321  "([\\d\\w\\.\\/\\%\\+\\-\\=\\&amp;\\?\\:\\\\\\&quot;\\'\\,\\|\\~\\;]*)"));
322  wxString url = control->GetSelectedText();
323  // Is the URL selected?
324  if (reUrl.Matches(url))
325  return reUrl.GetMatch(url);
326  // else is there a URL near the cursor?
327 
328  // Find out start position
329  int startPos = control->GetCurrentPos();
330  const wxString space = wxT(" \n\r\t{}");
331  wxChar curCh = control->GetCharAt(startPos);
332  while ( (startPos > 0) && (space.Find(curCh) == -1) )
333  {
334  startPos--;
335  curCh = control->GetCharAt(startPos);
336  }
337 
338  // Find out end position
339  int endPos = control->GetCurrentPos();
340  int maxPos = control->GetLineEndPosition(control->GetLineCount());
341  curCh = control->GetCharAt(endPos);
342  while ( (endPos < maxPos) && (space.Find(curCh) == -1) )
343  {
344  endPos++;
345  curCh = control->GetCharAt(endPos);
346  }
347 
348  url = control->GetTextRange(startPos, endPos);
349  if ( (control->GetLexer() == wxSCI_LEX_CPP)
350  && ( (control->GetStyleAt(control->GetCurrentPos()) == wxSCI_C_STRING)
351  || (control->GetStyleAt(control->GetCurrentPos()) == wxSCI_C_STRINGEOL) ) )
352  {
353  url.Replace(wxT("\\n"), wxT("\n"));
354  url.Replace(wxT("\\r"), wxT("\r"));
355  url.Replace(wxT("\\t"), wxT("\t"));
356  }
357 
358  if (reUrl.Matches(url))
359  {
360  wxString match = reUrl.GetMatch(url);
361  if ( (url.Find(match) + startPos < control->GetCurrentPos())
362  && (url.Find(match) + startPos + (int)match.Length() > control->GetCurrentPos()) )
363  {
364  url = match(0, match.find_last_not_of(wxT(",.")) + 1); // trim trailing
365  }
366  else
367  url = wxEmptyString; // nope, too far from cursor, return invalid (empty)
368  }
369  else
370  url = wxEmptyString; // nope, return invalid (empty)
371 
372  return url;
373  }
374 
376  {
377  int currLine = (line == -1)
378  ? stc->LineFromPosition(stc->GetCurrentPos())
379  : line;
380  wxString text = stc->GetLine(currLine);
381  unsigned int len = text.Length();
382  wxString indent;
383  for (unsigned int i = 0; i < len; ++i)
384  {
385  if (text[i] == _T(' ') || text[i] == _T('\t'))
386  {
387  indent << text[i];
388  }
389  else
390  {
391  break;
392  }
393  }
394  return indent;
395  }
396 
403  {
404  int lineCount[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
405  // lineCount[0] == number of lines with tabs
406  // lineCount[1] == number of lines with only spaces
407  // lineCount[2 ... 8] == number of lines divisible by that number
408  // Scan 1000 lines from the middle of the file to generate statistics
409  const int maxLine = std::min(stc->GetLineCount(), stc->GetLineCount() / 2 + 500);
410  for (int line = std::max(0, stc->GetLineCount() / 2 - 500); line < maxLine; ++line)
411  {
412  const wxString& indent = cbEditorInternalData::GetLineIndentString(line, stc);
413  if (indent.IsEmpty())
414  continue;
415  if (indent.Find(wxT('\t')) != wxNOT_FOUND)
416  ++lineCount[0];
417  else
418  {
419  ++lineCount[1];
420  for (int i = 2; i < 9; ++i)
421  {
422  if (indent.Length() % i == 0)
423  ++lineCount[i];
424  }
425  }
426  }
427 
428  if (lineCount[0] > 0 && lineCount[1] == 0)
429  return 0; // tabs
430  double total = lineCount[0] + lineCount[1];
431  if (total < 10)
432  return -1; // not sure -> use defaults
433  else if (lineCount[0] / total > 0.75)
434  return 0; // tabs
435  else if (lineCount[1] / total < 0.75)
436  return -1; // not sure -> use defaults
437 
438  total = lineCount[1];
439  int tabSize = 8;
440  for (int i = 2; i < 8; ++i)
441  {
442  if (lineCount[i] > lineCount[tabSize])
443  tabSize = i;
444  }
445  if (lineCount[tabSize] / total < 0.65)
446  return -1; // not sure -> use defaults
447 
448  switch (tabSize)
449  {
450  case 2:
451  if ((lineCount[2] - lineCount[6]) / total < 0.1)
452  return 6;
453  if ( lineCount[2] > lineCount[4] * 1.8
454  || lineCount[4] / total < 0.5 )
455  return 2;
456  // fall through
457  case 4:
458  if ( lineCount[4] > lineCount[8] * 1.8
459  || lineCount[8] / total < 0.5 )
460  return 4;
461  // fall through
462  case 8:
463  if (lineCount[8] / total < 0.6)
464  return -1; // not sure -> use defaults
465  return 8;
466 
467  case 3:
468  if ( lineCount[3] > lineCount[6] * 1.8
469  || lineCount[6] / total < 0.5 )
470  return 3;
471  if (lineCount[6] / total < 0.6)
472  return -1; // not sure -> use defaults
473  return 6;
474 
475  default:
476  if (lineCount[tabSize] / total < 0.7)
477  return -1; // not sure -> use defaults
478  return tabSize;
479  }
480  }
481 
482  // vars
486 
489 
492 
496 
499 
501 };
503 
504 const int idEmptyMenu = wxNewId();
505 const int idEdit = wxNewId();
506 const int idUndo = wxNewId();
507 const int idRedo = wxNewId();
508 const int idClearHistory = wxNewId();
509 const int idCut = wxNewId();
510 const int idCopy = wxNewId();
511 const int idPaste = wxNewId();
512 const int idDelete = wxNewId();
513 const int idUpperCase = wxNewId();
514 const int idLowerCase = wxNewId();
515 const int idSelectAll = wxNewId();
518 const int idBookmarks = wxNewId();
521 const int idBookmarksNext = wxNewId();
523 const int idFolding = wxNewId();
524 const int idFoldingFoldAll = wxNewId();
530 const int idInsert = wxNewId();
531 const int idSplit = wxNewId();
532 const int idSplitHorz = wxNewId();
533 const int idSplitVert = wxNewId();
534 const int idUnsplit = wxNewId();
535 const int idProperties = wxNewId();
539 const int idOpenUrl = wxNewId();
540 
541 const int idBookmarkAdd = wxNewId();
542 const int idBookmarkRemove = wxNewId();
544 
545 const int idBreakpointAdd = wxNewId();
546 const int idBreakpointEdit = wxNewId();
550 
551 BEGIN_EVENT_TABLE(cbEditor, EditorBase)
552  EVT_CLOSE(cbEditor::OnClose)
553  // we got dynamic events; look in ConnectEvents()
554 
593 
596 
597 END_EVENT_TABLE()
598 
599 // Count lines of EOL style in the opened file
600 static void CountLineEnds(cbStyledTextCtrl* control, int &linesCR, int &linesLF, int &linesCRLF)
601 {
602  linesCR = 0;
603  linesLF = 0;
604  linesCRLF = 0;
605 
606  int lengthDoc = control->GetLength();
607  const int maxLengthDoc = 1000000;
608  char chPrev = ' ';
609  char chNext = control->GetCharAt(0);
610  for (int i = 0; i < lengthDoc; i++)
611  {
612  char ch = chNext;
613  chNext = control->GetCharAt(i + 1);
614  if (ch == '\r')
615  {
616  if (chNext == '\n')
617  linesCRLF++;
618  else
619  linesCR++;
620  }
621  else if (ch == '\n')
622  {
623  if (chPrev != '\r')
624  linesLF++;
625  }
626  else if (i > maxLengthDoc) // stop the loop if the file contains too many characters
627  return;
628 
629  chPrev = ch;
630  }
631 }
632 
633 // Detect the EOL mode of the control. If a file has mixed EOLs, we will using the voting
634 // logic, and give user a InfoWindow notification.
635 static int DetectLineEnds(cbStyledTextCtrl* control)
636 {
637  int eolMode;
638  wxString eolModeStr;
639  // initial EOL mode depend on OS
640  if (platform::windows)
641  {
642  eolMode = wxSCI_EOL_CRLF;
643  eolModeStr = _T("\"CR-LF\"");
644  }
645  else
646  {
647  eolMode = wxSCI_EOL_LF;
648  eolModeStr = _T("\"LF\"");
649  }
650 
651  int linesCR;
652  int linesLF;
653  int linesCRLF;
654  // count lines of each EOL style
655  CountLineEnds(control, linesCR, linesLF, linesCRLF);
656 
657  // voting logic
658  // if the file does not contain any line-feed or the most largest counts are equal( e.g.: linesLF=5,
659  // linesCRLF=5, linesCR=0 ), then we will use the initial EOL mode
660  if ( (linesLF > linesCR) && (linesLF > linesCRLF) )
661  {
662  eolMode = wxSCI_EOL_LF;
663  eolModeStr = _T("\"LF\"");
664  }
665  else if ( (linesCR > linesLF) && (linesCR > linesCRLF) )
666  {
667  eolMode = wxSCI_EOL_CR;
668  eolModeStr = _T("\"CR\"");
669  }
670  else if ( (linesCRLF > linesLF) && (linesCRLF > linesCR))
671  {
672  eolMode = wxSCI_EOL_CRLF;
673  eolModeStr = _T("\"CR-LF\"");
674  }
675 
676  unsigned int delay = 2000;
677  if ( ( (linesCR>0) && (linesCRLF>0) )
678  || ( (linesLF>0) && (linesCRLF>0) )
679  || ( (linesCR>0) && (linesLF>0) ) )
680  {
681  //In mixed EOL file, give the user a beep and InfoWindow notification.
682  wxBell();
683  InfoWindow::Display(_("Mixed Line Endings"), _("Mixed line endings found, setting mode ") + eolModeStr, delay);
684  }
685  return eolMode;
686 }
687 
688 // class constructor
689 cbEditor::cbEditor(wxWindow* parent, const wxString& filename, EditorColourSet* theme)
690  : EditorBase(parent, filename),
691  m_pSplitter(nullptr),
692  m_pSizer(nullptr),
693  m_pControl(nullptr),
694  m_pControl2(nullptr),
695  m_foldBackup(nullptr),
696  m_SplitType(stNoSplit),
697  m_Modified(false),
698  m_Index(-1),
699  m_pProjectFile(nullptr),
700  m_pTheme(theme),
701  m_lang(HL_AUTO)
702 {
703  DoInitializations(filename);
704 }
705 
706 // class constructor
707 cbEditor::cbEditor(wxWindow* parent, LoaderBase* fileLdr, const wxString& filename, EditorColourSet* theme)
708  : EditorBase(parent, filename),
710  m_pSizer(nullptr),
715  m_Modified(false),
716  m_Index(-1),
718  m_pTheme(theme),
719  m_lang(HL_AUTO)
720 {
721  DoInitializations(filename, fileLdr);
722 }
723 
724 // class destructor
726 {
727  SetSizer(nullptr);
728 
729  // moved in ~EditorBase
730 // NotifyPlugins(cbEVT_EDITOR_CLOSE, 0, m_Filename);
731 
733  if (m_pControl)
734  {
735  if (m_pProjectFile)
736  m_pProjectFile->editorOpen = false;
737  m_pControl->Destroy();
738  m_pControl = nullptr;
739  }
741 
742  delete m_pData;
743 }
744 
745 void cbEditor::DoInitializations(const wxString& filename, LoaderBase* fileLdr)
746 {
747  // first thing to do!
748  // if we add more constructors in the future, don't forget to set this!
749  m_pData = new cbEditorInternalData(this);//, fileLdr);
750  m_pData->m_pFileLoader = fileLdr;
751  m_IsBuiltinEditor = true;
752 
753  if (!filename.IsEmpty())
754  {
755  InitFilename(filename);
756  wxFileName fname(m_Filename);
758  m_Filename = fname.GetFullPath();
759  }
760  else
761  {
762  static int untitledCounter = 1;
763  wxString f;
765  if (prj)
766  f.Printf(_("%sUntitled%d"), prj->GetBasePath().c_str(), untitledCounter++);
767  else
768  f.Printf(_("Untitled%d"), untitledCounter++);
769 
770  InitFilename(f);
771  }
772 // Manager::Get()->GetLogManager()->DebugLog(_T("ctor: Filename=%s\nShort=%s"), m_Filename.c_str(), m_Shortname.c_str());
773 
774  // initialize left control (unsplit state)
778  SetSizer(m_pSizer);
779 
780  // the following two lines make the editors behave strangely in linux:
781  // when resizing other docked windows, the editors do NOT resize too
782  // and they stame the same size...
783  // if commenting the following two lines causes problems in other platforms,
784  // simply put an "#ifdef __WXGTK__" guard around and uncomment them.
785 // m_pSizer->Fit(this);
786 // m_pSizer->SetSizeHints(this);
787 
789 
790  // by default we show no markers, marginMasks are set explicitly in "InternalSetEditorStyleBeforeFileOpen()"
791  // and/or by plugins, that use markers, like browsemarks-plugin
796 
798  m_IsOK = Open();
800  if (Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/folding/fold_all_on_open"), false))
801  FoldAll();
802 
803  // if !m_IsOK then it's a new file, so set the modified flag ON
804  if (!m_IsOK || filename.IsEmpty())
805  {
806  SetModified(true);
807  m_IsOK = false;
808  }
810 }
811 
812 void cbEditor::NotifyPlugins(wxEventType type, int intArg, const wxString& strArg, int xArg, int yArg)
813 {
814  if (!Manager::Get()->GetPluginManager())
815  return; // no plugin manager! app shutting down?
816  CodeBlocksEvent event(type);
817  event.SetEditor(this);
818  event.SetInt(intArg);
819  event.SetString(strArg);
820  event.SetX(xArg);
821  event.SetY(yArg);
822  if (m_pProjectFile)
823  event.SetProject(m_pProjectFile->GetParentProject());
824  //wxPostEvent(Manager::Get()->GetAppWindow(), event);
826 }
827 
829 {
830  if (m_pControl2)
831  {
832  m_pControl2->Destroy();
833  m_pControl2 = nullptr;
834  }
835  if (m_pSplitter)
836  {
837  m_pSplitter->Destroy();
838  m_pSplitter = nullptr;
839  }
840 }
841 
843 {
844  // return the last focused control (left or right)
845  if (m_pControl2)
846  {
847  // every time a control gets the focus it stores the actual timestamp, the timestamp defaults to 0 so the
848  // greater is the timestamp of the control that had the focus last time
849  // finding the focused window does not work if another control has the keyboard-focus
851  return m_pControl2;
852  }
853  return m_pControl;
854 }
855 
857 {
858  return m_Modified || m_pControl->GetModify();
859 }
860 
861 void cbEditor::SetModified(bool modified)
862 {
863  if (modified != m_Modified)
864  {
865  m_Modified = modified;
866  if (!m_Modified)
868 
871  // visual state
872  if (m_pProjectFile)
874  }
875 }
876 
878 {
879  if (m_Modified)
880  SetTitle(g_EditorModified + title);
881  else
882  SetTitle(title);
883 }
884 
885 void cbEditor::SetProjectFile(ProjectFile* project_file, bool preserve_modified)
886 {
887  if (m_pProjectFile == project_file)
888  return; // we 've been here before ;)
889 
890  bool wasmodified = false;
891  if (preserve_modified)
892  wasmodified = GetModified();
893 
894  m_pProjectFile = project_file;
895  if (m_pProjectFile)
896  {
897  // update our filename
898  m_Filename = UnixFilename(project_file->file.GetFullPath());
899 
904  if (m_pProjectFile->editorSplit != (int)stNoSplit)
905  {
907  if (m_pControl2)
908  {
914  }
915  }
916 
918 
919  if ( Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/folding/show_folds"), true) )
920  {
921  for (unsigned int i = 0; i < m_pProjectFile->editorFoldLinesArray.GetCount(); i++)
923  }
924 
925  m_pProjectFile->editorOpen = true;
926 
927  if (Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/tab_text_relative"), true))
929  else
932 
933  if (!wxFileExists(m_Filename))
935  else if (!wxFile::Access(m_Filename.c_str(), wxFile::write)) // readonly
937  }
938 
939 #if 0
940  wxString dbg;
941  dbg << _T("[ed] Filename: ") << GetFilename() << _T('\n');
942  dbg << _T("[ed] Short name: ") << GetShortName() << _T('\n');
943  dbg << _T("[ed] Modified: ") << GetModified() << _T('\n');
944  dbg << _T("[ed] Project: ") << ((m_pProjectFile && m_pProjectFile->project) ? m_pProjectFile->project->GetTitle() : _T("unknown")) << _T('\n');
945  dbg << _T("[ed] Project file: ") << (m_pProjectFile ? m_pProjectFile->relativeFilename : _T("unknown")) << _T('\n');
947 #endif
948  if (preserve_modified)
949  SetModified(wasmodified);
950 }
951 
953 {
954  if (m_pControl && m_pProjectFile)
955  {
956  m_pProjectFile->editorOpen = true;
962  if (m_pControl2)
963  {
968  if (GetControl()==m_pControl2)
970  }
971 
972  if (m_pProjectFile->editorFoldLinesArray.GetCount() != 0)
974 
975  int i = 0;
976  while ((i = m_pControl->ContractedFoldNext(i)) != -1)
978  }
979 }
980 
981 void cbEditor::SetMarkerStyle(int marker, int markerType, wxColor fore, wxColor back)
982 {
983  m_pControl->MarkerDefine(marker, markerType);
984  m_pControl->MarkerSetForeground(marker, fore);
985  m_pControl->MarkerSetBackground(marker, back);
986 
987  if (m_pControl2)
988  {
989  m_pControl2->MarkerDefine(marker, markerType);
990  m_pControl2->MarkerSetForeground(marker, fore);
991  m_pControl2->MarkerSetBackground(marker, back);
992  }
993 }
994 
995 void cbEditor::UnderlineFoldedLines(bool underline)
996 {
997  m_pControl->SetFoldFlags(underline ? 16 : 0);
998  if (m_pControl2)
999  m_pControl2->SetFoldFlags(underline ? 16 : 0);
1000 }
1001 
1003 {
1004  // avoid gtk-critical because of sizes less than -1 (can happen with wxAuiNotebook/cbAuiNotebook)
1005  wxSize size = m_pControl ? wxDefaultSize : GetSize();
1006  size.x = std::max(size.x, -1);
1007  size.y = std::max(size.y, -1);
1008 
1009  cbStyledTextCtrl* control = new cbStyledTextCtrl(this, wxNewId(), wxDefaultPosition, size);
1010  control->UsePopUp(false);
1011 
1012  ConfigManager *config = Manager::Get()->GetConfigManager(_T("editor"));
1013  wxString encodingName = config->Read(_T("/default_encoding"), wxEmptyString);
1015  if (m_pData->m_encoding == wxFONTENCODING_MAX && encodingName == wxT("default"))
1017 
1018  for (int marker = 0 ; marker <= wxSCI_MARKNUM_LASTUNUSED ; ++marker)
1019  control->MarkerDefine(marker, wxSCI_MARK_EMPTY);
1020 
1021  return control;
1022 }
1023 
1025 {
1026  wxWindowID stcID = stc->GetId();
1027  // dynamic events
1028  Connect( stcID, wxEVT_SCI_MARGINCLICK, wxScintillaEventHandler(cbEditor::OnMarginClick) );
1029  Connect( stcID, wxEVT_SCI_UPDATEUI, wxScintillaEventHandler(cbEditor::OnEditorUpdateUI) );
1030  Connect( stcID, wxEVT_SCI_CHANGE, wxScintillaEventHandler(cbEditor::OnEditorChange) );
1031  Connect( stcID, wxEVT_SCI_CHARADDED, wxScintillaEventHandler(cbEditor::OnEditorCharAdded) );
1032  Connect( stcID, wxEVT_SCI_DWELLSTART, wxScintillaEventHandler(cbEditor::OnEditorDwellStart) );
1033  Connect( stcID, wxEVT_SCI_DWELLEND, wxScintillaEventHandler(cbEditor::OnEditorDwellEnd) );
1034  Connect( stcID, wxEVT_SCI_USERLISTSELECTION, wxScintillaEventHandler(cbEditor::OnUserListSelection) );
1035  Connect( stcID, wxEVT_SCI_MODIFIED, wxScintillaEventHandler(cbEditor::OnEditorModified) );
1036 
1037  // Now bind all *other* scintilla events to a common function so that editor hooks
1038  // can be informed for them too.
1039  // If you implement one of these events using a different function, do the following:
1040  // * comment it out here,
1041  // * "connect" it in the above block
1042  // * and make sure you call OnScintillaEvent() from your new handler function
1043  // This will make sure that all editor hooks will be called when needed.
1044  int scintilla_events[] =
1045  {
1046 // wxEVT_SCI_CHANGE,
1047  wxEVT_SCI_STYLENEEDED,
1048 // wxEVT_SCI_CHARADDED,
1049  wxEVT_SCI_SAVEPOINTREACHED,
1050  wxEVT_SCI_SAVEPOINTLEFT,
1051  wxEVT_SCI_ROMODIFYATTEMPT,
1052  wxEVT_SCI_DOUBLECLICK,
1053 // wxEVT_SCI_UPDATEUI,
1054 // wxEVT_SCI_MODIFIED,
1055  wxEVT_SCI_MACRORECORD,
1056 // wxEVT_SCI_MARGINCLICK,
1057  wxEVT_SCI_NEEDSHOWN,
1058  wxEVT_SCI_PAINTED,
1059 // wxEVT_SCI_USERLISTSELECTION,
1060 // wxEVT_SCI_DWELLSTART,
1061 // wxEVT_SCI_DWELLEND,
1062  wxEVT_SCI_START_DRAG,
1063  wxEVT_SCI_DRAG_OVER,
1064  wxEVT_SCI_DO_DROP,
1065  wxEVT_SCI_ZOOM,
1066  wxEVT_SCI_HOTSPOT_CLICK,
1067  wxEVT_SCI_HOTSPOT_DCLICK,
1068  wxEVT_SCI_CALLTIP_CLICK,
1069  wxEVT_SCI_AUTOCOMP_SELECTION,
1070 // wxEVT_SCI_INDICATOR_CLICK,
1071 // wxEVT_SCI_INDICATOR_RELEASE,
1072  wxEVT_SCI_AUTOCOMP_CANCELLED,
1073 
1074  -1 // to help enumeration of this array
1075  };
1076  int i = 0;
1077  while (scintilla_events[i] != -1)
1078  {
1079  Connect( stcID, scintilla_events[i], wxScintillaEventHandler(cbEditor::OnScintillaEvent) );
1080  ++i;
1081  }
1082 }
1083 
1085 {
1086  Freeze();
1087 
1088  // unsplit first, if needed
1089  if (m_pSplitter)
1090  {
1091  Unsplit();
1092  Manager::Yield();
1093  }
1094  m_SplitType = split;
1095  if (m_SplitType == stNoSplit)
1096  {
1097  Thaw();
1098  return;
1099  }
1100 
1101  // remove the left control from the sizer
1103 
1104  // create the splitter window
1107 
1108  // create the right control
1110 
1111  // update controls' look'n'feel
1112  // do it here (before) document is attached, speeds up syntaxhighlighting
1113  // we do not call "SetEditorStyleAfterFileOpen" here because it calls SetLanguage for the already loaded text inside
1114  // the left control and slows down loading of large files a lot.
1116 
1117  // make sure basic settings of indicators (maybe set by plugins) are used for the new control
1118  for (int i = 0; i < wxSCI_INDIC_MAX; ++i )
1119  {
1123  }
1124 
1125  ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor"));
1126  SetFoldingIndicator(mgr->ReadInt(_T("/folding/indicator"), 2));
1127  UnderlineFoldedLines(mgr->ReadBool(_T("/folding/underline_folded_line"), true));
1128 
1129  if (m_pTheme)
1130  {
1131  m_pTheme->Apply(m_lang, m_pControl2, false, true);
1133  }
1134 
1135  // and make it a live copy of left control
1137 
1138  // on wxGTK > 2.9 we need to thaw before reparent and refreeze the editor here or the whole app stays frozen
1139  #if defined ( __WXGTK__ ) && wxCHECK_VERSION(3, 0, 0)
1140  Thaw();
1141  #endif
1142  // parent both controls under the splitter
1143  m_pControl->Reparent(m_pSplitter);
1144  m_pControl2->Reparent(m_pSplitter);
1145  #if defined ( __WXGTK__ ) && wxCHECK_VERSION(3, 0, 0)
1146  Freeze();
1147  #endif
1148 
1149  // add the splitter in the sizer
1150  m_pSizer->SetDimension(0, 0, GetSize().x, GetSize().y);
1152 
1153  m_pSizer->Layout();
1154 
1155  // split as needed
1156  switch (m_SplitType)
1157  {
1158  case stHorizontal:
1160  break;
1161 
1162  case stVertical:
1164  break;
1165 
1166  case stNoSplit: // fall-trough
1167  default:
1168  break;
1169  }
1170 
1172 
1173  // initial zoom is same as left/top control
1175  // make sure the line numbers margin is correct for the new control
1177 
1179 
1181 
1182  Thaw();
1183 }
1184 
1186 {
1188  if (!m_pSplitter)
1189  return;
1190 
1191  Freeze();
1192 
1193  // if "unsplit" requested on right control, swap left-right first
1194  if (GetControl() == m_pControl2)
1195  {
1198  m_pControl2 = tmp;
1199  }
1200 
1201  // remove the splitter from the sizer
1203 
1204  // on wxGTK > 2.9 we need to thaw before reparent and refreeze the editor here or the whole app stays frozen
1205  #if defined ( __WXGTK__ ) && wxCHECK_VERSION(3, 0, 0)
1206  Thaw();
1207  #endif
1208  // parent the left control under this
1209  m_pControl->Reparent(this);
1210  #if defined ( __WXGTK__ ) && wxCHECK_VERSION(3, 0, 0)
1211  Freeze();
1212  #endif
1213  // add it in the sizer
1215  // notify the plugin when the right splitter window is not destroyed and the left window is reparented to cbEditor
1217  // destroy the splitter and right control
1218  DestroySplitView();
1219  // and layout
1220  m_pSizer->Layout();
1221 
1222  Thaw();
1223 }
1224 
1226 {
1228 }
1229 
1231 {
1234 }
1235 
1237 {
1238  if (!control)
1239  return;
1240  // Override the use tab setting for languages which have explicit requirements about tab/space
1241  // usage.
1242  int lexer = control->GetLexer();
1243  switch (lexer)
1244  {
1245  case wxSCI_LEX_PYTHON:
1246  case wxSCI_LEX_YAML:
1247  control->SetUseTabs(false);
1248  break;
1249  case wxSCI_LEX_MAKEFILE:
1250  control->SetUseTabs(true);
1251  break;
1252  default:
1253  break;
1254  }
1255 }
1256 
1258 {
1259  ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor"));
1260 
1261  // update the tab text based on preferences
1262  if (m_pProjectFile)
1263  {
1264  if (mgr->ReadBool(_T("/tab_text_relative"), true))
1266  else
1269  }
1270 
1271  // Folding properties.
1272  m_pData->mFoldingLimit = mgr->ReadBool(_T("/folding/limit"), false);
1273  m_pData->mFoldingLimitLevel = mgr->ReadInt(_T("/folding/limit_level"), 1);
1274 
1275  // EOL properties
1276  m_pData->m_strip_trailing_spaces = mgr->ReadBool(_T("/eol/strip_trailing_spaces"), true);
1277  m_pData->m_ensure_final_line_end = mgr->ReadBool(_T("/eol/ensure_final_line_end"), true);
1278  m_pData->m_ensure_consistent_line_ends = mgr->ReadBool(_T("/eol/ensure_consistent_line_ends"), false);
1279 
1281 
1282  if (m_pControl2)
1284 
1285  SetFoldingIndicator(mgr->ReadInt(_T("/folding/indicator"), 2));
1286 
1287  SetLanguage(HL_AUTO, false);
1288 
1291 }
1292 
1294 {
1296  if (m_pControl2)
1298 
1299  ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor"));
1300 
1301  UnderlineFoldedLines(mgr->ReadBool(_T("/folding/underline_folded_line"), true));
1302 
1303  // line numbers
1305 }
1306 
1307 // static
1308 // public version of InternalSetEditorStyleBeforeFileOpen
1310 {
1311  if (!control)
1312  return;
1313 
1316 }
1317 
1318 // static
1320 {
1321  if (!control)
1322  return;
1323 
1324  ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor"));
1325 
1326  // setting the default editor font size to 10 point
1328 
1329  wxString fontstring = mgr->Read(_T("/font"), wxEmptyString);
1330 
1331  if (!fontstring.IsEmpty())
1332  {
1333  wxNativeFontInfo nfi;
1334  nfi.FromString(fontstring);
1335  font.SetNativeFontInfo(nfi);
1336  }
1337 
1338  control->SetMouseDwellTime(1000);
1339 
1340  int caretStyle = mgr->ReadInt(_T("/caret/style"), wxSCI_CARETSTYLE_LINE);
1341  control->SetCaretStyle(caretStyle);
1342  if (caretStyle == wxSCI_CARETSTYLE_LINE)
1343  control->SetCaretWidth(mgr->ReadInt(_T("/caret/width"), 1));
1344  else
1345  control->SetCaretWidth(1);
1346 
1348 
1349  control->SetCaretForeground(colours->GetColour(wxT("editor_caret")));
1350  control->SetCaretPeriod(mgr->ReadInt(_T("/caret/period"), 500));
1351  control->SetCaretLineVisible(mgr->ReadBool(_T("/highlight_caret_line"), false));
1352  control->SetFoldMarginColour(true, colours->GetColour(wxT("editor_margin_chrome")));
1353  control->SetFoldMarginHiColour(true, colours->GetColour(wxT("editor_margin_chrome_highlight")));
1354 
1355  control->SetWhitespaceForeground(true, colours->GetColour(wxT("editor_whitespace")));
1356 
1357  // setup for "CamelCase selection"
1358  if (mgr->ReadBool(_T("/camel_case"), false))
1359  {
1360  // consider CamelCase for both: cursor movement with CTRL and selection with CTRL+SHIFT:
1365  }
1366  else // else set default "none CamelCase" key behavior (also default scintilla behaviour, see scintilla docs)
1367  {
1372  }
1373 
1374  control->SetUseTabs(mgr->ReadBool(_T("/use_tab"), false));
1375  control->SetIndentationGuides(mgr->ReadBool(_T("/show_indent_guides"), false)?wxSCI_IV_LOOKBOTH:wxSCI_IV_NONE);
1376  control->SetTabIndents(mgr->ReadBool(_T("/tab_indents"), true));
1377  control->SetBackSpaceUnIndents(mgr->ReadBool(_T("/backspace_unindents"), true));
1378  control->SetWrapMode(mgr->ReadBool(_T("/word_wrap"), false));
1379  if (mgr->ReadBool(_T("/word_wrap_style_home_end"), true))
1380  {
1381  // in word wrap mode, home/end keys goto the wrap point if not already there,
1382  // otherwise to the start/end of the entire line.
1383  // alt+home/end go to start/end of the entire line.
1384  // in unwrapped mode, there is no difference between home/end and alt+home/end
1389 
1390  // if user wants "Home" key to set cursor to the very beginning of line
1391  if (mgr->ReadBool(_T("/simplified_home"), false))
1392  {
1397  }
1398  else // else set default "Home" key behaviour
1399  {
1404  }
1405  }
1406  else
1407  { // in word wrap mode, home/end keys goto start/end of the entire line. alt+home/end goes to wrap points
1410 
1411  // if user wants "Home" key to set cursor to the very beginning of line
1412  if (mgr->ReadBool(_T("/simplified_home"), false))
1413  {
1416  }
1417  else // else set default "Home" key behaviour
1418  {
1421  }
1422  }
1423  control->SetViewEOL(mgr->ReadBool(_T("/show_eol"), false));
1424  control->SetViewWhiteSpace(mgr->ReadInt(_T("/view_whitespace"), 0));
1425 
1426  const int caretBuffer = mgr->ReadInt(wxT("/caret_buffer"), 2);
1427  if (caretBuffer == 0)
1428  {
1429  control->SetYCaretPolicy(wxSCI_CARET_EVEN, 0); // default
1430  control->SetVisiblePolicy(wxSCI_CARET_EVEN, 0); // default
1431  }
1432  else if (caretBuffer > 0 && caretBuffer <= 10)
1433  {
1434  // margin of N lines at top/bottom
1436  caretBuffer);
1438  caretBuffer);
1439  }
1440  else
1441  {
1442  // centred mode
1445  }
1446 
1447  // gutter
1448  control->SetEdgeMode(mgr->ReadInt(_T("/gutter/mode"), 0));
1449  control->SetEdgeColour(colours->GetColour(wxT("editor_gutter")));
1450  control->SetEdgeColumn(mgr->ReadInt(_T("/gutter/column"), 80));
1451 
1452  control->StyleSetFont(wxSCI_STYLE_DEFAULT, font);
1453  control->StyleClearAll();
1454 
1455  control->SetTabWidth(mgr->ReadInt(_T("/tab_size"), 4));
1456 
1457  // margin for bookmarks, breakpoints etc.
1458  // FIXME: how to display a mark with an offset???
1459  control->SetMarginWidth(C_MARKER_MARGIN, 16);
1461  control->SetMarginSensitive(C_MARKER_MARGIN, mgr->ReadBool(_T("/margin_1_sensitive"), true));
1462  // use "|" here or we might break plugins that use the margin (like browsemarks)
1463  control->SetMarginMask(C_MARKER_MARGIN,
1464  control->GetMarginMask(C_MARKER_MARGIN)
1465  | (1 << BOOKMARK_MARKER)
1466  | (1 << BREAKPOINT_MARKER)
1468  | (1 << BREAKPOINT_OTHER_MARKER)
1469  | (1 << DEBUG_MARKER)
1470  | (1 << DEBUG_MARKER_HIGHLIGHT)
1471  | (1 << ERROR_MARKER) );
1472 
1473  // 1.) Marker for Bookmarks etc...
1475  control->MarkerSetBackground(BOOKMARK_MARKER, wxColour(0xA0, 0xA0, 0xFF));
1476 
1477  // 2.) Marker for Breakpoints etc...
1478  const wxString &basepath = ConfigManager::GetDataFolder() + wxT("/manager_resources.zip#zip:/images/12x12/");
1479  bool imageBP = mgr->ReadBool(_T("/margin_1_image_bp"), true);
1480  if (imageBP)
1481  {
1482  wxBitmap iconBP = cbLoadBitmap(basepath + wxT("breakpoint.png"), wxBITMAP_TYPE_PNG);
1483  wxBitmap iconBPDis = cbLoadBitmap(basepath + wxT("breakpoint_disabled.png"), wxBITMAP_TYPE_PNG);
1484  wxBitmap iconBPOth = cbLoadBitmap(basepath + wxT("breakpoint_other.png"), wxBITMAP_TYPE_PNG);
1485  if (iconBP.IsOk() && iconBPDis.IsOk() && iconBPOth.IsOk())
1486  {
1487  control->MarkerDefineBitmap(BREAKPOINT_MARKER, iconBP );
1488  control->MarkerDefineBitmap(BREAKPOINT_DISABLED_MARKER, iconBPDis);
1489  control->MarkerDefineBitmap(BREAKPOINT_OTHER_MARKER, iconBPOth);
1490  }
1491  else
1492  imageBP = false; // apply default markers
1493  }
1494  if (!imageBP)
1495  {
1497  control->MarkerSetBackground(BREAKPOINT_MARKER, wxColour(0xFF, 0x00, 0x00));
1499  control->MarkerSetBackground(BREAKPOINT_DISABLED_MARKER, wxColour(0x90, 0x90, 0x90));
1501  control->MarkerSetBackground(BREAKPOINT_OTHER_MARKER, wxColour(0x59, 0x74, 0x8e));
1502  }
1503  // 3.) Marker for Debugging (currently debugged line) etc...
1505  control->MarkerSetBackground(DEBUG_MARKER, wxColour(0xFF, 0xFF, 0x00));
1506 
1508  control->MarkerSetBackground(DEBUG_MARKER_HIGHLIGHT, wxColour(0xFF, 0xFF, 0x00));
1509 
1510  // 4.) Marker for Errors...
1512  control->MarkerSetBackground(ERROR_MARKER, wxColour(0xFF, 0x00, 0x00));
1513 
1514  // changebar margin
1515  if (mgr->ReadBool(_T("/margin/use_changebar"), true))
1516  {
1517  control->SetMarginWidth(C_CHANGEBAR_MARGIN, 4);
1519  // use "|" here or we might break plugins that use the margin (none at the moment)
1523  | (1 << wxSCI_MARKNUM_CHANGESAVED) );
1524 
1526  control->MarkerSetBackground(wxSCI_MARKNUM_CHANGEUNSAVED, wxColour(0xFF, 0xE6, 0x04));
1528  control->MarkerSetBackground(wxSCI_MARKNUM_CHANGESAVED, wxColour(0x04, 0xFF, 0x50));
1529  }
1530  else
1531  control->SetMarginWidth(C_CHANGEBAR_MARGIN, 0);
1532 
1533  // NOTE: duplicate line in editorconfigurationdlg.cpp (ctor)
1534  control->SetScrollWidthTracking( mgr->ReadBool(_T("/margin/scroll_width_tracking"), false));
1535  control->SetMultipleSelection( mgr->ReadBool(_T("/selection/multi_select"), false));
1536  const bool multiTyping = mgr->ReadBool(_T("/selection/multi_typing"), false);
1537  control->SetAdditionalSelectionTyping(multiTyping);
1538  control->SetMultiPaste(multiTyping);
1539 
1540  unsigned virtualSpace = 0;
1541  if (mgr->ReadBool(_T("/selection/use_rect_vspace"), false))
1542  virtualSpace |= wxSCI_VS_RECTANGULARSELECTION;
1543  if (mgr->ReadBool(_T("/selection/use_vspace"), false))
1544  virtualSpace |= wxSCI_VS_USERACCESSIBLE;
1545  if (!virtualSpace)
1546  virtualSpace = wxSCI_VS_NONE; // Just in case wxSCI_VS_NONE != 0
1547  control->SetVirtualSpaceOptions(virtualSpace);
1548 }
1549 
1550 // static
1552 {
1553  if (!control)
1554  return;
1555 
1556  ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor"));
1557 
1558  // set the EOL, fall back value: Windows takes CR+LF, other platforms LF only
1559  int eolMode = mgr->ReadInt(_T("/eol/eolmode"), platform::windows ? wxSCI_EOL_CRLF : wxSCI_EOL_LF);
1560 
1561  if (eolMode == 3) //auto detect the EOL
1562  eolMode = DetectLineEnds(control);
1563 
1564  control->SetEOLMode(eolMode);
1565 
1566  // indentation style is already set
1567  if (mgr->ReadBool(_T("/detect_indent"), false))
1568  {
1569  // override style if auto-detection succeeds
1570  int indentStyle = cbEditorInternalData::DetectIndentStyle(control);
1571  if (indentStyle == 0)
1572  control->SetUseTabs(true);
1573  else if (indentStyle != -1)
1574  {
1575  control->SetUseTabs(false);
1576  control->SetTabWidth(indentStyle);
1577  }
1578  }
1579 
1580  // Interpret #if/#else/#endif to grey out code that is not active
1581  control->SetProperty(_T("lexer.cpp.track.preprocessor"), mgr->ReadBool(_T("/track_preprocessor"), true) ? _T("1") : _T("0"));
1582 
1583  // code folding
1584  if (mgr->ReadBool(_T("/folding/show_folds"), true))
1585  {
1586  control->SetProperty(_T("fold"), _T("1"));
1587  control->SetProperty(_T("fold.html"), mgr->ReadBool(_T("/folding/fold_xml"), true) ? _T("1") : _T("0"));
1588  control->SetProperty(_T("fold.comment"), mgr->ReadBool(_T("/folding/fold_comments"), false) ? _T("1") : _T("0"));
1589  control->SetProperty(_T("fold.compact"), _T("0"));
1590  control->SetProperty(_T("fold.preprocessor"), mgr->ReadBool(_T("/folding/fold_preprocessor"), false) ? _T("1") : _T("0"));
1591 
1592  control->SetFoldFlags(16);
1594  control->SetMarginWidth(C_FOLDING_MARGIN, 16);
1595  // use "|" here or we might break plugins that use the margin (none at the moment)
1598  | ( wxSCI_MASK_FOLDERS
1599  - ( (1 << wxSCI_MARKNUM_CHANGEUNSAVED)
1600  | (1 << wxSCI_MARKNUM_CHANGESAVED))) );
1601  control->SetMarginSensitive(C_FOLDING_MARGIN, 1);
1602  }
1603  else
1604  {
1605  control->SetProperty(_T("fold"), _T("0"));
1606  control->SetMarginWidth(C_FOLDING_MARGIN, 0);
1607  }
1608  control->SetProperty(_T("highlight.wxsmith"), mgr->ReadBool(_T("/highlight_wxsmith"), true) ? _T("1") : _T("0"));
1609 
1610  // line numbering
1612 
1613  // As a final step colourise the document. This make sure that style and folding information is
1614  // set on every line/character of the editor. If Colourise is called earlier restoring the
1615  // folding of the editor might not work. Also this is probably slow for larger files, so it is
1616  // best if we call it minimal number of times.
1617  control->Colourise(0, -1);
1618 }
1619 
1621 {
1622  m_pTheme = theme;
1623  SetLanguage(m_lang, true);
1624 }
1625 
1627 {
1628  if (!m_pData)
1629  return wxFONTENCODING_SYSTEM;
1630 
1631  return m_pData->m_encoding;
1632 }
1633 
1635 {
1637 }
1638 
1640 {
1641  if (!m_pData)
1642  return;
1643 
1644  if (encoding == wxFONTENCODING_SYSTEM)
1645  encoding = wxLocale::GetSystemEncoding();
1646 
1647  if (encoding == m_pData->m_encoding)
1648  return;
1649 
1650  m_pData->m_encoding = encoding;
1651  SetModified(true);
1652 }
1653 
1655 {
1656  if (!m_pData)
1657  return false;
1658  return m_pData->m_useByteOrderMark;
1659 }
1660 
1661 void cbEditor::SetUseBom( bool bom )
1662 {
1663  if (!m_pData)
1664  return;
1665 
1666  if ( bom == GetUseBom() )
1667  return;
1668 
1669  m_pData->m_useByteOrderMark = bom;
1670  SetModified(true);
1671 }
1672 
1673 bool cbEditor::Reload(bool detect_encoding)
1674 {
1675  // keep current pos
1676  const int pos = m_pControl ? m_pControl->GetCurrentPos() : 0;
1677  const int pos2 = m_pControl2 ? m_pControl2->GetCurrentPos() : 0;
1678 
1679  // call open
1680  if (!Open(detect_encoding))
1681  {
1682  return false;
1683  }
1684  // Re-establish margin styles, width, etc
1686 
1687  // return (if possible) to old pos
1688  if (m_pControl)
1689  {
1690  m_pControl->GotoPos(pos);
1691  }
1692  if (m_pControl2)
1693  {
1694  m_pControl2->GotoPos(pos2);
1695  }
1696  return true;
1697 } // end of Reload
1698 
1700 {
1702 }
1703 
1704 void cbEditor::SetLanguage(HighlightLanguage lang, bool colourise)
1705 {
1706  if (m_pTheme)
1707  {
1708  m_lang = m_pTheme->Apply(this, lang, colourise);
1709  if (m_pControl)
1711  if (m_pControl2)
1713  }
1714  else
1715  m_lang = HL_AUTO;
1716 }
1717 
1718 bool cbEditor::Open(bool detectEncoding)
1719 {
1720  if (m_pProjectFile)
1721  {
1722  if (!wxFileExists(m_Filename))
1724  else if (!wxFile::Access(m_Filename.c_str(), wxFile::write)) // readonly
1726  }
1727 
1728  if (!wxFileExists(m_Filename))
1729  return false;
1730 
1731  // open file
1732  SetReadOnly(false);
1733 
1734  m_pControl->ClearAll();
1736 
1737  if (!m_pData)
1738  return false;
1739 
1740  if (!m_pData->m_pFileLoader)
1742 
1743 #ifdef fileload_measuring
1744  wxStopWatch sw;
1745 #endif
1747  if (detectEncoding)
1748  {
1749  m_pData->m_useByteOrderMark = enc.UsesBOM();
1750  m_pData->m_byteOrderMarkLength = enc.GetBOMSizeInBytes();
1751  m_pData->m_encoding = enc.GetFontEncoding();
1752 
1753  SetEncoding(enc.GetFontEncoding());
1755  }
1756 
1757  ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor"));
1758 #ifdef fileload_measuring
1759  Manager::Get()->GetLogManager()->DebugLog(F(_T("cbEditor::Open() => Encoding detection and conversion took : %d ms"),(int)sw.Time()));
1760  sw.Start();
1761 #endif
1762 
1763  m_pControl->InsertText(0, enc.GetWxStr());
1764  m_pControl->EmptyUndoBuffer(mgr->ReadBool(_T("/margin/use_changebar"), true));
1766 
1767  // mark the file read-only, if applicable
1768  bool read_only = !wxFile::Access(m_Filename.c_str(), wxFile::write);
1769  SetReadOnly(read_only);
1770 
1771  wxFileName fname(m_Filename);
1773 
1774  SetModified(false);
1775 
1777 
1778  if (m_pData->m_pFileLoader)
1779  {
1780  delete m_pData->m_pFileLoader;
1781  m_pData->m_pFileLoader = nullptr;
1782  }
1783 #ifdef fileload_measuring
1784  Manager::Get()->GetLogManager()->DebugLog(F(_T("loading into editor needs : %d ms"),(int)sw.Time()));
1785 #endif
1786  return true;
1787 }
1788 
1790 {
1791  if ( !GetModified() )
1792  return true;
1793 
1794  // remember current column (caret and anchor)
1795  int columnC = m_pControl->GetColumn(m_pControl->GetCurrentPos());
1796  int columnA = m_pControl->GetColumn(m_pControl->GetAnchor());
1797 
1798  // one undo action for all modifications in this context
1799  // (angled braces added for clarity)
1801  {
1808  }
1810 
1811  // restore virtual position ( if changed by StripTrailingSpaces() )
1812  columnC -= m_pControl->GetColumn(m_pControl->GetCurrentPos());
1813  columnA -= m_pControl->GetColumn(m_pControl->GetAnchor());
1814  if (columnC > 0)
1816  if (columnA > 0)
1818 
1819  if (!m_IsOK)
1820  return SaveAs();
1821 
1825 
1827  {
1828  wxString msg;
1829  msg.Printf(_("File %s could not be saved..."), GetFilename().c_str());
1830  cbMessageBox(msg, _("Error saving file"), wxICON_ERROR);
1831  return false; // failed; file is read-only?
1832  }
1833 
1834  wxFileName fname(m_Filename);
1836 
1837  m_IsOK = true;
1838 
1840  SetModified(false);
1841 
1843  return true;
1844 } // end of Save
1845 
1847 {
1848  wxFileName fname;
1849  fname.Assign(m_Filename);
1850  ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("app"));
1851  int StoredIndex = 0;
1853  wxString Path = fname.GetPath();
1854  wxString Extension = fname.GetExt();
1855  wxString Filter;
1856  if (!Extension.IsEmpty())
1857  { // use the current extension as the filter
1858  // Select filter belonging to this file type:
1859  Extension.Prepend(_T("."));
1860  Filter = FileFilters::GetFilterString(Extension);
1861  }
1862  else if (mgr)
1863  {
1864  // File type is unknown. Select the last used filter:
1865  Filter = mgr->Read(_T("/file_dialogs/save_file_as/filter"), _T("C/C++ files"));
1866  }
1867  if (!Filter.IsEmpty())
1868  {
1869  // We found a filter, look up its index:
1870  int sep = Filter.find(_T("|"));
1871  if (sep != wxNOT_FOUND)
1872  Filter.Truncate(sep);
1873  if (!Filter.IsEmpty())
1874  FileFilters::GetFilterIndexFromName(Filters, Filter, StoredIndex);
1875  }
1876  if (mgr && Path.IsEmpty())
1877  Path = mgr->Read(_T("/file_dialogs/save_file_as/directory"), Path);
1878 
1879  wxFileDialog dlg(Manager::Get()->GetAppWindow(), _("Save file"), Path, fname.GetFullName(),
1881  // Initialize the wildcards here. If we do it in the wxFileDialog constructor it will detect
1882  // that our file name doesn't have extension and it will try to add one. It doens't have a
1883  // correct value for the filter index we want, so it uses the first one which is ads for Ada
1884  // files. This is happening only on wxGTK.
1885  dlg.SetWildcard(Filters);
1886  dlg.SetFilterIndex(StoredIndex);
1887  PlaceWindow(&dlg);
1888  if (dlg.ShowModal() != wxID_OK)
1889  { // cancelled out
1890  return false;
1891  }
1892  m_Filename = dlg.GetPath();
1894  fname.Assign(m_Filename);
1895  m_Shortname = fname.GetFullName();
1897  // invalidate m_pProjectFile, because if kept, it would point to the ProjectFile with old name and
1898  // cause ProjectManager::RemoveFileFromProject called via context menu to crash
1899  SetProjectFile(nullptr);
1900  //Manager::Get()->GetLogManager()->Log(mltDevDebug, "Filename=%s\nShort=%s", m_Filename.c_str(), m_Shortname.c_str());
1901  m_IsOK = true;
1902  SetLanguage(HL_AUTO, true);
1903  SetModified(true);
1907  // store the last used filter and directory
1908  if (mgr)
1909  {
1910  int Index = dlg.GetFilterIndex();
1911  Filter.Empty();
1912  if (FileFilters::GetFilterNameFromIndex(Filters, Index, Filter))
1913  mgr->Write(_T("/file_dialogs/save_file_as/filter"), Filter);
1914  wxString Test = dlg.GetDirectory();
1915  mgr->Write(_T("/file_dialogs/save_file_as/directory"), dlg.GetDirectory());
1916  }
1917  return Save();
1918 } // end of SaveAs
1919 
1921 {
1922  bool bRet = false;
1923  if ((m_foldBackup = CreateEditor()))
1924  {
1927  int count = m_pControl->GetLineCount();
1928  for (int i = 0; i < count; ++i)
1930  bRet = true;
1931  }
1932  return bRet;
1933 } // end of SaveFoldState
1934 
1936 {
1937  bool bRet = false;
1938  if (m_foldBackup)
1939  {
1940  int backupLength = m_foldBackup->GetLineCount();
1941  int realLength = m_pControl->GetLineCount();
1942  if (backupLength == realLength) // It is supposed to be the same, but you never know :)
1943  {
1944  ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor"));
1945  if (mgr->ReadBool(_T("/folding/show_folds"), true)) // Only fix the folds if the folds are enabled
1946  {
1947  int count = m_pControl->GetLineCount();
1948  for (int i = 0; i < count; ++i)
1949  {
1950  int oldFoldLevel = m_foldBackup->GetFoldLevel(i);
1951  int newFoldLevel = m_pControl->GetFoldLevel(i);
1952  if (oldFoldLevel != newFoldLevel)
1953  {
1954  if (m_pControl->GetLineVisible(i) == true)
1955  m_pControl->SetFoldExpanded(i, true);
1956  else
1957  {
1958  int parent = m_foldBackup->GetFoldParent(i);
1959  while(parent != -1)
1960  {
1961  m_pControl->ToggleFold(parent);
1962  parent = m_foldBackup->GetFoldParent(parent);
1963  }
1964  m_pControl->ShowLines(i, i);
1965  parent = m_foldBackup->GetFoldParent(i);
1966  while(parent != -1)
1967  {
1968  m_pControl->ToggleFold(parent);
1969  parent = m_foldBackup->GetFoldParent(parent);
1970  }
1971  }
1972  }
1973  }
1974  }
1975  bRet = true;
1976  }
1977  m_foldBackup->Destroy();
1978  m_foldBackup = nullptr;
1979  }
1980  return bRet;
1981 } // end of FixFoldState
1982 
1984 {
1985  Manager::Get()->GetLogManager()->Log(_T("cbEditor::AutoComplete() is obsolete.\nUse AutoComplete(cbEditor &ed) from the Abbreviations plugin instead."));
1986 }
1987 
1989 {
1991  if (m_SplitType != stNoSplit)
1993  cbStyledTextCtrl* ctrl = GetControl();
1994 
1995  ctrl->Colourise(0, -1); // the *most* important part!
1996 
1997  if (fold != FoldMode::toggle)
1998  {
1999  const int count = ctrl->GetLineCount();
2000  for (int line = 0; line < count; ++line)
2001  {
2002  const int level = ctrl->GetFoldLevel(line);
2003  if ((level & wxSCI_FOLDLEVELHEADERFLAG) == 0)
2004  continue;
2005 
2006  if (m_pData->mFoldingLimit)
2007  {
2008  const bool isExpanded = ctrl->GetFoldExpanded(line);
2009 
2010  // Apply the folding level limit only if the current block will be
2011  // folded (that means it's currently expanded), folding level limiter
2012  // must be enabled of course. Unfolding will not be affected.
2013  if (isExpanded && (fold == FoldMode::contract || fold == FoldMode::toggle))
2014  {
2015  int levelNumber = (level & wxSCI_FOLDLEVELNUMBERMASK) - wxSCI_FOLDLEVELBASE;
2016  if (levelNumber > m_pData->mFoldingLimitLevel - 1)
2017  continue;
2018  }
2019  }
2020 
2021  ctrl->FoldLine(line, int(fold));
2022  }
2023  }
2024  else
2025  {
2026  // Toggle implementation - we need this one because the implementation for fold/unfold
2027  // doesn't work correctly - it expands parent folds when there is an expanded child fold.
2028  // We want to toggle all fold points in the editor no matter what level are they at. If
2029  // there is a folding limit we respect it for both contracting and expanding.
2030 
2031  struct FoldRange
2032  {
2033  FoldRange(int start, int end, bool hasContracted) :
2034  start(start),
2035  end(end),
2036  hasContracted(hasContracted)
2037  {}
2038 
2039  int start, end;
2040  bool hasContracted;
2041  };
2042  // We need to know if a parent fold has been contracted. For this we use a stack with the
2043  // active folds at the line we are processing.
2044  std::stack<FoldRange> parentFolds;
2045 
2046  const int count = ctrl->GetLineCount();
2047  for (int line = 0; line < count; ++line)
2048  {
2049  while (!parentFolds.empty() && parentFolds.top().end < line)
2050  parentFolds.pop();
2051 
2052  const int level = ctrl->GetFoldLevel(line);
2053  if ((level & wxSCI_FOLDLEVELHEADERFLAG) == 0)
2054  continue;
2055  const int levelNumber = (level & wxSCI_FOLDLEVELNUMBERMASK) - wxSCI_FOLDLEVELBASE;
2056  if (m_pData->mFoldingLimit)
2057  {
2058  // Apply folding level limit.
2059  if (levelNumber > m_pData->mFoldingLimitLevel - 1)
2060  continue;
2061  }
2062 
2063  const bool toContract = ctrl->GetFoldExpanded(line);
2064  const int lastChild = ctrl->GetLastChild(line, -1);
2065 
2066  bool hasContracted;
2067  if (toContract)
2068  hasContracted = true;
2069  else
2070  {
2071  if (parentFolds.empty())
2072  hasContracted = false;
2073  else
2074  hasContracted = parentFolds.top().hasContracted;
2075  }
2076  parentFolds.push(FoldRange(line, lastChild, hasContracted));
2077 
2078  if (toContract)
2079  {
2080  ctrl->SetFoldExpanded(line, false);
2081  ctrl->HideLines(line + 1, lastChild);
2082  }
2083  else
2084  {
2085  ctrl->SetFoldExpanded(line, true);
2086  // If there are contracted parent folds we must not show lines for child folds even
2087  // if they are expanded. When the user does an expand operation for the parent
2088  // Scintilla will make sure to show these lines.
2089  if (!hasContracted)
2090  ctrl->ShowLines(line + 1, lastChild);
2091  }
2092  }
2093  }
2094 }
2095 
2096 void cbEditor::DoFoldBlockFromLine(int line, FoldMode fold, unsigned foldFlags)
2097 {
2098  // Use static asserts to verify the constants are the same, because we don't want to include
2099  // wxscintilla.h in cbeditor.h. This code is here, because we want the Foldmode to be private.
2100  static_assert(int(cbEditor::FoldMode::contract) == wxSCI_FOLDACTION_CONTRACT, "Must match");
2101  static_assert(int(cbEditor::FoldMode::expand) == wxSCI_FOLDACTION_EXPAND, "Must match");
2102  static_assert(int(cbEditor::FoldMode::toggle) == wxSCI_FOLDACTION_TOGGLE, "Must match");
2103 
2105  if (m_SplitType != stNoSplit)
2107  cbStyledTextCtrl* ctrl = GetControl();
2108  if (!ctrl)
2109  return;
2110 
2111  // This is needed to update the folding information for the current view.
2112  ctrl->Colourise(0, -1);
2113 
2114  int foldLine;
2115  int level = ctrl->GetFoldLevel(line);
2116  if (level & wxSCI_FOLDLEVELHEADERFLAG)
2117  foldLine = line;
2118  else
2119  {
2120  // If the line is not a block start line, find the block start. This makes it possible to
2121  // toggle the folding when the cursor is in the middle of some block of code.
2122  foldLine = ctrl->GetFoldParent(line);
2123  if (foldLine == -1)
2124  return;
2125  }
2126  const bool isExpanded = ctrl->GetFoldExpanded(foldLine);
2127 
2128  ctrl->FoldLine(foldLine, int(fold));
2129 
2130  if (foldFlags & FoldFlags::ensureVisible)
2131  {
2132  if (fold == FoldMode::expand || (fold == FoldMode::toggle && !isExpanded))
2133  ctrl->EnsureVisibleEnforcePolicy(line);
2134  }
2135 }
2136 
2138 {
2140 }
2141 
2143 {
2145 }
2146 
2148 {
2150 }
2151 
2153 {
2154  wxColor f(0xff, 0xff, 0xff); // foreground colour
2155  wxColor b(0x80, 0x80, 0x80); // background colour
2156  // Arrow
2157  if (id == 0)
2158  {
2166  }
2167  // Circle
2168  else if (id == 1)
2169  {
2177  }
2178  // Square
2179  else if (id == 2)
2180  {
2188  }
2189  // Simple
2190  else if (id == 3)
2191  {
2199  }
2200 }
2201 
2203 {
2204  if (line == -1)
2205  line = GetControl()->GetCurrentLine();
2206  DoFoldBlockFromLine(line, FoldMode::contract, FoldFlags::ensureVisible);
2207 }
2208 
2210 {
2211  if (line == -1)
2212  line = GetControl()->GetCurrentLine();
2213  DoFoldBlockFromLine(line, FoldMode::expand, FoldFlags::ensureVisible);
2214 }
2215 
2217 {
2218  if (line == -1)
2219  line = GetControl()->GetCurrentLine();
2220  DoFoldBlockFromLine(line, FoldMode::toggle, FoldFlags::ensureVisible);
2221 }
2222 
2223 void cbEditor::GotoLine(int line, cb_unused bool centerOnScreen)
2224 {
2225  cbStyledTextCtrl* control = GetControl();
2226 
2227  // Make sure the line is not folded. This is done before moving to that
2228  // line because folding may change the lines layout.
2229  control->EnsureVisible(line);
2230 
2231  // If the line or the following is a fold point it will be unfolded, in this way
2232  // when the line is a function declaration (or only contains the opening brace of it [yes, that happens sometimes] )
2233  // the body is shown.
2234  DoFoldBlockFromLine(line, FoldMode::expand, FoldFlags::none);
2235  DoFoldBlockFromLine(line+1, FoldMode::expand, FoldFlags::none);
2236 
2237  control->GotoLine(line);
2238 }
2239 
2240 bool cbEditor::GotoTokenPosition(int line, const wxString& tokenName)
2241 {
2242  cbStyledTextCtrl* control = GetControl();
2243  if (line > control->GetLineCount())
2244  return false;
2245 
2246  GotoLine(line, true); // center function on screen
2247  SetFocus(); // ...and set focus to this editor
2248 
2249  // Now highlight the token
2250  const int startPos = control->GetCurrentPos();
2251  const int endPos = startPos + control->LineLength(line);
2252  if (endPos <= startPos)
2253  return false;
2254 
2255  int tokenPos = control->FindText(startPos, endPos, tokenName,
2257  if (tokenPos != wxSCI_INVALID_POSITION)
2258  control->SetSelectionInt(tokenPos, tokenPos + tokenName.Len());
2259  else
2260  control->GotoPos(startPos); // fall back, point the cursor to it
2261 
2262  return true;
2263 }
2264 
2266 {
2267  int marker = m_pControl->MarkerGet(line);
2268  if (marker & (1 << BREAKPOINT_MARKER))
2270  else if (marker & (1 << BREAKPOINT_DISABLED_MARKER))
2272  else
2274 }
2275 
2276 bool cbEditor::AddBreakpoint(int line, bool notifyDebugger)
2277 {
2278  if (HasBreakpoint(line))
2279  return false;
2280 
2281  if (line == -1)
2282  line = GetControl()->GetCurrentLine();
2283 
2284  if (!notifyDebugger)
2285  {
2286  BreakpointMarkerToggle(line);
2287  return false;
2288  }
2289 
2290  DebuggerManager *dbgManager = Manager::Get()->GetDebuggerManager();
2291  if (dbgManager->GetBreakpointDialog()->AddBreakpoint(dbgManager->GetActiveDebugger(), m_Filename, line + 1))
2292  {
2293  BreakpointMarkerToggle(line);
2294  return true;
2295  }
2296  return false;
2297 }
2298 
2299 bool cbEditor::RemoveBreakpoint(int line, bool notifyDebugger)
2300 {
2301  if (!HasBreakpoint(line))
2302  return false;
2303 
2304  if (line == -1)
2305  line = GetControl()->GetCurrentLine();
2306 
2307  if (!notifyDebugger)
2308  {
2309  BreakpointMarkerToggle(line);
2310  return false;
2311  }
2312 
2313  DebuggerManager *dbgManager = Manager::Get()->GetDebuggerManager();
2314  if (dbgManager->GetBreakpointDialog()->RemoveBreakpoint(dbgManager->GetActiveDebugger(), m_Filename, line + 1))
2315  {
2316  BreakpointMarkerToggle(line);
2317  return true;
2318  }
2319  return false;
2320 }
2321 
2322 void cbEditor::ToggleBreakpoint(int line, bool notifyDebugger)
2323 {
2324  if (line == -1)
2325  line = GetControl()->GetCurrentLine();
2326  if (!notifyDebugger)
2327  {
2328  BreakpointMarkerToggle(line);
2329  return;
2330  }
2331 
2332  DebuggerManager *dbgManager = Manager::Get()->GetDebuggerManager();
2333  cbBreakpointsDlg *dialog = dbgManager->GetBreakpointDialog();
2334  cbDebuggerPlugin *plugin = dbgManager->GetActiveDebugger();
2335  if (!plugin || !plugin->SupportsFeature(cbDebuggerFeature::Breakpoints))
2336  return;
2337 
2338  bool toggle = false;
2339  if (HasBreakpoint(line))
2340  {
2341  if (dialog->RemoveBreakpoint(plugin, m_Filename, line + 1))
2342  toggle = true;
2343  }
2344  else
2345  {
2346  if (dialog->AddBreakpoint(plugin, m_Filename, line + 1))
2347  toggle = true;
2348  }
2349 
2350  if (toggle)
2351  {
2352  BreakpointMarkerToggle(line);
2353  dialog->Reload();
2354  }
2355 }
2356 
2357 bool cbEditor::HasBreakpoint(int line) const
2358 {
2359  if (line == -1)
2360  line = GetControl()->GetCurrentLine();
2362 }
2363 
2365 {
2367 }
2368 
2370 {
2372 }
2373 
2375 {
2377 }
2378 
2380 {
2381  // First remove all breakpoint markers, then add the markers for the active debugger
2383  int line = 0;
2384  while ((line = c->MarkerNext(line, (1 << BREAKPOINT_MARKER))) != -1)
2386 
2387  line = 0;
2388  while ((line = c->MarkerNext(line, (1 << BREAKPOINT_DISABLED_MARKER))) != -1)
2390 
2391  line = 0;
2392  while ((line = c->MarkerNext(line, (1 << BREAKPOINT_OTHER_MARKER))) != -1)
2394 
2396  for (DebuggerManager::RegisteredPlugins::const_iterator it = plugins.begin(); it != plugins.end(); ++it)
2397  {
2398  const cbDebuggerPlugin *debugger = it->first;
2399  if (debugger == Manager::Get()->GetDebuggerManager()->GetActiveDebugger())
2400  {
2401  for (int ii = 0; ii < debugger->GetBreakpointsCount(); ++ii)
2402  {
2403  cb::shared_ptr<const cbBreakpoint> bp = debugger->GetBreakpoint(ii);
2404  if (bp->GetLocation() == GetFilename())
2405  {
2406  if (bp->IsEnabled())
2407  MarkerToggle(BREAKPOINT_MARKER, bp->GetLine() - 1);
2408  else
2409  MarkerToggle(BREAKPOINT_DISABLED_MARKER, bp->GetLine() - 1);
2410  }
2411  }
2412  }
2413  else
2414  {
2415  // all breakpoints for the non active debugger use the other breakpoint marker
2416  for (int ii = 0; ii < debugger->GetBreakpointsCount(); ++ii)
2417  {
2418  cb::shared_ptr<const cbBreakpoint> bp = debugger->GetBreakpoint(ii);
2419  if (bp->GetLocation() == GetFilename())
2420  MarkerToggle(BREAKPOINT_OTHER_MARKER, bp->GetLine() - 1);
2421  }
2422  }
2423  }
2424 }
2425 
2426 bool cbEditor::HasBookmark(int line) const
2427 {
2428  return LineHasMarker(BOOKMARK_MARKER, line);
2429 }
2430 
2432 {
2434 }
2435 
2437 {
2439 }
2440 
2442 {
2443  cbStyledTextCtrl* control = GetControl();
2444  control->MarkerDeleteAll(BOOKMARK_MARKER);
2445 }
2446 
2448 {
2449  MarkLine(DEBUG_MARKER, line);
2450  if (GetControl()->GetCaretLineVisible())
2452  m_pData->m_LastDebugLine = line;
2453 }
2454 
2456 {
2457  MarkLine(ERROR_MARKER, line);
2458 }
2459 
2461 {
2462  cbAssert(GetControl());
2463  GetControl()->Undo();
2464 }
2465 
2467 {
2468  cbAssert(GetControl());
2469  GetControl()->Redo();
2470 }
2471 
2473 {
2474  cbAssert(GetControl());
2475  GetControl()->EmptyUndoBuffer(Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/margin/use_changebar"), true));
2476 }
2477 
2479 {
2480  cbAssert(GetControl());
2481  cbStyledTextCtrl* p_Control = GetControl();
2482  int fromLine = p_Control->LineFromPosition(p_Control->GetCurrentPos());
2483  int toLine = p_Control->GetLineCount() - 1;
2484  if (fromLine == toLine)
2485  fromLine = 0;
2486  else
2487  fromLine++;
2488 
2489  int newLine = p_Control->FindChangedLine(fromLine, toLine);
2490  if (newLine != wxSCI_INVALID_POSITION)
2491  {
2492  p_Control->GotoLine(newLine);
2493  p_Control->MakeNearbyLinesVisible(p_Control->GetCurrentLine());
2494  }
2495 }
2496 
2498 {
2499  cbAssert(GetControl());
2500  cbStyledTextCtrl* p_Control = GetControl();
2501  int fromLine = p_Control->LineFromPosition(p_Control->GetCurrentPos());
2502  int toLine = 0;
2503  if (fromLine == toLine)
2504  fromLine = p_Control->GetLineCount() - 1;
2505  else
2506  fromLine--;
2507 
2508  int newLine = p_Control->FindChangedLine(fromLine, toLine);
2509  if (newLine != wxSCI_INVALID_POSITION)
2510  {
2511  p_Control->GotoLine(newLine);
2512  p_Control->MakeNearbyLinesVisible(p_Control->GetCurrentLine());
2513  }
2514 }
2515 
2516 void cbEditor::SetChangeCollection(bool collectChange)
2517 {
2518  cbAssert(GetControl());
2519  GetControl()->SetChangeCollection(collectChange);
2520 }
2521 
2523 {
2524  cbAssert(GetControl());
2525  GetControl()->Cut();
2526 }
2527 
2529 {
2530  cbAssert(GetControl());
2531  GetControl()->Copy();
2532 }
2533 
2535 {
2536  cbAssert(GetControl());
2537  GetControl()->Paste();
2538 }
2539 
2540 bool cbEditor::CanUndo() const
2541 {
2542  cbAssert(GetControl());
2543  return !IsReadOnly() && GetControl()->CanUndo();
2544 }
2545 
2546 bool cbEditor::CanRedo() const
2547 {
2548  cbAssert(GetControl());
2549  return !IsReadOnly() && GetControl()->CanRedo();
2550 }
2551 
2553 {
2554  cbAssert(GetControl());
2555  cbStyledTextCtrl* control = GetControl();
2556  return control->GetSelectionStart() != control->GetSelectionEnd();
2557 }
2558 
2560 {
2561  cbAssert(GetControl());
2562  if (platform::gtk)
2563  return !IsReadOnly();
2564 
2565  return GetControl()->CanPaste() && !IsReadOnly();
2566 }
2567 
2569 {
2570  cbAssert(GetControl());
2571  return GetControl()->GetReadOnly();
2572 }
2573 
2574 void cbEditor::SetReadOnly(bool readonly)
2575 {
2576  cbAssert(GetControl());
2577  GetControl()->SetReadOnly(readonly);
2578 }
2579 
2580 bool cbEditor::LineHasMarker(int marker, int line) const
2581 {
2582  if (line == -1)
2583  line = GetControl()->GetCurrentLine();
2584  return m_pControl->MarkerGet(line) & (1 << marker);
2585 }
2586 
2587 void cbEditor::MarkerToggle(int marker, int line)
2588 {
2589  if (line == -1)
2590  line = GetControl()->GetCurrentLine();
2591  if (LineHasMarker(marker, line))
2592  GetControl()->MarkerDelete(line, marker);
2593  else
2594  GetControl()->MarkerAdd(line, marker);
2595 }
2596 
2597 void cbEditor::MarkerNext(int marker)
2598 {
2599  int line = GetControl()->GetCurrentLine() + 1;
2600  int newLine = GetControl()->MarkerNext(line, 1 << marker);
2601 
2602  // Start from beginning if at last marker.
2603  if (newLine == -1)
2604  {
2605  line = 0;
2606  newLine = GetControl()->MarkerNext(line, 1 << marker);
2607 
2608  if (newLine != -1)
2609  InfoWindow::Display(_("Find bookmark action"), _("Reached the end of the document"), 1000);
2610  }
2611 
2612  if (newLine != -1)
2613  GotoLine(newLine);
2614 }
2615 
2617 {
2618  int line = GetControl()->GetCurrentLine() - 1;
2619  int newLine = GetControl()->MarkerPrevious(line, 1 << marker);
2620 
2621  // Back to last one if at first marker.
2622  if (newLine == -1)
2623  {
2624  line = GetControl()->GetLineCount();
2625  newLine = GetControl()->MarkerPrevious(line, 1 << marker);
2626 
2627  if (newLine != -1)
2628  InfoWindow::Display(_("Find bookmark action"), _("Reached the end of the document"), 1000);
2629  }
2630 
2631  if (newLine != -1)
2632  GotoLine(newLine);
2633 }
2634 
2635 void cbEditor::MarkLine(int marker, int line)
2636 {
2637  if (line == -1)
2638  GetControl()->MarkerDeleteAll(marker);
2639  else
2640  GetControl()->MarkerAdd(line, marker);
2641 }
2642 
2644 {
2645  cbStyledTextCtrl* control = GetControl();
2646 
2647  // this works only when the caret is *before* the brace
2648  int matchingBrace = control->BraceMatch(control->GetCurrentPos());
2649 
2650  // if we haven't found it, we 'll search at pos-1 too
2651  if (matchingBrace == wxSCI_INVALID_POSITION)
2652  matchingBrace = control->BraceMatch(control->GetCurrentPos() - 1);
2653  else
2654  ++matchingBrace; // to keep the caret on the same side of the brace
2655 
2656  // else look for a matching preprocessor command
2657  if (matchingBrace == wxSCI_INVALID_POSITION)
2658  {
2659  wxRegEx ppIf(wxT("^[ \t]*#[ \t]*if"));
2660  wxRegEx ppElse(wxT("^[ \t]*#[ \t]*el"));
2661  wxRegEx ppEnd(wxT("^[ \t]*#[ \t]*endif"));
2662  wxRegEx pp(wxT("^[ \t]*#[ \t]*[a-z]*")); // generic match to get length
2663  if (ppIf.Matches(control->GetCurLine()) || ppElse.Matches(control->GetCurLine()))
2664  {
2665  int depth = 1; // search forwards
2666  for (int i = control->GetCurrentLine() + 1; i < control->GetLineCount(); ++i)
2667  {
2668  if (control->GetLine(i).Find(wxT('#')) != wxNOT_FOUND) // limit testing due to performance cost
2669  {
2670  if (ppIf.Matches(control->GetLine(i))) // ignore else's, elif's, ...
2671  ++depth;
2672  else if (ppEnd.Matches(control->GetLine(i)))
2673  --depth;
2674  }
2675  if (depth == 0)
2676  {
2677  pp.Matches(control->GetLine(i));
2678  matchingBrace = control->PositionFromLine(i) + pp.GetMatch(control->GetLine(i)).Length();
2679  break;
2680  }
2681  }
2682  }
2683  else if (ppEnd.Matches(control->GetCurLine()))
2684  {
2685  int depth = -1; // search backwards
2686  for (int i = control->GetCurrentLine() - 1; i >= 0; --i)
2687  {
2688  if (control->GetLine(i).Find(wxT('#')) != wxNOT_FOUND) // limit testing due to performance cost
2689  {
2690  if (ppIf.Matches(control->GetLine(i))) // ignore else's, elif's, ...
2691  ++depth;
2692  else if (ppEnd.Matches(control->GetLine(i)))
2693  --depth;
2694  }
2695  if (depth == 0)
2696  {
2697  pp.Matches(control->GetLine(i));
2698  matchingBrace = control->PositionFromLine(i) + pp.GetMatch(control->GetLine(i)).Length();
2699  break;
2700  }
2701  }
2702  }
2703  }
2704 
2705  // now, we either found it or not
2706  if (matchingBrace != wxSCI_INVALID_POSITION)
2707  {
2708  // move to the actual position
2709  control->GotoPos(matchingBrace);
2710  control->ChooseCaretX();
2711  // make nearby lines visible
2712  control->MakeNearbyLinesVisible(control->GetCurrentLine());
2713  }
2714 }
2715 
2717 {
2718  cbStyledTextCtrl* control = GetControl();
2719 
2721  int currPos = control->GetCurrentPos();
2722  int newPos = control->BraceMatch(currPos);
2723  if (newPos == wxSCI_INVALID_POSITION)
2724  {
2725  if (currPos > 0)
2726  currPos--;
2727  newPos = control->BraceMatch(currPos);
2728  }
2729  wxChar ch = control->GetCharAt(currPos);
2730  if (ch == _T('{') || ch == _T('[') || ch == _T('(') ||
2731  ch == _T('}') || ch == _T(']') || ch == _T(')'))
2732  {
2733  if (newPos != wxSCI_INVALID_POSITION)
2734  {
2735  control->BraceHighlight(currPos, newPos);
2736  const int currColum = control->GetColumn(currPos);
2737  const int newColum = control->GetColumn(newPos);
2738  control->SetHighlightGuide((currColum < newColum) ? currColum :newColum);
2739  }
2740  else
2741  {
2742  control->BraceBadLight(currPos);
2743  }
2744  }
2745  else
2746  {
2747  control->BraceHighlight(-1, -1);
2748  }
2749 }
2750 
2752 {
2753  cbStyledTextCtrl* control = GetControl();
2754  int currLine = (line == -1)
2755  ? control->LineFromPosition(control->GetCurrentPos())
2756  : line;
2757  wxString text = control->GetLine(currLine);
2758  unsigned int len = text.Length();
2759  int spaceCount = 0;
2760  for (unsigned int i = 0; i < len; ++i)
2761  {
2762  if (text[i] == _T(' '))
2763  {
2764  ++spaceCount;
2765  }
2766  else if (text[i] == _T('\t'))
2767  {
2768  spaceCount += control->GetTabWidth();
2769  }
2770  else
2771  {
2772  break;
2773  }
2774  }
2775  return spaceCount;
2776 }
2777 
2779 {
2781 }
2782 
2783 // Creates a submenu for a Context Menu based on the submenu's specific Id
2785 {
2786  wxMenu* menu = nullptr;
2787  if (id == idInsert)
2788  {
2789  menu = new wxMenu;
2790  menu->Append(idEmptyMenu, _("Empty"));
2791  menu->Enable(idEmptyMenu, false);
2792  }
2793  else if (id == idEdit)
2794  {
2795  menu = new wxMenu;
2796  menu->Append(idUndo, _("Undo"));
2797  menu->Append(idRedo, _("Redo"));
2798  menu->Append(idClearHistory, _("Clear changes history"));
2799  menu->AppendSeparator();
2800  menu->Append(idDelete, _("Delete"));
2801  menu->Append(idSelectAll, _("Select all"));
2802  menu->AppendSeparator();
2803  menu->Append(idUpperCase, _("UPPERCASE"));
2804  menu->Append(idLowerCase, _("lowercase"));
2805 
2806  cbStyledTextCtrl* control = GetControl();
2807 
2808  menu->Enable(idUndo, control->CanUndo());
2809  menu->Enable(idRedo, control->CanRedo());
2810  menu->Enable(idClearHistory, control->CanUndo() || control->CanRedo());
2811 
2812  const bool hasSelection = !control->GetSelectionEmpty();
2813  menu->Enable(idDelete, !control->GetReadOnly() && hasSelection);
2814  menu->Enable(idUpperCase, !control->GetReadOnly() && hasSelection);
2815  menu->Enable(idLowerCase, !control->GetReadOnly() && hasSelection);
2816  }
2817  else if (id == idBookmarks)
2818  {
2819  menu = new wxMenu;
2820  menu->Append(idBookmarksToggle, _("Toggle bookmark"));
2821  menu->Append(idBookmarksPrevious, _("Goto previous bookmark"));
2822  menu->Append(idBookmarksNext, _("Goto next bookmark"));
2823  menu->Append(idBookmarksClearAll, _("Clear all bookmarks"));
2824  }
2825  else if (id == idFolding)
2826  {
2827  menu = new wxMenu;
2828  menu->Append(idFoldingFoldAll, _("Fold all"));
2829  menu->Append(idFoldingUnfoldAll, _("Unfold all"));
2830  menu->Append(idFoldingToggleAll, _("Toggle all"));
2831  menu->AppendSeparator();
2832  menu->Append(idFoldingFoldCurrent, _("Fold current block"));
2833  menu->Append(idFoldingUnfoldCurrent, _("Unfold current block"));
2834  menu->Append(idFoldingToggleCurrent, _("Toggle current block"));
2835  }
2836  else
2838 
2839  return menu;
2840 }
2841 
2842 // Adds menu items to context menu (both before and after loading plugins' items)
2843 void cbEditor::AddToContextMenu(wxMenu* popup,ModuleType type,bool pluginsdone)
2844 {
2845  PluginManager *pluginManager = Manager::Get()->GetPluginManager();
2846  bool noeditor = (type != mtEditorManager);
2847  if (!pluginsdone)
2848  {
2849  wxMenu *bookmarks = nullptr, *folding = nullptr, *editsubmenu = nullptr, *insert = nullptr;
2850  if (!noeditor)
2851  {
2852  insert = CreateContextSubMenu(idInsert);
2853  editsubmenu = CreateContextSubMenu(idEdit);
2854  bookmarks = CreateContextSubMenu(idBookmarks);
2855  if (Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/folding/show_folds"), false))
2856  folding = CreateContextSubMenu(idFolding);
2857  }
2858 
2859  if (editsubmenu)
2860  {
2861  popup->Append(idCut, _("Cut"));
2862  popup->Append(idCopy, _("Copy"));
2863  popup->Append(idPaste, _("Paste"));
2864  popup->Append(idEdit, _("Edit"), editsubmenu);
2865  popup->AppendSeparator();
2866 
2867  cbStyledTextCtrl* control = GetControl();
2868  const bool hasSelection = !control->GetSelectionEmpty();
2869  popup->Enable(idCut, !control->GetReadOnly() && hasSelection);
2870  popup->Enable(idCopy, hasSelection);
2871 
2872  if (platform::gtk) // a wxGTK bug causes the triggering of unexpected events
2873  popup->Enable(idPaste, !control->GetReadOnly());
2874  else
2875  popup->Enable(idPaste, !control->GetReadOnly() && control->CanPaste());
2876  pluginManager->RegisterLastNonPluginMenuItem(idPaste);
2877  }
2878  if (insert)
2879  {
2880  popup->Append(idInsert, _("Insert/Refactor"), insert);
2881  pluginManager->RegisterLastNonPluginMenuItem(idInsert);
2882  }
2883  if (bookmarks)
2884  {
2885  popup->Append(idBookmarks, _("Bookmarks"), bookmarks);
2887  }
2888  if (folding)
2889  {
2890  popup->Append(idFolding, _("Folding"), folding);
2891  pluginManager->RegisterLastNonPluginMenuItem(idFolding);
2892  }
2893 
2894  if (insert || bookmarks || folding)
2895  popup->AppendSeparator();
2896  }
2897  else
2898  {
2899  if (!noeditor && !m_pData->GetUrl().IsEmpty())
2900  {
2901  popup->InsertSeparator(0);
2902  popup->Insert(0, idOpenUrl, _("Open link in browser"));
2903  pluginManager->RegisterFindMenuItems(true, 2);
2904  }
2905  // remove "Insert/Empty" if more than one entry
2906  wxMenu* insert = nullptr;
2907  wxMenuItem* insertitem = popup->FindItem(idInsert);
2908  if (insertitem)
2909  insert = insertitem->GetSubMenu();
2910  if (insert)
2911  {
2912  if (insert->GetMenuItemCount() > 1)
2913  insert->Delete(idEmptyMenu);
2914  }
2915  }
2916 }
2917 
2919 {
2920  bool noeditor = (type != mtEditorManager);
2921  if (!noeditor && position!=wxDefaultPosition)
2922  {
2923  // right mouse click inside the editor
2924 
2925  // because here the focus has not switched yet (i.e. the left control has the focus,
2926  // but the user right-clicked inside the right control), we find out the active control differently...
2927  wxPoint clientpos(ScreenToClient(position));
2928  const int margin = m_pControl->GetMarginWidth(C_LINE_MARGIN) + // numbers, if present
2929  m_pControl->GetMarginWidth(C_MARKER_MARGIN) + // breakpoints, bookmarks... if present
2930  m_pControl->GetMarginWidth(C_FOLDING_MARGIN) + // folding, if present
2931  m_pControl->GetMarginWidth(C_CHANGEBAR_MARGIN); // changebar, if present
2932  wxRect r = m_pControl->GetRect();
2933 
2934  bool inside1 = r.Contains(clientpos);
2935 
2936  cbStyledTextCtrl* control = !m_pControl2 || inside1 ? m_pControl : m_pControl2;
2937 // control->SetFocus();
2938 
2939  clientpos = control->ScreenToClient(position);
2940  if (clientpos.x < margin)
2941  {
2942  // keep the line
2943  int pos = control->PositionFromPoint(clientpos);
2945 
2946  // create special menu
2947  wxMenu* popup = new wxMenu;
2948 
2950  if (plugin && plugin->SupportsFeature(cbDebuggerFeature::Breakpoints))
2951  {
2954 
2955  if (hasBreak || hasBreakDisabled)
2956  {
2957  popup->Append(idBreakpointEdit, _("Edit breakpoint"));
2958  popup->Append(idBreakpointRemove, _("Remove breakpoint"));
2959  if (hasBreak)
2960  popup->Append(idBreakpointDisable, _("Disable breakpoint"));
2961  if (hasBreakDisabled)
2962  popup->Append(idBreakpointEnable, _("Enable breakpoint"));
2963  }
2964  else
2965  popup->Append(idBreakpointAdd, _("Add breakpoint"));
2966  popup->AppendSeparator();
2967  }
2968 
2970  {
2971  popup->Append(idBookmarkRemove, _("Remove bookmark"));
2972  }
2973  else
2974  {
2975  popup->Append(idBookmarkAdd, _("Add bookmark"));
2976  }
2977 
2978  popup->Append(idBookmarkRemoveAll, _("Remove all bookmark"));
2979 
2980  // display menu... wxWindows help says not to force the position
2981  PopupMenu(popup);
2982 
2983  delete popup;
2984  return false;
2985  }
2986 
2987  // before the context menu creation, move the caret to where mouse is
2988 
2989  // get caret position and line from mouse cursor
2990  const int pos = control->PositionFromPoint(control->ScreenToClient(wxGetMousePosition()));
2991 
2992  // this re-enables 1-click "Find declaration of..."
2993  // but avoids losing selection for cut/copy
2994  if (control->GetSelectionStart() > pos ||
2995  control->GetSelectionEnd() < pos)
2996  {
2997  control->GotoPos(pos);
2998  }
2999  }
3000 
3001  // follow default strategy
3002  return EditorBase::OnBeforeBuildContextMenu(position, type);
3003 }
3004 
3006 {
3007  // we don't care
3008 }
3009 
3010 void cbEditor::Print(bool selectionOnly, PrintColourMode pcm, bool line_numbers)
3011 {
3012  cbStyledTextCtrl * control = GetControl();
3013  if (!control)
3014  return;
3015 
3016  // Remember same settings, so we can restore them.
3017  int oldMarginWidth = control->GetMarginWidth(C_LINE_MARGIN);
3018  int oldMarginType = control->GetMarginType(C_LINE_MARGIN);
3019  int oldEdgeMode = control->GetEdgeMode();
3020 
3021  // print line numbers?
3023  if (!line_numbers)
3024  {
3025  control->SetPrintMagnification(-1);
3026  control->SetMarginWidth(C_LINE_MARGIN, 0);
3027  }
3028  else
3029  {
3030  control->SetPrintMagnification(-2);
3031  control->SetMarginWidth(C_LINE_MARGIN, 1);
3032  }
3033  // never print the gutter line
3034  control->SetEdgeMode(wxSCI_EDGE_NONE);
3035 
3036  switch (pcm)
3037  {
3038  case pcmAsIs:
3040  break;
3041  case pcmBlackAndWhite:
3043  break;
3044  case pcmColourOnWhite:
3046  break;
3047  case pcmInvertColours:
3049  break;
3050  default:
3051  break;
3052  }
3053  InitPrinting();
3054  cbEditorPrintout printout(m_Filename, control, selectionOnly);
3055  if (!g_printer->Print(this, &printout, true))
3056  {
3058  {
3059  cbMessageBox(_("There was a problem printing.\n"
3060  "Perhaps your current printer is not set correctly?"), _("Printing"), wxICON_ERROR);
3061  DeInitPrinting();
3062  }
3063  }
3064  else
3065  {
3067  Manager::Get()->GetConfigManager(_T("app"))->Write(_T("/printerdialog/paperid"), (int)ppd->GetPaperId());
3068  Manager::Get()->GetConfigManager(_T("app"))->Write(_T("/printerdialog/paperorientation"), (int)ppd->GetOrientation());
3069  }
3070 
3071  // revert line number settings
3072  control->SetMarginType(C_LINE_MARGIN, oldMarginType);
3073  control->SetMarginWidth(C_LINE_MARGIN, oldMarginWidth);
3074 
3075  // revert gutter settings
3076  control->SetEdgeMode(oldEdgeMode);
3077 
3078  // restore line numbers if needed
3080 }
3081 
3082 // events
3083 
3085 {
3086  cbStyledTextCtrl* control = GetControl();
3087 
3088  // we have a single event handler for all popup menu entries,
3089  // so that we can add/remove options without the need to recompile
3090  // the whole project (almost) but more importantly, to
3091  // *not* break cbEditor's interface for such a trivial task...
3092  const int id = event.GetId();
3093 
3094  if (id == idUndo)
3095  control->Undo();
3096  else if (id == idRedo)
3097  control->Redo();
3098  else if (id == idClearHistory)
3099  control->EmptyUndoBuffer(Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/margin/use_changebar"), true));
3100  else if (id == idCut)
3101  control->Cut();
3102  else if (id == idCopy)
3103  control->Copy();
3104  else if (id == idPaste)
3105  control->Paste();
3106  else if (id == idDelete)
3107  control->ReplaceSelection(wxEmptyString);
3108  else if (id == idUpperCase)
3109  control->UpperCase();
3110  else if (id == idLowerCase)
3111  control->LowerCase();
3112  else if (id == idSelectAll)
3113  control->SelectAll();
3114  else if (id == idSwapHeaderSource)
3116  else if (id == idOpenContainingFolder)
3118  else if (id == idBookmarkAdd)
3120  else if (id == idBookmarkRemove)
3122  else if (id == idBookmarkRemoveAll)
3123  control->MarkerDeleteAll(BOOKMARK_MARKER);
3124  else if (id == idBookmarksToggle)
3126  else if (id == idBookmarksNext)
3128  else if (id == idBookmarksPrevious)
3130  else if (id == idBookmarksClearAll)
3131  control->MarkerDeleteAll(BOOKMARK_MARKER);
3132  else if (id == idFoldingFoldAll)
3133  FoldAll();
3134  else if (id == idFoldingUnfoldAll)
3135  UnfoldAll();
3136  else if (id == idFoldingToggleAll)
3137  ToggleAllFolds();
3138  else if (id == idFoldingFoldCurrent)
3140  else if (id == idFoldingUnfoldCurrent)
3142  else if (id == idFoldingToggleCurrent)
3144  else if (id == idOpenUrl)
3146  else if (id == idSplitHorz)
3148  else if (id == idSplitVert)
3149  Split(stVertical);
3150  else if (id == idUnsplit)
3151  Unsplit();
3152  else if (id == idProperties)
3153  {
3154  if (m_pProjectFile)
3155  m_pProjectFile->ShowOptions(this);
3156  else
3157  {
3158  // active editor not-in-project
3159  ProjectFileOptionsDlg dlg(this, GetFilename());
3160  PlaceWindow(&dlg);
3161  dlg.ShowModal();
3162  }
3163  }
3164  else if (id == idAddFileToProject)
3165  {
3167 
3168  wxArrayInt targets;
3169  if (Manager::Get()->GetProjectManager()->AddFileToProject(m_Filename, prj, targets) != 0)
3170  {
3171  ProjectFile* pf = prj->GetFileByFilename(m_Filename, false);
3172  SetProjectFile(pf);
3174  }
3175  }
3176  else if (id == idRemoveFileFromProject)
3177  {
3178  if (m_pProjectFile)
3179  {
3183  }
3184  }
3185  else if (id == idShowFileInProject)
3186  {
3188  ui.SwitchToProjectsPage();
3190  }
3191  else if (id == idBreakpointAdd)
3193  else if (id == idBreakpointEdit)
3194  {
3197  }
3198  else if (id == idBreakpointRemove)
3200  else if (id == idBreakpointEnable)
3201  {
3204  }
3205  else if (id == idBreakpointDisable)
3206  {
3209  }
3210  else
3211  event.Skip();
3212  //Manager::Get()->GetLogManager()->DebugLog(_T("Leaving OnContextMenuEntry"));
3213 }
3214 
3216 {
3217  switch (event.GetMargin())
3218  {
3219  case C_MARKER_MARGIN: // bookmarks and breakpoints margin
3220  {
3221  int lineYpix = event.GetPosition();
3222  int line = GetControl()->LineFromPosition(lineYpix);
3223 
3224  ToggleBreakpoint(line);
3225  break;
3226  }
3227  case C_FOLDING_MARGIN: // folding margin
3228  {
3229  int lineYpix = event.GetPosition();
3230  int line = GetControl()->LineFromPosition(lineYpix);
3231 
3232  GetControl()->ToggleFold(line);
3233  break;
3234  }
3235  default:
3236  break;
3237  }
3238  OnScintillaEvent(event);
3239 }
3240 
3242 {
3243  if (Manager::Get()->GetEditorManager()->GetActiveEditor() == this)
3244  {
3246  HighlightBraces(); // brace highlighting
3247  }
3248  OnScintillaEvent(event);
3249 }
3250 
3252 {
3254  OnScintillaEvent(event);
3255 }
3256 
3258 {
3259  // if message manager is auto-hiding, this will close it if not needed open
3260 // Manager::Get()->GetLogManager()->Close();
3261 
3262  m_autoIndentDone = false;
3263  OnScintillaEvent(event); // smart indent plugins will be called here
3264  if (!m_autoIndentDone)
3265  {
3266  const wxChar ch = event.GetKey();
3267  cbStyledTextCtrl* control = GetControl();
3268  // auto indent
3269  if ( (ch == _T('\n')) || ( (control->GetEOLMode() == wxSCI_EOL_CR) && (ch == _T('\r')) ) )
3270  {
3271  const int pos = control->GetCurrentPos();
3272  const int currLine = control->LineFromPosition(pos);
3273  const bool autoIndent = Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/auto_indent"), true);
3274  if (autoIndent && currLine > 0)
3275  {
3276  wxString indent;
3277  if (control->GetCurLine().Trim().IsEmpty())
3278  {
3279  // copy the indentation of the last non-empty line
3280  for (int i = currLine - 1; i >= 0; --i)
3281  {
3282  const wxString& prevLineStr = control->GetLine(i);
3283  if (!(prevLineStr.IsEmpty() || prevLineStr[0] == _T('\n') || prevLineStr[0] == _T('\r')))
3284  {
3285  indent = GetLineIndentString(i);
3286  break;
3287  }
3288  }
3289  }
3290  else
3291  indent = GetLineIndentString(currLine - 1);
3292  if (!indent.IsEmpty())
3293  {
3294  control->BeginUndoAction();
3295 
3296  control->InsertText(pos, indent);
3297  control->GotoPos(pos + indent.Length());
3298  control->ChooseCaretX();
3299 
3300  control->EndUndoAction();
3301  }
3302  }
3303  }
3304 
3305  // selection brace completion
3306  bool braceCompleted = false;
3307  if ( Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/selection_brace_completion"), false)
3308  || control->IsBraceShortcutActive() )
3309  {
3310  braceCompleted = control->DoSelectionBraceCompletion(ch);
3311  }
3312 
3313  // brace completion
3314  if ( !braceCompleted
3315  && Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/brace_completion"), true) )
3316  {
3317  control->DoBraceCompletion(ch);
3318  }
3319  }
3320 }
3321 
3323 {
3324  m_autoIndentDone = true;
3325 }
3326 
3328 {
3329  if ( !wxTheApp->IsActive() )
3330  return;
3331 
3332  cbStyledTextCtrl* control = GetControl();
3333  if (!control)
3334  return;
3335 
3336  wxRect screenRect = control->GetScreenRect();
3337  wxPoint ptEvent(event.GetX(), event.GetY());
3338  ptEvent = control->ClientToScreen(ptEvent);
3339  wxPoint ptScreen = wxGetMousePosition();
3340  wxPoint ptClient = control->ScreenToClient(ptScreen);
3341 
3342  double distance = sqrt( (ptScreen.x - ptEvent.x) * (ptScreen.x - ptEvent.x)
3343  + (ptScreen.y - ptEvent.y) * (ptScreen.y - ptEvent.y) );
3344  if (!screenRect.Contains(ptScreen) || distance > 10)
3345  return;
3346 
3347  int pos = control->PositionFromPoint(ptClient);
3348  int style = control->GetStyleAt(pos);
3349  NotifyPlugins(cbEVT_EDITOR_TOOLTIP, style, wxEmptyString, ptClient.x, ptClient.y);
3350  wxScintillaEvent newEvent(event);
3351  newEvent.SetX(ptClient.x);
3352  newEvent.SetY(ptClient.y);
3353  OnScintillaEvent(event);
3354 }
3355 
3357 {
3359  OnScintillaEvent(event);
3360 }
3361 
3363 {
3364 // wxString txt = _T("OnEditorModified(): ");
3365 // int flags = event.GetModificationType();
3366 // if (flags & wxSCI_MOD_CHANGEMARKER) txt << _T("wxSCI_MOD_CHANGEMARKER, ");
3367 // if (flags & wxSCI_MOD_INSERTTEXT) txt << _T("wxSCI_MOD_INSERTTEXT, ");
3368 // if (flags & wxSCI_MOD_DELETETEXT) txt << _T("wxSCI_MOD_DELETETEXT, ");
3369 // if (flags & wxSCI_MOD_CHANGEFOLD) txt << _T("wxSCI_MOD_CHANGEFOLD, ");
3370 // if (flags & wxSCI_PERFORMED_USER) txt << _T("wxSCI_PERFORMED_USER, ");
3371 // if (flags & wxSCI_MOD_BEFOREINSERT) txt << _T("wxSCI_MOD_BEFOREINSERT, ");
3372 // if (flags & wxSCI_MOD_BEFOREDELETE) txt << _T("wxSCI_MOD_BEFOREDELETE, ");
3373 // txt << _T("pos=")
3374 // << wxString::Format(_T("%d"), event.GetPosition())
3375 // << _T(", line=")
3376 // << wxString::Format(_T("%d"), event.GetLine())
3377 // << _T(", linesAdded=")
3378 // << wxString::Format(_T("%d"), event.GetLinesAdded());
3379 // Manager::Get()->GetLogManager()->DebugLog(txt);
3380 
3381  // whenever event.GetLinesAdded() != 0, we must re-set breakpoints for lines greater
3382  // than LineFromPosition(event.GetPosition())
3383  int linesAdded = event.GetLinesAdded();
3384  bool isAdd = event.GetModificationType() & wxSCI_MOD_INSERTTEXT;
3385  bool isDel = event.GetModificationType() & wxSCI_MOD_DELETETEXT;
3386  if ((isAdd || isDel) && linesAdded != 0)
3387  {
3388  // whether to show line-numbers or not is handled in SetLineNumberColWidth() now
3390 
3391  // NB: I don't think polling for each debugger every time will slow things down enough
3392  // to worry about unless there are automated tasks that call this routine regularly
3393  //
3394  // well, scintilla events happen regularly
3395  // although we only reach this part of the code only if a line has been added/removed
3396  // so, yes, it might not be that bad after all
3397  int startline = m_pControl->LineFromPosition(event.GetPosition());
3398  if (m_pControl == event.GetEventObject())
3399  {
3402  for (DebuggerManager::RegisteredPlugins::const_iterator it = plugins.begin(); it != plugins.end(); ++it)
3403  {
3404  if (it->first != active)
3405  it->first->EditorLinesAddedOrRemoved(this, startline + 1, linesAdded);
3406  }
3407  if (active)
3408  active->EditorLinesAddedOrRemoved(this, startline + 1, linesAdded);
3409 
3411  if (dlg)
3412  dlg->Reload();
3414  }
3415  }
3416  // If we remove the folding-point (the brace or whatever) from a folded block,
3417  // we have to make the hidden lines visible, otherwise, they
3418  // will no longer be reachable, until the editor is closed and reopened again
3419  if ( (event.GetModificationType() & wxSCI_MOD_CHANGEFOLD)
3421  {
3422  cbStyledTextCtrl* control = GetControl();
3423  int line = event.GetLine();
3424  if (! control->GetFoldExpanded(line))
3425  {
3426  control->SetFoldExpanded(line, true);
3427  control->ShowLines(line, control->GetLastChild(line, -1));
3428  }
3429  }
3430  OnScintillaEvent(event);
3431 } // end of OnEditorModified
3432 
3434 {
3435  OnScintillaEvent(event);
3436 }
3437 
3438 void cbEditor::OnClose(cb_unused wxCloseEvent& event)
3439 {
3440  Manager::Get()->GetEditorManager()->Close(this);
3441 }
3442 
3444 {
3445  cbStyledTextCtrl* control = GetControl();
3446  if (control)
3447  control->SendMsg(wxSCI_CMD_TAB);
3448 }
3449 
3451 {
3452  cbStyledTextCtrl* control = GetControl();
3453  if (control)
3454  control->SendMsg(wxSCI_CMD_BACKTAB);
3455 }
3456 
3458 {
3459  ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor"));
3460 
3461  int zoom = GetControl()->GetZoom();
3463  // if all editors should be zoomed, we call cbAuiNotebooks SetZoom()
3464  bool both = Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/zoom_all"));
3465  if (both)
3467 
3469 
3470  if (mgr->ReadBool(_T("/folding/show_folds"), true))
3471  m_pData->SetFoldingColWidth(both);
3472 
3473  OnScintillaEvent(event);
3474 }
3475 
3476 // used to set zoom for both (if splitted) or just the last active control,
3477 // called from cbAuiNotebook
3478 void cbEditor::SetZoom(int zoom, bool both)
3479 {
3480  if (both)
3481  {
3482  if (m_pControl->GetZoom() != zoom)
3483  m_pControl->SetZoom(zoom);
3484  if (m_pControl2 && (m_pControl2->GetZoom() != zoom))
3485  m_pControl2->SetZoom(zoom);
3486  }
3487  else
3488  {
3489  if (GetControl()->GetZoom() != zoom)
3490  GetControl()->SetZoom(zoom);
3491  }
3492 }
3493 
3494 // generic scintilla event handler
3496 {
3497 // wxString txt;
3498 // wxEventType type = event.GetEventType();
3499 // if (type == wxEVT_SCI_CHANGE) txt << _T("wxEVT_SCI_CHANGE");
3500 // else if (type == wxEVT_SCI_STYLENEEDED) txt << _T("wxEVT_SCI_STYLENEEDED");
3501 // else if (type == wxEVT_SCI_CHARADDED) txt << _T("wxEVT_SCI_CHARADDED");
3502 // else if (type == wxEVT_SCI_SAVEPOINTREACHED) txt << _T("wxEVT_SCI_SAVEPOINTREACHED");
3503 // else if (type == wxEVT_SCI_SAVEPOINTLEFT) txt << _T("wxEVT_SCI_SAVEPOINTLEFT");
3504 // else if (type == wxEVT_SCI_ROMODIFYATTEMPT) txt << _T("wxEVT_SCI_ROMODIFYATTEMPT");
3505 // else if (type == wxEVT_SCI_KEY) txt << _T("wxEVT_SCI_KEY");
3506 // else if (type == wxEVT_SCI_DOUBLECLICK) txt << _T("wxEVT_SCI_DOUBLECLICK");
3507 // else if (type == wxEVT_SCI_UPDATEUI) txt << _T("wxEVT_SCI_UPDATEUI");
3508 // else if (type == wxEVT_SCI_MODIFIED) txt << _T("wxEVT_SCI_MODIFIED");
3509 // else if (type == wxEVT_SCI_MACRORECORD) txt << _T("wxEVT_SCI_MACRORECORD");
3510 // else if (type == wxEVT_SCI_MARGINCLICK) txt << _T("wxEVT_SCI_MARGINCLICK");
3511 // else if (type == wxEVT_SCI_NEEDSHOWN) txt << _T("wxEVT_SCI_NEEDSHOWN");
3512 // else if (type == wxEVT_SCI_PAINTED) txt << _T("wxEVT_SCI_PAINTED");
3513 // else if (type == wxEVT_SCI_USERLISTSELECTION) txt << _T("wxEVT_SCI_USERLISTSELECTION");
3514 // else if (type == wxEVT_SCI_URIDROPPED) txt << _T("wxEVT_SCI_URIDROPPED");
3515 // else if (type == wxEVT_SCI_DWELLSTART) txt << _T("wxEVT_SCI_DWELLSTART");
3516 // else if (type == wxEVT_SCI_DWELLEND) txt << _T("wxEVT_SCI_DWELLEND");
3517 // else if (type == wxEVT_SCI_START_DRAG) txt << _T("wxEVT_SCI_START_DRAG");
3518 // else if (type == wxEVT_SCI_DRAG_OVER) txt << _T("wxEVT_SCI_DRAG_OVER");
3519 // else if (type == wxEVT_SCI_DO_DROP) txt << _T("wxEVT_SCI_DO_DROP");
3520 // else if (type == wxEVT_SCI_ZOOM) txt << _T("wxEVT_SCI_ZOOM");
3521 // else if (type == wxEVT_SCI_HOTSPOT_CLICK) txt << _T("wxEVT_SCI_HOTSPOT_CLICK");
3522 // else if (type == wxEVT_SCI_HOTSPOT_DCLICK) txt << _T("wxEVT_SCI_HOTSPOT_DCLICK");
3523 // else if (type == wxEVT_SCI_CALLTIP_CLICK) txt << _T("wxEVT_SCI_CALLTIP_CLICK");
3524 // else if (type == wxEVT_SCI_AUTOCOMP_SELECTION) txt << _T("wxEVT_SCI_AUTOCOMP_SELECTION");
3525 // else if (type == wxEVT_SCI_INDICATOR_CLICK) txt << _T("wxEVT_SCI_INDICATOR_CLICK");
3526 // else if (type == wxEVT_SCI_INDICATOR_RELEASE) txt << _T("wxEVT_SCI_INDICATOR_RELEASE");
3527 // Manager::Get()->GetLogManager()->DebugLog(txt);
3528 
3529  // call any hooked functors
3531  {
3532  EditorHooks::CallHooks(this, event);
3533  }
3534 }
3535 
3537 {
3538  int res = 0;
3539  cbStyledTextCtrl* control = GetControl();
3540  if (control)
3541  res = control->GetLength();
3542  return res > 0;
3543 }
3544 
3546 {
3547  cbStyledTextCtrl* control = GetControl();
3548  if (control)
3549  control->SelectAll();
3550 }
virtual void GotoPreviousBookmark()
Go to previous bookmark.
Definition: cbeditor.cpp:2436
ProjectFile * GetFileByFilename(const wxString &filename, bool isRelative=true, bool isUnixFilename=false)
Access a file of the project.
Definition: cbproject.cpp:1049
#define wxSCI_VS_USERACCESSIBLE
Definition: wxscintilla.h:392
#define wxSCI_MARK_MINUS
Definition: wxscintilla.h:100
static wxFontEncoding GetEncodingFromName(const wxString &encoding)
static int DetectIndentStyle(cbStyledTextCtrl *stc)
Detect the indentation style used in a document.
Definition: cbeditor.cpp:402
wxString F(const wxChar *msg,...)
sprintf-like function
Definition: logmanager.h:20
void IndicatorSetForeground(int indicator, const wxColour &fore)
Set the foreground colour of an indicator.
EVTIMPORT const wxEventType cbEVT_EDITOR_TOOLTIP
Definition: sdk_events.cpp:88
#define ERROR_MARKER
Definition: cbeditor.cpp:67
wxPoint wxGetMousePosition()
virtual const wxString & GetShortName() const
Returns the editor&#39;s short name.
Definition: editorbase.h:58
static void Display(const wxString &title, const wxString &message, unsigned int delay=5000, unsigned int hysteresis=1)
Definition: infowindow.cpp:294
wxPrintOrientation GetOrientation() const
wxApp * wxTheApp
cbStyledTextCtrl * m_pControl
Definition: cbeditor.h:387
wxFontEncoding GetEncoding() const
Definition: cbeditor.cpp:1626
void SelectAll() override
Select everything in the editor.
Definition: cbeditor.cpp:3545
const int idUpperCase
Definition: cbeditor.cpp:513
#define wxSCI_CARET_SLOP
Caret policy, used by SetXCaretPolicy and SetYCaretPolicy.
Definition: wxscintilla.h:347
wxString relativeToCommonTopLevelPath
The relative filename to the common top-level path.
Definition: projectfile.h:135
virtual wxMenu * CreateContextSubMenu(long id)
Creates context submenus.
Definition: editorbase.cpp:219
cbDebuggerPlugin * GetActiveDebugger()
void ReplaceSelection(const wxString &text)
Replace the selected text with the argument text.
#define wxSCI_CMD_HOMEWRAP
Like Home but when word-wrap is enabled goes first to start of display line HomeDisplay, then to start of document line Home.
Definition: wxscintilla.h:2704
int MarkerGet(int line)
Get a bit mask of all the markers set on a line.
void OverrideUseTabsPerLanguage(cbStyledTextCtrl *control)
Definition: cbeditor.cpp:1236
#define BREAKPOINT_DISABLED_MARKER
Definition: cbeditor.cpp:64
#define BREAKPOINT_OTHER_MARKER
Definition: cbeditor.cpp:63
void LowerCase()
Transform the selection to lower case.
void SetDocPointer(void *docPointer)
Change the document object used.
const int idSwapHeaderSource
Definition: cbeditor.cpp:516
virtual bool Detach(wxWindow *window)
#define wxSCI_MARGIN_NUMBER
Definition: wxscintilla.h:151
wxSplitterWindow * m_pSplitter
Definition: cbeditor.h:385
#define wxSCI_MARKNUM_FOLDEROPENMID
Definition: wxscintilla.h:140
const int idBookmarksPrevious
Definition: cbeditor.cpp:520
int GetFoldParent(int line) const
Find the parent line of a child line.
void FoldLine(int line, int action)
Expand or contract a fold header.
void MarkerDefineBitmap(int markerNumber, const wxBitmap &bmp)
Define a marker from a bitmap.
void EnsureVisible(int line)
Ensure a particular line is visible by expanding any header line hiding it.
#define wxSCI_MARK_LCORNER
Definition: wxscintilla.h:105
int wxNewId()
PluginManager * GetPluginManager() const
Definition: manager.cpp:444
void EmptyUndoBuffer(bool collectChangeHistory=false)
Delete the undo history.
void MarkerSetBackground(int markerNumber, const wxColour &back)
Set the background colour used for a particular marker number.
int GetZoom() const
Retrieve the zoom level.
void SetSashPosition(int position, bool redraw=true)
wxString relativeFilename
The relative (to the project) filename of this file.
Definition: projectfile.h:131
const int idBreakpointAdd
Definition: cbeditor.cpp:545
void StyleClearAll()
Clear all the styles and make equivalent to the global default style.
const int idDelete
Definition: cbeditor.cpp:512
bool FromString(const wxString &s)
const int idEdit
Definition: cbeditor.cpp:505
#define wxSCI_MARKNUM_FOLDER
Definition: wxscintilla.h:144
#define wxSCI_MARK_ARROWDOWN
Definition: wxscintilla.h:99
const int idBookmarkRemove
Definition: cbeditor.cpp:542
#define wxSCI_MARK_BACKGROUND
Invisible mark that only sets the line background colour.
Definition: wxscintilla.h:119
int MarkerNext(int lineStart, int markerMask)
Find the next line at or after lineStart that includes a marker in mask.
void SetEOLMode(int eolMode)
Set the current end of line mode.
void Assign(const wxFileName &filepath)
ConfigManager * GetConfigManager(const wxString &name_space) const
Definition: manager.cpp:474
const int idFoldingFoldCurrent
Definition: cbeditor.cpp:527
#define wxSCI_MARKNUM_FOLDEROPEN
Definition: wxscintilla.h:145
void MarkLine(int marker, int line)
Definition: cbeditor.cpp:2635
bool CanRedo() const override
Is there something to redo?
Definition: cbeditor.cpp:2546
int ReadInt(const wxString &name, int defaultVal=0)
bool GetSelectionEmpty() const
Is every selected range empty?
Base class for debugger plugins.
Definition: cbplugin.h:397
virtual bool SplitHorizontally(wxWindow *window1, wxWindow *window2, int sashPosition=0)
virtual void RebuildTree()=0
Rebuild the project manager&#39;s tree.
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
Definition: manager.cpp:182
#define wxSCI_EOL_CR
Definition: wxscintilla.h:84
const int idFoldingFoldAll
Definition: cbeditor.cpp:524
bool FixFoldState()
Fix fold states by comparing foldBackup with m_pControl.
Definition: cbeditor.cpp:1935
void UpperCase()
Transform the selection to upper case.
#define wxSCI_MARGIN_SYMBOL
Definition: wxscintilla.h:150
void OnEditorModified(wxScintillaEvent &event)
Definition: cbeditor.cpp:3362
bool m_IsBuiltinEditor
Definition: editorbase.h:278
void SetX(int val)
Definition: wxscintilla.h:5431
size_t GetLength()
Definition: filemanager.cpp:48
int MarkerPrevious(int lineStart, int markerMask)
Find the previous line before lineStart that includes a marker in mask.
wxMenuItem * InsertSeparator(size_t pos)
#define wxSCI_PRINT_INVERTLIGHT
PrintColourMode - invert the light value of each style for printing.
Definition: wxscintilla.h:247
cbEditorInternalData * m_pData
Definition: cbeditor.h:404
void SetTabIndents(bool tabIndents)
Sets whether a tab pressed when caret is within indentation indents.
const int idEmptyMenu
Definition: cbeditor.cpp:504
void CmdKeyAssign(int key, int modifiers, int cmd)
When key+modifier combination keyDefinition is pressed perform sciCommand.
void Paste()
Paste the contents of the clipboard into the document replacing the selection.
bool GetFoldExpanded(int line) const
Is a header line expanded?
void SetIndentationGuides(int indentView)
Show or hide indentation guides.
void Copy() override
Copy selected text/object to clipboard.
Definition: cbeditor.cpp:2528
#define wxSCI_MARK_VLINE
Shapes used for outlining column.
Definition: wxscintilla.h:104
void MarkerSetForeground(int markerNumber, const wxColour &fore)
Set the foreground colour used for a particular marker number.
#define wxSCI_CMD_VCHOMEEXTEND
Like VCHome but extending selection to new caret position.
Definition: wxscintilla.h:2643
void EnsureFinalLineEnd()
Add extra blank line to the file.
Definition: cbeditor.cpp:174
bool ShowOptions(wxWindow *parent)
Show the file properties dialog.
const int idOpenContainingFolder
Definition: cbeditor.cpp:517
DLLIMPORT bool HasRegisteredHooks()
Are there any hooks registered?
#define wxSCI_CMD_WORDPARTLEFT
Move to the previous change in capitalisation.
Definition: wxscintilla.h:2730
EditorColourSet * m_pTheme
Definition: cbeditor.h:395
void BraceHighlight(int posA, int posB)
Highlight the characters at two positions.
static wxFontEncoding GetDefaultEncoding()
#define wxICON_ERROR
DLLIMPORT wxBitmap cbLoadBitmap(const wxString &filename, wxBitmapType bitmapType=wxBITMAP_TYPE_PNG)
This function loads a bitmap from disk.
Definition: globals.cpp:1102
bool Reload(bool detectEncoding=true)
Reloads the file from disk.
Definition: cbeditor.cpp:1673
void Enable(int id, bool enable)
bool wxFileExists(const wxString &filename)
int editorSplitActive
Last active splitview (1 or 2).
Definition: projectfile.h:154
void GotoLine(int line, bool centerOnScreen=true) override
Move the caret at the specified line.
Definition: cbeditor.cpp:2223
wxFileName file
The full filename of this file.
Definition: projectfile.h:126
void RemoveFileFromProject(ProjectFile *pfile, cbProject *project)
Remove a file from a project.
void EnsureVisibleEnforcePolicy(int line)
Ensure a particular line is visible by expanding any header line hiding it.
int GetColumn(int pos) const
Retrieve the column number of a position, taking tab width into account.
void SetCaretPeriod(int periodMilliseconds)
Get the time in milliseconds that the caret is on and off. 0 = steady on.
void EnsureConsistentLineEnds()
Make sure all the lines end with the same EOL mode.
Definition: cbeditor.cpp:185
void SetColourSet(EditorColourSet *theme)
Set the colour set to use.
Definition: cbeditor.cpp:1620
#define wxSCI_EOL_LF
Definition: wxscintilla.h:85
#define wxSCI_KEYMOD_ALT
Definition: wxscintilla.h:467
void BreakpointMarkerToggle(int line)
Definition: cbeditor.cpp:2265
#define wxSCI_MARK_CIRCLEMINUSCONNECTED
Definition: wxscintilla.h:116
#define wxSCI_FIND_WHOLEWORD
Definition: wxscintilla.h:257
int editorPos_2
The last known caret position in an editor for this file (right/bottom control if split)...
Definition: projectfile.h:169
virtual void ShowFileInTree(ProjectFile &projectFile)=0
PrintColourMode
void SetMarginType(int margin, int marginType)
Set a margin to be either numeric or symbolic.
wxUint8 wxByte
bool GotoTokenPosition(int line, const wxString &tokenName)
Move the caret at the specified line.
Definition: cbeditor.cpp:2240
void SetWhitespaceForeground(bool useSetting, const wxColour &fore)
Set the foreground colour of all whitespace and whether to use this setting.
cbProject * project
Definition: projectfile.h:227
bool DoSelectionBraceCompletion(const wxChar &ch)
Put braces/quotes around the current selection in the editor.
bool IndicatorGetUnder(int indicator) const
Retrieve whether indicator drawn under or over text.
bool ReadBool(const wxString &name, bool defaultVal=false)
virtual void Reload()=0
static wxDateTime Now()
void UnderlineFoldedLines(bool underline)
Definition: cbeditor.cpp:995
void UnfoldAll()
Unfold all editor folds (shows blocks of code).
Definition: cbeditor.cpp:2142
#define wxSCI_FOLDLEVELBASE
Definition: wxscintilla.h:263
const int idClearHistory
Definition: cbeditor.cpp:508
void SetY(int val)
Definition: wxscintilla.h:5432
void SetCaretForeground(const wxColour &fore)
Set the foreground colour of the caret.
DLLIMPORT bool NormalizePath(wxFileName &f, const wxString &base)
Definition: globals.cpp:942
virtual int GetBreakpointsCount() const =0
void Print(bool selectionOnly, PrintColourMode pcm, bool line_numbers)
Print the file.
Definition: cbeditor.cpp:3010
cbStyledTextCtrl * m_pControl2
Definition: cbeditor.h:388
virtual bool IsOk() const
#define wxSCI_C_STRING
Definition: wxscintilla.h:635
FileManager * GetFileManager() const
Definition: manager.cpp:479
void UsePopUp(int popUpMode)
Set whether a pop up menu is displayed automatically when the user presses the wrong mouse button on ...
DLLIMPORT bool GetFilterIndexFromName(const wxString &FiltersList, const wxString &FilterName, int &Index)
Get the index of the filter &#39;FilterName&#39; in the FiltersList.
#define C_CHANGEBAR_MARGIN
Definition: cbeditor.cpp:73
size_t Length() const
int ReplaceTarget(const wxString &text)
Replace the target text with the argument text.
#define wxSCI_MODEVENTMASKALL
Definition: wxscintilla.h:435
cbEditor(wxWindow *parent, const wxString &filename, EditorColourSet *theme)
cbEditor constructor.
Definition: cbeditor.cpp:689
wxCStrData c_str() const
wxString m_Shortname
Definition: editorbase.h:279
void SetSelectionNCaretVirtualSpace(int selection, int space)
Set the virtual space of the caret of the nth selection.
void Paste() override
Paste selected text/object from clipboard.
Definition: cbeditor.cpp:2534
wxMenuItem * Append(int id, const wxString &item=wxEmptyString, const wxString &helpString=wxEmptyString, wxItemKind kind=wxITEM_NORMAL)
long Time() const
void SetText(const wxString &text)
Replace the contents of the document with the argument text.
wxString GetLine(int line) const
Retrieve the contents of a line.
virtual void SwitchToProjectsPage()=0
Switches the management&#39;s notebook to the Projects tab.
void NotifyPlugins(wxEventType type, int intArg=0, const wxString &strArg=wxEmptyString, int xArg=0, int yArg=0)
Definition: cbeditor.cpp:812
bool Matches(const wxString &text, int flags=0) const
bool LineHasMarker(int marker, int line=-1) const
Definition: cbeditor.cpp:2580
bool Open(bool detectEncoding=true)
Definition: cbeditor.cpp:1718
bool m_Modified
Definition: cbeditor.h:391
#define _T(string)
void OnEditorDwellStart(wxScintillaEvent &event)
Definition: cbeditor.cpp:3327
#define wxSCI_VS_RECTANGULARSELECTION
Definition: wxscintilla.h:391
const int idSplitHorz
Definition: cbeditor.cpp:532
static wxString GetEncodingName(wxFontEncoding encoding)
int GetSelectionStart() const
Returns the position at the start of the selection.
void IndicatorSetUnder(int indicator, bool under)
Set an indicator to draw under text or over(default).
wxIntPtr SendMsg(int msg, wxUIntPtr wp=0, wxIntPtr lp=0) const
Send a message to Scintilla.
bool Close(const wxString &filename, bool dontsave=false)
void wxBell()
void SetSelectionNAnchorVirtualSpace(int selection, int space)
Set the virtual space of the anchor of the nth selection.
void Unsplit()
Unsplit the editor window.
Definition: cbeditor.cpp:1185
void SetReadOnly(bool readOnly)
Set to read only or read write.
cbProjectManagerUI & GetUI()
virtual bool HasBookmark(int line) const
Does line has bookmark?
Definition: cbeditor.cpp:2426
const int idBreakpointEdit
Definition: cbeditor.cpp:546
void Cut()
Cut the selection to the clipboard.
void MarkerDelete(int line, int markerNumber)
Delete a marker from a line.
void Cut() override
Cut selected text/object to clipboard.
Definition: cbeditor.cpp:2522
const int idUndo
Definition: cbeditor.cpp:506
#define wxSCI_MARK_CIRCLEMINUS
Definition: wxscintilla.h:115
cbEditorInternalData(cbEditor *owner, LoaderBase *fileLoader=nullptr)
Definition: cbeditor.cpp:100
void SetFoldExpanded(int line, bool expanded)
Show the children of a header line.
void OnEditorChange(wxScintillaEvent &event)
Definition: cbeditor.cpp:3251
bool HasSelection() const override
Is there a selection?
Definition: cbeditor.cpp:2552
void SetFoldMarginColour(bool useSetting, const wxColour &back)
Set one of the colours used as a chequerboard pattern in the fold margin.
EVTIMPORT const wxEventType cbEVT_EDITOR_TOOLTIP_CANCEL
Definition: sdk_events.cpp:89
void DoBraceCompletion(const wxChar &ch)
Automated braces/quotes completion.
const int idFoldingUnfoldCurrent
Definition: cbeditor.cpp:528
EVTIMPORT const wxEventType cbEVT_EDITOR_SPLIT
Definition: sdk_events.cpp:90
bool m_ensure_consistent_line_ends
Definition: cbeditor.cpp:485
void SetModified(bool modified=true) override
Set the editor&#39;s modification state to modified.
Definition: cbeditor.cpp:861
void SetVisiblePolicy(int visiblePolicy, int visibleSlop)
Set the way the display area is determined when a particular line is to be moved to by Find...
virtual void EnableBreakpoint(const wxString &filename, int line, bool enable)=0
wxFontEncoding
bool OpenContainingFolder()
#define wxSCI_MARK_BOXPLUSCONNECTED
Definition: wxscintilla.h:108
#define wxSCI_MARK_CIRCLEPLUSCONNECTED
Definition: wxscintilla.h:114
void SetSavePoint()
Remember the current position in the undo history as the position at which the document was saved...
bool OnBeforeBuildContextMenu(const wxPoint &position, ModuleType type) override
Definition: cbeditor.cpp:2918
const int idFoldingToggleAll
Definition: cbeditor.cpp:526
#define wxT(string)
int GetModificationType() const
Definition: wxscintilla.h:5457
#define wxNOT_FOUND
int editorZoom
The zoom-factor of the editor for this file (left/top control if split).
Definition: projectfile.h:166
#define wxSP_LIVE_UPDATE
#define DEBUG_MARKER
Definition: cbeditor.cpp:68
void * GetDocPointer()
Retrieve a pointer to the document object.
Represents a file in a Code::Blocks project.
Definition: projectfile.h:39
int GetLexer() const
Retrieve the lexing language of the document.
#define wxSCI_CMD_LINEENDWRAP
Like LineEnd but when word-wrap is enabled goes first to end of display line LineEndDisplay, then to start of document line LineEnd.
Definition: wxscintilla.h:2712
int editorPos
The last known caret position in an editor for this file (left/top control if split).
Definition: projectfile.h:160
void HighlightBraces()
Highlights the brace pair (one of the braces must be under the cursor)
Definition: cbeditor.cpp:2716
void IndicatorSetStyle(int indicator, int indicatorStyle)
Set an indicator to plain, squiggle or TT.
size_t GetMenuItemCount() const
#define wxSCI_CARET_EVEN
If CARET_EVEN is not set, instead of having symmetrical UZs, the left and bottom UZs are extended up ...
Definition: wxscintilla.h:362
int GetFoldLevelPrev() const
Definition: wxscintilla.h:5464
size_t find(const wxString &str, size_t nStart=0) const
A generic Code::Blocks event.
Definition: sdk_events.h:20
#define wxSCI_CARET_STRICT
If CARET_STRICT is set, the policy is enforced...
Definition: wxscintilla.h:352
#define wxSCI_MARKNUM_FOLDERSUB
Definition: wxscintilla.h:143
int GetLineEndPosition(int line) const
Get the position after the last visible characters on a line.
#define wxSCI_CMD_BACKTAB
Dedent the selected lines.
Definition: wxscintilla.h:2630
#define wxSCI_CMD_VCHOMEWRAPEXTEND
Like VCHomeExtend but when word-wrap is enabled extends first to start of display line VCHomeDisplayE...
Definition: wxscintilla.h:2724
DLLIMPORT bool GetFilterNameFromIndex(const wxString &FiltersList, int Index, wxString &FilterName)
Get the Filter name for the Index-th filter in the FiltersList.
void DoFoldAll(FoldMode fold)
Definition: cbeditor.cpp:1988
void SetZoom(int zoom)
Set zoomfactor for builtin editors.
Definition: cbauibook.cpp:228
const int idFoldingUnfoldAll
Definition: cbeditor.cpp:525
EditorManager * GetEditorManager() const
Definition: manager.cpp:434
void SetEncoding(wxFontEncoding encoding)
Definition: cbeditor.cpp:1639
int ContractedFoldNext(int lineStart)
Find the next line at or after lineStart that is a contracted fold header line.
void SetProperty(const wxString &key, const wxString &value)
Set up a value that may be used by a lexer for some optional feature.
void DestroySplitView()
Definition: cbeditor.cpp:828
#define wxSCI_CMD_LINEENDWRAPEXTEND
Like LineEndExtend but when word-wrap is enabled extends first to end of display line LineEndDisplayE...
Definition: wxscintilla.h:2716
void SetCaretLineVisible(bool show)
Display the background of the line containing the caret in a different colour.
int FindChangedLine(const int fromLine, const int toLine) const
Find a changed line, if fromLine > toLine search is performed backwards.
wxDateTime GetLastFocusTime() const
#define wxSCI_CMD_WORDPARTRIGHTEXTEND
Move to the next change in capitalisation extending selection to new caret position.
Definition: wxscintilla.h:2741
#define wxSCI_KEYMOD_SHIFT
Definition: wxscintilla.h:465
wxPrinter * g_printer
Try to detect the encoding of a file on disk.
wxMenu * CreateContextSubMenu(long id) override
Creates context submenus.
Definition: cbeditor.cpp:2784
#define wxSCI_FOLDLEVELHEADERFLAG
Definition: wxscintilla.h:265
void GotoNextChanged() override
Goto next changed line.
Definition: cbeditor.cpp:2478
#define wxSCI_CMD_TAB
If selection is empty or all on one line replace the selection with a tab character.
Definition: wxscintilla.h:2627
wxUSE_UNICODE_dependent wxChar
#define wxSCI_KEY_HOME
Definition: wxscintilla.h:448
wxString GetSelectedText()
Retrieve the selected text.
#define wxSCI_CMD_WORDLEFTEXTEND
Move caret left one word extending selection to new caret position.
Definition: wxscintilla.h:2572
int editorSplitPos
Last splitter position.
Definition: projectfile.h:157
void MarkerNext(int marker)
Definition: cbeditor.cpp:2597
void SetWrapMode(int wrapMode)
Sets whether text is word wrapped.
#define wxSCI_VS_NONE
Definition: wxscintilla.h:390
bool CanPaste() const
Will a paste succeed?
#define wxSCI_C_STRINGEOL
Definition: wxscintilla.h:641
ProjectManager * GetProjectManager() const
Functions returning pointers to the respective sub-manager instances.
Definition: manager.cpp:429
#define wxSCI_STYLE_LINENUMBER
Definition: wxscintilla.h:164
cbStyledTextCtrl * m_foldBackup
Definition: cbeditor.h:389
void SetChangeCollection(bool collectChange) override
Definition: cbeditor.cpp:2516
PluginManager manages plugins.
Definition: pluginmanager.h:76
const wxString space(_T(" "))
void DoFoldBlockFromLine(int line, FoldMode fold, unsigned foldFlags)
Definition: cbeditor.cpp:2096
wxPrintData & GetPrintData()
const int idPaste
Definition: cbeditor.cpp:511
bool Contains(int x, int y) const
virtual void SetErrorLine(int line)
Highlight the specified line as error.
Definition: cbeditor.cpp:2455
const int idAddFileToProject
Definition: cbeditor.cpp:536
void Write(const wxString &name, const wxString &value, bool ignoreEmpty=false)
DebuggerManager * GetDebuggerManager() const
Definition: manager.cpp:484
wxPaperSize GetPaperId() const
void ShowLines(int lineStart, int lineEnd)
Make a range of lines visible.
int editorTopLine
The last known caret line in an editor for this file (left/top control if split). ...
Definition: projectfile.h:163
virtual const wxString & GetFilename() const
Get the editor&#39;s filename (if applicable).
Definition: editorbase.h:45
void SetLanguage(HighlightLanguage lang, bool colourise)
Sets the language for this editor.
Definition: cbeditor.cpp:1704
DLLIMPORT wxString UnixFilename(const wxString &filename, wxPathFormat format=wxPATH_NATIVE)
Definition: globals.cpp:228
void SetMarginWidth(int margin, int pixelWidth)
Set the width of a margin to a width expressed in pixels.
wxString GetExt() const
void SetZoom(int zoomInPoints)
Set the zoom level.
wxBoxSizer * m_pSizer
Definition: cbeditor.h:386
void SetAdditionalSelectionTyping(bool additionalSelectionTyping)
Set whether typing can be performed into multiple selections.
Represents a Code::Blocks project.
Definition: cbproject.h:96
virtual void InitFilename(const wxString &filename)
Initializes filename data.
Definition: editorbase.cpp:84
void OnClose(wxCloseEvent &event)
Definition: cbeditor.cpp:3438
bool SaveAs() override
Save editor contents under a different filename.
Definition: cbeditor.cpp:1846
int GetEOLMode() const
Retrieve the current end of line mode - one of wxSCI_EOL_CRLF, wxSCI_EOL_CR, or wxSCI_EOL_LF.
int GetLineIndentInSpaces(int line=-1) const
Returns the specified line&#39;s (0-based) indentation (whitespace) in spaces.
Definition: cbeditor.cpp:2751
int GetCurrentLine()
Manually declared methods.
void OnUserListSelection(wxScintillaEvent &event)
Definition: cbeditor.cpp:3433
void SetDimension(int x, int y, int width, int height)
void Copy()
Copy the selection to the clipboard.
#define wxSCI_FIND_MATCHCASE
Definition: wxscintilla.h:258
void SetReadOnly(bool readonly=true) override
Set the editor read-only.
Definition: cbeditor.cpp:2574
#define wxSCI_FOLDACTION_EXPAND
Definition: wxscintilla.h:271
#define wxSCI_IV_LOOKBOTH
Definition: wxscintilla.h:241
#define wxSCI_KEYMOD_CTRL
Definition: wxscintilla.h:466
void SetViewEOL(bool visible)
Make the end of line characters visible or invisible.
null_pointer_t nullptr
Definition: nullptr.cpp:16
cbStyledTextCtrl * GetControl() const
Returns a pointer to the underlying cbStyledTextCtrl object (which itself is the wxWindows implementa...
Definition: cbeditor.cpp:842
virtual bool HasBreakpoint(int line) const
Does line has debugger breakpoint? If line is -1, use current line.
Definition: cbeditor.cpp:2357
bool m_autoIndentDone
Definition: cbeditor.h:398
#define wxSCI_CMD_VCHOMEWRAP
Like VCHome but when word-wrap is enabled goes first to start of display line VCHomeDisplay, then behaves like VCHome.
Definition: wxscintilla.h:2720
#define BOOKMARK_STYLE
Definition: cbeditor.cpp:58
wxColour GetColour(const wxString &id) const
bool SetNativeFontInfo(const wxString &info)
ModuleType
The type of module offering a context menu.
Definition: globals.h:38
#define wxSCI_MARKNUM_FOLDEREND
Definition: wxscintilla.h:139
wxFontEncoding m_encoding
Definition: cbeditor.cpp:493
void Empty()
virtual const wxString & GetTitle() const
Read the target&#39;s title.
int editorSplit
Split type of the editor as int.
Definition: projectfile.h:151
void BraceBadLight(int pos)
Highlight the character at a position indicating there is no matching brace.
#define wxSCI_PRINT_BLACKONWHITE
PrintColourMode - force black text on white background for printing.
Definition: wxscintilla.h:250
virtual void RefreshBreakpointMarkers()
Refresh all markers for the breakpoints (only the markers for the current debugger will be shown) ...
Definition: cbeditor.cpp:2379
const int idSplitVert
Definition: cbeditor.cpp:533
int GetTabWidth() const
Retrieve the visible size of a tab.
virtual bool AddBreakpoint(cbDebuggerPlugin *plugin, const wxString &filename, int line)=0
wxSizerItem * Add(wxWindow *window, const wxSizerFlags &flags)
int GetFoldLevel(int line) const
Retrieve the fold level of a line.
bool IsReadOnly() const override
Is the editor read-only?
Definition: cbeditor.cpp:2568
size_t Replace(const wxString &strOld, const wxString &strNew, bool replaceAll=true)
const int idBookmarks
Definition: cbeditor.cpp:518
#define wxSCI_LEX_YAML
Definition: wxscintilla.h:523
#define wxSCI_CMD_WORDPARTLEFTEXTEND
Move to the previous change in capitalisation extending selection to new caret position.
Definition: wxscintilla.h:2734
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt=true)
int IndicatorGetStyle(int indicator) const
Retrieve the style of an indicator.
#define wxSCI_CMD_HOME
Move caret to first position on line.
Definition: wxscintilla.h:2581
bool AddBreakpoint(int line=-1, bool notifyDebugger=true)
Add debugger breakpoint at specified line.
Definition: cbeditor.cpp:2276
void MarkerDeleteAll(int markerNumber)
Delete all markers with a particular number from all lines.
const wxSize wxDefaultSize
bool GetModify() const
Is the document different from when it was last saved?
#define wxSCI_CMD_WORDPARTRIGHT
Move to the change next in capitalisation.
Definition: wxscintilla.h:2737
const wxPoint wxDefaultPosition
void Redo() override
Redo changes.
Definition: cbeditor.cpp:2466
const int idFoldingToggleCurrent
Definition: cbeditor.cpp:529
void SetChangeCollection(bool collectChange)
Choose between collecting actions into the changes history and discarding them.
virtual void ToggleBookmark(int line=-1)
Toggle bookmark at specified line.
Definition: cbeditor.cpp:2374
virtual void ClearAllBookmarks()
Clear all bookmarks.
Definition: cbeditor.cpp:2441
#define wxSCI_PRINT_COLOURONWHITE
PrintColourMode - text stays coloured, but all background is forced to be white for printing...
Definition: wxscintilla.h:253
cbEditor * m_pOwner
Definition: cbeditor.cpp:98
bool CanUndo() const override
Is there something to undo?
Definition: cbeditor.cpp:2540
static const wxString sep
bool GetMatch(size_t *start, size_t *len, size_t index=0) const
wxMenuItem * AppendSeparator()
int FindText(int minPos, int maxPos, const wxString &text, int flags=0, int *findEnd=NULL)
Find some text in the document.
Base class that all "editors" should inherit from.
Definition: editorbase.h:30
LogManager * GetLogManager() const
Definition: manager.cpp:439
bool m_IsOK
Definition: cbeditor.h:384
int GetCurrentPos() const
Returns the position of the caret.
bool SetItemMinSize(wxWindow *window, int width, int height)
wxString & Truncate(size_t len)
cbProject * GetActiveProject()
Retrieve the active project.
wxString Read(const wxString &key, const wxString &defaultVal=wxEmptyString)
EVTIMPORT const wxEventType cbEVT_EDITOR_UPDATE_UI
Definition: sdk_events.cpp:92
int GetLength() const
Returns the number of bytes in the document.
void OnZoom(wxScintillaEvent &event)
Definition: cbeditor.cpp:3457
virtual wxString GetBasePath() const
Read the target&#39;s base path, e.g. if GetFilename() returns "/usr/local/bin/xxx", base path will retur...
bool Delete(int id)
#define wxSCI_MARKNUM_CHANGESAVED
Definition: wxscintilla.h:137
void StripTrailingSpaces()
Strip trailing blanks before saving.
Definition: cbeditor.cpp:145
int SetSelectionInt(int caret, int anchor)
Set a simple selection.
static int DetectLineEnds(cbStyledTextCtrl *control)
Definition: cbeditor.cpp:635
void SetCaretStyle(int caretStyle)
Set the style of the caret to be drawn.
cbStyledTextCtrl * CreateEditor()
Definition: cbeditor.cpp:1002
void SetFoldingIndicator(int id)
Sets the type of folding indicator where id is one of the following: 0->Arrow, 1->Circle, 2->Square, 3->simple.
Definition: cbeditor.cpp:2152
size_t find_last_not_of(const wxString &str, size_t nStart=npos) const
const int idFolding
Definition: cbeditor.cpp:523
void StyleSetFont(int styleNum, const wxFont &font)
Set style size, face, bold, italic, and underline attributes from a wxFont&#39;s attributes.
virtual int ShowModal()
#define wxSCI_LEX_MAKEFILE
Definition: wxscintilla.h:488
static void InternalSetEditorStyleAfterFileOpen(cbStyledTextCtrl *control)
Definition: cbeditor.cpp:1551
void GotoMatchingBrace()
Jumps to the matching brace (if there is one).
Definition: cbeditor.cpp:2643
void SetMarginSensitive(int margin, bool sensitive)
Make a margin sensitive or insensitive to mouse clicks.
const int idSelectAll
Definition: cbeditor.cpp:515
int editorTopLine_2
The last known caret line in an editor for this file(right/bottom control if split).
Definition: projectfile.h:172
void OnAfterBuildContextMenu(ModuleType type) override
Definition: cbeditor.cpp:3005
const int idBookmarksToggle
Definition: cbeditor.cpp:519
void OnMarginClick(wxScintillaEvent &event)
Definition: cbeditor.cpp:3215
static wxFontEncoding GetSystemEncoding()
wxString GetTextRange(int startPos, int endPos)
Retrieve a range of text.
#define wxSCI_FOLDACTION_TOGGLE
Definition: wxscintilla.h:272
#define wxSCI_EDGE_NONE
Definition: wxscintilla.h:317
int GetAnchor() const
Returns the position of the opposite end of the selection to the caret.
LoaderBase * m_pFileLoader
Definition: cbeditor.cpp:500
void OnScintillaEvent(wxScintillaEvent &event)
notify all the registered EditorHook functions
Definition: cbeditor.cpp:3495
static wxString GetLineIndentString(int line, cbStyledTextCtrl *stc)
Definition: cbeditor.cpp:375
#define wxSCI_LEX_CPP
Definition: wxscintilla.h:480
wxString wxEmptyString
const int idInsert
Definition: cbeditor.cpp:530
const int idBreakpointRemove
Definition: cbeditor.cpp:547
#define wxSP_NOBORDER
void MarkerPrevious(int marker)
Definition: cbeditor.cpp:2616
const long idBreakpointDisable
Definition: cbeditor.cpp:549
#define wxSCI_CMD_WORDLEFT
Move caret left one word.
Definition: wxscintilla.h:2569
wxString GetCurLine(int *linePos=NULL)
Retrieve the text of the line containing the caret.
#define wxSCI_CMD_WORDRIGHT
Move caret right one word.
Definition: wxscintilla.h:2575
void SetMultiPaste(int multiPaste)
Change the effect of pasting when there are multiple selections.
int GetEdgeMode() const
Retrieve the edge highlight mode.
#define wxSCI_CMD_VCHOME
Move caret to before first visible character on line.
Definition: wxscintilla.h:2640
void NotifyPlugins(CodeBlocksEvent &event)
void SetMouseDwellTime(int periodMilliseconds)
Sets the time the mouse must sit still to generate a mouse dwell event.
#define wxSCI_IV_NONE
Definition: wxscintilla.h:238
#define C_FOLDING_MARGIN
Definition: cbeditor.cpp:74
void SetModEventMask(int eventMask)
Set which document modification events are sent to the container.
const int idBookmarkRemoveAll
Definition: cbeditor.cpp:543
bool CanUndo() const
Are there any undoable actions in the undo history?
void SetZoom(int zoom)
bool editorOpen
If true, the file is open inside an editor.
Definition: projectfile.h:148
static bool Access(const wxString &name, wxFile::OpenMode mode)
const wxString & _(const wxString &string)
wxString & Trim(bool fromRight=true)
void SetLineNumberColWidth(bool both=true)
Set line number column width.
Definition: cbeditor.cpp:193
virtual void EditorLinesAddedOrRemoved(cbEditor *editor, int startline, int lines)
Notify the debugger that lines were added or removed in an editor.
Definition: cbplugin.cpp:373
int GetSelectionEnd() const
Returns the position at the end of the selection.
const int idOpenUrl
Definition: cbeditor.cpp:539
#define wxSCI_CMD_WORDRIGHTEXTEND
Move caret right one word extending selection to new caret position.
Definition: wxscintilla.h:2578
void SetViewWhiteSpace(int viewWS)
Make white space characters invisible, always visible or visible outside indentation.
int GetSashPosition() const
const int idBookmarkAdd
Definition: cbeditor.cpp:541
#define wxSCI_MOD_INSERTTEXT
Notifications Type of modification and the action which caused the modification.
Definition: wxscintilla.h:413
std::map< cbDebuggerPlugin *, PluginData > RegisteredPlugins
wxColour GetCaretLineBackground() const
Get the colour of the background of the line containing the caret.
#define wxSCI_MARK_BOXMINUS
Definition: wxscintilla.h:109
#define cbAssert(expr)
Definition: cbexception.h:48
void SetFoldingColWidth(bool both=true)
Definition: cbeditor.cpp:280
void MakeNearbyLinesVisible(int line)
Scroll minimum amount such that 2 lines above and below line are shown.
#define wxSCI_FOLDACTION_CONTRACT
Definition: wxscintilla.h:270
static void Yield()
Whenever you need to call wxYield(), call Manager::Yield(). It&#39;s safer.
Definition: manager.cpp:221
void RegisterLastNonPluginMenuItem(int id)
Called by the editor code which adds the non-plugin related menu items to store the id of the last fi...
cb_must_consume_result LoaderBase * Load(const wxString &file, bool reuseEditors=false)
Loads a file, once this function is called, the actually loading process is done in the worker thread...
#define wxSCI_STYLE_DEFAULT
Styles in range 32..38 are predefined for parts of the UI and are not used as normal styles...
Definition: wxscintilla.h:163
void SetScrollWidthTracking(bool tracking)
Sets whether the maximum width line displayed is used to set scroll width.
int PositionFromPoint(wxPoint pt) const
Find the position from a point within the window.
wxArray< int > wxArrayInt
#define wxSCI_KEY_LEFT
Definition: wxscintilla.h:446
int BraceMatch(int pos, int maxReStyle=0)
Find the position of a matching brace or wxSCI_INVALID_POSITION if no match.
static void ApplyStyles(cbStyledTextCtrl *control)
Apply the editor defaults to any (possibly foreign) cbStyledTextCtrl.
Definition: cbeditor.cpp:1309
int PositionFromLine(int line) const
Retrieve the position at the start of a line.
void DoInitializations(const wxString &filename, LoaderBase *fileLdr=nullptr)
Definition: cbeditor.cpp:745
void ScrollToColumn(int column)
Scroll enough to make the given column visible.
static bool IsBusy()
For use with plugins.
void UnfoldBlockFromLine(int line=-1)
Unfolds the block containing line.
Definition: cbeditor.cpp:2209
static wxString GetDataFolder(bool global=true)
const int idRemoveFileFromProject
Definition: cbeditor.cpp:537
void Colourise(int start, int end)
Colourise a segment of the document using the current lexing language.
DLLIMPORT wxString GetFilterString(const wxString &ext=wxEmptyString)
Generates and returns the filter string for use in file dialogs.
Definition: filefilters.cpp:60
#define wxSCI_CMD_HOMEEXTEND
Move caret to first position on line extending selection to new caret position.
Definition: wxscintilla.h:2584
void SetZoom(int zoom, bool both=true)
Definition: cbeditor.cpp:3478
DLLIMPORT void DeInitPrinting()
#define wxSCI_INDIC_MAX
Definition: wxscintilla.h:233
HighlightLanguage m_lang
Definition: cbeditor.h:396
ColourManager * GetColourManager() const
Definition: manager.cpp:489
void SetPrintMagnification(int magnification)
Sets the print magnification added to the point size of each style for printing.
void Redo()
Redoes the next action on the undo history.
#define wxSCI_CMD_LINEENDEXTEND
Move caret to last position on line extending selection to new caret position.
Definition: wxscintilla.h:2590
wxString GetEncodingName() const
Definition: cbeditor.cpp:1634
#define wxSCI_MARKNUM_FOLDERTAIL
Definition: wxscintilla.h:142
void SetTabWidth(int tabWidth)
Change the visible size of a tab to be a multiple of the width of a space character.
bool SaveFoldState()
Save fold states within a new cbStyledTextCtrl.
Definition: cbeditor.cpp:1920
void SetMinimumPaneSize(int paneSize)
void Touch()
Sets the last modification time for the file to &#39;now&#39;.
Definition: cbeditor.cpp:1699
void SetProjectFile(ProjectFile *project_file, bool preserve_modified=false)
Set the ProjectFile pointer associated with this editor.
Definition: cbeditor.cpp:885
void SetEditorStyleBeforeFileOpen()
Definition: cbeditor.cpp:1257
bool GetReadOnly() const
In read-only mode?
void SelectAll()
Select all the text in the document.
void HideLines(int lineStart, int lineEnd)
Make a range of lines invisible.
#define wxSCI_LEX_PYTHON
Definition: wxscintilla.h:479
A file editor.
Definition: cbeditor.h:43
virtual int FindItem(const wxString &itemString) const
void MarkerToggle(int marker, int line=-1)
Definition: cbeditor.cpp:2587
void InsertText(int pos, const wxString &text)
Insert string at a position.
bool IsEmpty() const
int GetCharAt(int pos) const
Returns the character byte at the position.
DLLIMPORT void PlaceWindow(wxTopLevelWindow *w, cbPlaceDialogMode mode=pdlBest, bool enforce=false)
Definition: globals.cpp:1177
ProjectFile * m_pProjectFile
Definition: cbeditor.h:394
void FoldAll()
Fold all editor folds (hides blocks of code).
Definition: cbeditor.cpp:2137
void MarkerDefine(int markerNumber, int markerSymbol, const wxColour &foreground=wxNullColour, const wxColour &background=wxNullColour)
Set the symbol used for a particular marker number, and optionally the fore and background colours...
const int idSplit
Definition: cbeditor.cpp:531
virtual void SetTitle(const wxString &newTitle)
Set the editor&#39;s title.
Definition: editorbase.cpp:149
#define wxSCI_KEY_END
Definition: wxscintilla.h:449
void EndUndoAction()
End a sequence of actions that is undone and redone as a unit.
RegisteredPlugins const & GetAllDebuggers() const
wxString GetPath(int flags=wxPATH_GET_VOLUME, wxPathFormat format=wxPATH_NATIVE) const
const int idCut
Definition: cbeditor.cpp:509
wxColour IndicatorGetForeground(int indicator) const
Retrieve the foreground colour of an indicator.
void FoldBlockFromLine(int line=-1)
Folds the block containing line.
Definition: cbeditor.cpp:2202
bool GetLineVisible(int line) const
Is a line visible?
static void CountLineEnds(cbStyledTextCtrl *control, int &linesCR, int &linesLF, int &linesCRLF)
Definition: cbeditor.cpp:600
void Start(long milliseconds=0)
~cbEditor() override
cbEditor destructor.
Definition: cbeditor.cpp:725
cbAuiNotebook * GetNotebook()
Definition: editormanager.h:73
size_t Len() const
void SetEdgeColumn(int column)
Set the column number of the edge.
virtual cb::shared_ptr< cbBreakpoint > GetBreakpoint(int index)=0
cbBreakpointsDlg * GetBreakpointDialog()
Returns a pointer to the breakpoints dialog.
void SetBackSpaceUnIndents(bool bsUnIndents)
Sets whether a backspace pressed when caret is within indentation unindents.
#define C_MARKER_MARGIN
Definition: cbeditor.cpp:72
DLLIMPORT wxString GetEOLStr(int eolMode=-1)
Reads settings if eolMode is -1 Expected input (defined in sdk/wxscintilla/include/wx/wxscintilla.h) is: wxSCI_EOL_CRLF=0, wxSCI_EOL_CR=1, or wxSCI_EOL_LF=2.
Definition: globals.cpp:812
int GetMargin() const
Definition: wxscintilla.h:5465
void Log(const wxString &msg, int i=app_log, Logger::level lv=Logger::info)
Definition: logmanager.h:140
int LineLength(int line) const
How many characters are on a line, including end of line characters?
void GotoPos(int caret)
Set caret to a position and ensure it is visible.
wxString GetFullName() const
int GetMarginMask(int margin) const
Retrieve the marker mask of a margin.
wxString GetLineIndentString(int line=-1) const
Returns the specified line&#39;s (0-based) indentation (whitespace) string.
Definition: cbeditor.cpp:2778
int GetBOMSizeInBytes() const
void OnContextMenuEntry(wxCommandEvent &event)
Definition: cbeditor.cpp:3084
#define wxSCI_INVALID_POSITION
Definition: wxscintilla.h:70
#define wxSCI_MARKNUM_CHANGEUNSAVED
Definition: wxscintilla.h:136
void ClearAll()
Delete all text in the document.
EVTIMPORT const wxEventType cbEVT_EDITOR_BEFORE_SAVE
Definition: sdk_events.cpp:85
const int idBookmarksClearAll
Definition: cbeditor.cpp:522
#define wxSCI_MASK_FOLDERS
Definition: wxscintilla.h:147
#define wxSCI_MARKNUM_LASTUNUSED
Definition: wxscintilla.h:132
void SetLanguageDependentColours(cbStyledTextCtrl &control)
Definition: cbeditor.cpp:1225
void SetFoldMarginHiColour(bool useSetting, const wxColour &fore)
Set the other colour used as a chequerboard pattern in the fold margin.
bool UsesBOM() const
void ToggleFold(int line)
Switch a header line between expanded and contracted.
void DebugLog(const wxString &msg, Logger::level lv=Logger::info)
Definition: logmanager.h:146
void SetUseTabs(bool useTabs)
Indentation will only use space characters if useTabs is false, otherwise it will use a combination o...
void RegisterFindMenuItems(bool before, int count)
Can be called by plugins&#39; BuildModuleMenu when building the EditorManager&#39;s context menu...
const int idLowerCase
Definition: cbeditor.cpp:514
const int idBookmarksNext
Definition: cbeditor.cpp:521
void ClearHistory() override
Clear Undo- (and Changebar-) history.
Definition: cbeditor.cpp:2472
DLLIMPORT void InitPrinting()
void AddToContextMenu(wxMenu *popup, ModuleType type, bool pluginsdone) override
Definition: cbeditor.cpp:2843
#define HL_AUTO
Definition: globals.h:166
int MarkerAdd(int line, int markerNumber)
Add a marker to a line, returning an ID which can be used to find or delete the marker.
wxString & Prepend(const wxString &str)
SplitType m_SplitType
Definition: cbeditor.h:390
int GetX() const
Definition: wxscintilla.h:5470
bool CanPaste() const override
Is there something to paste?
Definition: cbeditor.cpp:2559
DLLIMPORT bool cbSaveToFile(const wxString &filename, const wxString &contents, wxFontEncoding encoding=wxFONTENCODING_SYSTEM, bool bom=false)
Writes a wxString to a file.
Definition: globals.cpp:721
void SetHighlightGuide(int column)
Set the highlighted indentation guide column.
#define DEBUG_MARKER_HIGHLIGHT
Definition: cbeditor.cpp:69
const int idShowFileInProject
Definition: cbeditor.cpp:538
void Undo()
Undo one action in the undo history.
void OnEditorUpdateUI(wxScintillaEvent &event)
Definition: cbeditor.cpp:3241
virtual int GetPointSize() const
char * GetData()
Definition: filemanager.cpp:42
wxFont StyleGetFont(int style)
Get the font of a style.
#define wxSCI_LEX_DIFF
Definition: wxscintilla.h:493
int GetStyleAt(int pos) const
Returns the style byte at the position.
#define wxSCI_MARK_TCORNER
Definition: wxscintilla.h:106
#define wxSCI_MARK_ARROW
Definition: wxscintilla.h:95
virtual void SetDebugLine(int line)
Highlight the line the debugger will execute next.
Definition: cbeditor.cpp:2447
void DoIndent()
Indents current line/block.
Definition: cbeditor.cpp:3443
#define wxScintillaEventHandler(func)
Definition: wxscintilla.h:5616
int GetLineCount() const
Returns the number of lines in the document. There is always at least one.
void SetMarkerStyle(int marker, int markerType, wxColor fore, wxColor back)
Definition: cbeditor.cpp:981
cbProject * GetParentProject()
Definition: projectfile.h:93
#define wxSCI_CMD_LINEEND
Move caret to last position on line.
Definition: wxscintilla.h:2587
bool Save() override
Save editor contents.
Definition: cbeditor.cpp:1789
void SetMultipleSelection(bool multipleSelection)
Set whether multiple selections can be made.
int editorZoom_2
The zoom-factor of the editor for this file(right/bottom control if split).
Definition: projectfile.h:175
void SetTargetStart(int start)
Sets the position that starts the target which is used for updating the document without affecting th...
wxString m_Filename
Definition: editorbase.h:280
virtual void ToggleBreakpoint(int line=-1, bool notifyDebugger=true)
Toggle debugger breakpoint at specified line.
Definition: cbeditor.cpp:2322
#define wxSCI_PRINT_NORMAL
PrintColourMode - use same colours as screen.
Definition: wxscintilla.h:244
virtual void GotoNextBreakpoint()
Go to next debugger breakpoint.
Definition: cbeditor.cpp:2364
void ScrollToLine(int line)
Scroll enough to make the given line visible.
#define wxSCI_EOL_CRLF
Definition: wxscintilla.h:83
int LineFromPosition(int pos) const
Retrieve the line containing a position.
wxFontEncoding GetFontEncoding() const
void ChooseCaretX()
Set the last x chosen value to be the caret x position.
#define BREAKPOINT_STYLE
Definition: cbeditor.cpp:59
#define wxSCI_CARETSTYLE_LINE
Definition: wxscintilla.h:381
virtual void GotoPreviousBreakpoint()
Go to previous debugger breakpoint.
Definition: cbeditor.cpp:2369
#define EVT_SCI_ZOOM(id, fn)
Definition: wxscintilla.h:5640
#define wxSCI_MOD_DELETETEXT
Definition: wxscintilla.h:414
void DoUnIndent()
UnIndents current line/block.
Definition: cbeditor.cpp:3450
wxString GetText() const
Retrieve all the text in the document.
bool GetUseBom() const
Definition: cbeditor.cpp:1654
void OnEditorDwellEnd(wxScintillaEvent &event)
Definition: cbeditor.cpp:3356
void Undo() override
Undo changes.
Definition: cbeditor.cpp:2460
#define wxSCI_MARK_PLUS
Definition: wxscintilla.h:101
void AutoComplete()
This method is obsolete, use the abbreviations plugin instead.
Definition: cbeditor.cpp:1983
static void InternalSetEditorStyleBeforeFileOpen(cbStyledTextCtrl *control)
Definition: cbeditor.cpp:1319
int Find(wxUniChar ch, bool fromEnd=false) const
EVTIMPORT const wxEventType cbEVT_EDITOR_OPEN
Definition: sdk_events.cpp:81
int wxEventType
const int idRedo
Definition: cbeditor.cpp:507
int TextWidth(int style, const wxString &text)
Measure the pixel width of some text in a particular style.
int GetMarginWidth(int margin) const
Retrieve the width of a margin in pixels.
void SetTargetEnd(int end)
Sets the position that ends the target which is used for updating the document without affecting the ...
void ConnectEvents(cbStyledTextCtrl *stc)
Definition: cbeditor.cpp:1024
#define BOOKMARK_MARKER
Definition: cbeditor.cpp:66
static wxPrinterError GetLastError()
void Split(SplitType split)
Split the editor window.
Definition: cbeditor.cpp:1084
void ToggleFoldBlockFromLine(int line=-1)
Toggles folding of the block containing line.
Definition: cbeditor.cpp:2216
HighlightLanguage Apply(cbEditor *editor, HighlightLanguage lang, bool colourise)
wxArrayInt editorFoldLinesArray
Fold lines.
Definition: projectfile.h:181
void SetEditorTitle(const wxString &title)
Sets the editor title.
Definition: cbeditor.cpp:877
virtual bool SupportsFeature(cbDebuggerFeature::Flags flag)=0
wxMenu * GetSubMenu() const
void SetEditorStyleAfterFileOpen()
Definition: cbeditor.cpp:1293
const int idUnsplit
Definition: cbeditor.cpp:534
bool wxLaunchDefaultBrowser(const wxString &url, int flags=0)
#define wxSCI_MARK_CIRCLEPLUS
Definition: wxscintilla.h:113
#define wxSCI_MARK_LCORNERCURVE
Definition: wxscintilla.h:111
const long idBreakpointEnable
Definition: cbeditor.cpp:548
#define wxSCI_MARKNUM_FOLDERMIDTAIL
Definition: wxscintilla.h:141
void SetFoldLevel(int line, int level)
Set the fold level of a line.
#define wxSCI_CMD_HOMEWRAPEXTEND
Like HomeExtend but when word-wrap is enabled extends first to start of display line HomeDisplayExten...
Definition: wxscintilla.h:2708
#define wxSCI_FOLDLEVELNUMBERMASK
Definition: wxscintilla.h:266
virtual bool SplitVertically(wxWindow *window1, wxWindow *window2, int sashPosition=0)
#define DEBUG_STYLE_HIGHLIGHT
Definition: cbeditor.cpp:61
int m_Index
Definition: cbeditor.h:392
void SetVirtualSpaceOptions(int virtualSpaceOptions)
Set options for virtual space behaviour.
#define C_LINE_MARGIN
Definition: cbeditor.cpp:71
const int idProperties
Definition: cbeditor.cpp:535
void SetFileState(FileVisualState state)
Set the visual state (modified, read-only, etc).
virtual bool OnBeforeBuildContextMenu(cb_optional const wxPoint &position, cb_optional ModuleType type)
Informs the editor we &#39;re just about to create a context menu.
Definition: editorbase.h:270
void BeginUndoAction()
Start a sequence of actions that is undone and redone as a unit.
#define DEBUG_STYLE
Definition: cbeditor.cpp:60
int Printf(const wxString &pszFormat,...)
EVTIMPORT const wxEventType cbEVT_EDITOR_UNSPLIT
Definition: sdk_events.cpp:91
void SetMarginMask(int margin, int mask)
Set a mask that determines which markers are displayed in a margin.
bool CanSelectAll() const override
Can the editor select everything?
Definition: cbeditor.cpp:3536
virtual void SetWildcard(const wxString &wildCard)
EVTIMPORT const wxEventType cbEVT_EDITOR_SAVE
Definition: sdk_events.cpp:86
virtual bool IsActive() const
wxDateTime GetModificationTime() const
#define wxSCI_MARK_BOXMINUSCONNECTED
Definition: wxscintilla.h:110
void SetFoldFlags(int flags)
Set some style options for folding.
wxString GetFullPath(wxPathFormat format=wxPATH_NATIVE) const
#define wxSCI_MOD_CHANGEFOLD
Definition: wxscintilla.h:416
#define wxSCI_MARK_BOXPLUS
Definition: wxscintilla.h:107
virtual bool RemoveBreakpoint(cbDebuggerPlugin *plugin, const wxString &filename, int line)=0
int wxWindowID
#define wxSCI_KEYMOD_NORM
Definition: wxscintilla.h:464
void SetEdgeColour(const wxColour &edgeColour)
Change the colour used in edge indication.
virtual wxPrintDialogData & GetPrintDialogData() const
bool CanRedo() const
Are there any redoable actions in the undo history?
void SetPrintColourMode(int mode)
Modify colours when printing for clearer printed text.
int GetMarginType(int margin) const
Retrieve the type of a margin.
void SetCaretWidth(int pixelWidth)
Set the width of the insert mode caret.
bool GetModified() const override
Returns true if editor is modified, false otherwise.
Definition: cbeditor.cpp:856
void SetEdgeMode(int edgeMode)
The edge may be displayed by a line (wxSCI_EDGE_LINE/wxSCI_EDGE_MULTILINE) or by highlighting text th...
void OnEditorCharAdded(wxScintillaEvent &event)
Definition: cbeditor.cpp:3257
void GotoLine(int line)
Set caret to start of a line and ensure it is visible.
friend struct cbEditorInternalData
Definition: cbeditor.h:403
void ToggleAllFolds()
Toggle all editor folds (inverts the show/hide state of blocks of code).
Definition: cbeditor.cpp:2147
#define BREAKPOINT_MARKER
Definition: cbeditor.cpp:65
#define wxSCI_MARK_EMPTY
Definition: wxscintilla.h:98
#define wxSCI_MARK_LEFTRECT
Definition: wxscintilla.h:124
virtual void Layout()
#define ERROR_STYLE
Definition: cbeditor.cpp:57
wxMenuItem * Insert(size_t pos, wxMenuItem *menuItem)
void SetYCaretPolicy(int caretPolicy, int caretSlop)
Set the way the line the caret is on is kept visible.
DLLIMPORT int cbMessageBox(const wxString &message, const wxString &caption=wxEmptyString, int style=wxOK, wxWindow *parent=NULL, int x=-1, int y=-1)
wxMessageBox wrapper.
Definition: globals.cpp:1395
void ConvertEOLs(int eolMode)
Convert all line endings in the document to one mode.
wxDateTime m_LastModified
Definition: cbeditor.h:397
EVTIMPORT const wxEventType cbEVT_EDITOR_MODIFIED
Definition: sdk_events.cpp:87
void GotoPreviousChanged() override
Goto previous changed line.
Definition: cbeditor.cpp:2497
bool RemoveBreakpoint(int line=-1, bool notifyDebugger=true)
Remove debugger breakpoint at specified line.
Definition: cbeditor.cpp:2299
void UpdateProjectFile()
Updates the associated ProjectFile object with the editor&#39;s caret position, top visible line and its ...
Definition: cbeditor.cpp:952
const int idCopy
Definition: cbeditor.cpp:510
int GetPosition() const
Definition: wxscintilla.h:5454
void SetEditorStyle()
Applies the styles that match the filename of the editor.
Definition: cbeditor.cpp:1230
void SetUseBom(bool bom)
Definition: cbeditor.cpp:1661
void AutoIndentDone()
Definition: cbeditor.cpp:3322
#define wxSCI_KEY_RIGHT
Definition: wxscintilla.h:447
virtual void EditBreakpoint(const wxString &filename, int line)=0
int GetFirstVisibleLine() const
Retrieve the display line at the top of the display.
DLLIMPORT void CallHooks(cbEditor *editor, wxScintillaEvent &event)
Call all registered hooks using the supplied parameters.
virtual void GotoNextBookmark()
Go to next bookmark.
Definition: cbeditor.cpp:2431
bool SwapActiveHeaderSource()
int GetLastChild(int line, int level) const
Find the last child line of a header line.