MCPcopy Create free account
hub / github.com/dail8859/NotepadNext / EditorManager

Method EditorManager

src/EditorManager.cpp:46–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44
45
46EditorManager::EditorManager(ApplicationSettings *settings, QObject *parent)
47 : QObject(parent), settings(settings)
48{
49 connect(this, &EditorManager::editorCreated, this, [=](ScintillaNext *editor) {
50 connect(editor, &ScintillaNext::closed, this, [=]() {
51 emit editorClosed(editor);
52 });
53 });
54
55 connect(settings, &ApplicationSettings::showWrapSymbolChanged, this, [=](bool b) {
56 for (auto &editor : getEditors()) {
57 editor->setWrapVisualFlags(b ? SC_WRAPVISUALFLAG_END : SC_WRAPVISUALFLAG_NONE);
58 }
59 });
60
61
62 connect(settings, &ApplicationSettings::showWhitespaceChanged, this, [=](bool b) {
63 // TODO: could make SCWS_VISIBLEALWAYS configurable via settings. Probably not worth
64 // taking up menu space e.g. show all, show leading, show trailing
65 for (auto &editor : getEditors()) {
66 editor->setViewWS(b ? SCWS_VISIBLEALWAYS : SCWS_INVISIBLE);
67 }
68 });
69
70 connect(settings, &ApplicationSettings::showEndOfLineChanged, this, [=](bool b) {
71 for (auto &editor : getEditors()) {
72 editor->setViewEOL(b);
73 }
74 });
75
76 connect(settings, &ApplicationSettings::showIndentGuideChanged, this, [=](bool b) {
77 for (auto &editor : getEditors()) {
78 editor->setIndentationGuides(b ? SC_IV_LOOKBOTH : SC_IV_NONE);
79 }
80 });
81
82 connect(settings, &ApplicationSettings::wordWrapChanged, this, [=](bool b) {
83 if (b) {
84 for (auto &editor : getEditors()) {
85 editor->setWrapMode(SC_WRAP_WORD);
86 }
87 }
88 else {
89 for (auto &editor : getEditors()) {
90 // Store the top line and restore it after the lines have been unwrapped
91 int topLine = editor->docLineFromVisible(editor->firstVisibleLine());
92 editor->setWrapMode(SC_WRAP_NONE);
93 editor->setFirstVisibleLine(topLine);
94 }
95 }
96 });
97
98 connect(settings, &ApplicationSettings::fontNameChanged, this, [=](QString fontName){
99 for (auto &editor : getEditors()) {
100 for (int i = 0; i <= STYLE_MAX; ++i) {
101 editor->styleSetFont(i, fontName.toUtf8().data());
102 }
103 }

Callers

nothing calls this directly

Calls 2

dataMethod · 0.45
setEnabledMethod · 0.45

Tested by

no test coverage detected