Changeset View
Changeset View
Standalone View
Standalone View
src/document/katedocument.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | |||||
1022 | { | 1022 | { | ||
1023 | if (editSessionNumber == 0) { | 1023 | if (editSessionNumber == 0) { | ||
1024 | Q_ASSERT(0); | 1024 | Q_ASSERT(0); | ||
1025 | return false; | 1025 | return false; | ||
1026 | } | 1026 | } | ||
1027 | 1027 | | |||
1028 | // wrap the new/changed text, if something really changed! | 1028 | // wrap the new/changed text, if something really changed! | ||
1029 | if (m_buffer->editChanged() && (editSessionNumber == 1)) | 1029 | if (m_buffer->editChanged() && (editSessionNumber == 1)) | ||
1030 | if (m_undoManager->isActive() && config()->wordWrap()) { | 1030 | if (m_undoManager->isActive() && config()->isSet("Word Wrap")) { | ||
1031 | wrapText(m_buffer->editTagStart(), m_buffer->editTagEnd()); | 1031 | wrapText(m_buffer->editTagStart(), m_buffer->editTagEnd()); | ||
1032 | } | 1032 | } | ||
1033 | 1033 | | |||
1034 | editSessionNumber--; | 1034 | editSessionNumber--; | ||
1035 | 1035 | | |||
1036 | if (editSessionNumber > 0) { | 1036 | if (editSessionNumber > 0) { | ||
1037 | return false; | 1037 | return false; | ||
1038 | } | 1038 | } | ||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 1099 | { | |||
1100 | if (startLine < 0 || endLine < 0) { | 1100 | if (startLine < 0 || endLine < 0) { | ||
1101 | return false; | 1101 | return false; | ||
1102 | } | 1102 | } | ||
1103 | 1103 | | |||
1104 | if (!isReadWrite()) { | 1104 | if (!isReadWrite()) { | ||
1105 | return false; | 1105 | return false; | ||
1106 | } | 1106 | } | ||
1107 | 1107 | | |||
1108 | int col = config()->wordWrapAt(); | 1108 | int col = config()->intVal("Word Wrap Column"); | ||
1109 | 1109 | | |||
1110 | if (col == 0) { | 1110 | if (col == 0) { | ||
1111 | return false; | 1111 | return false; | ||
1112 | } | 1112 | } | ||
1113 | 1113 | | |||
1114 | editStart(); | 1114 | editStart(); | ||
1115 | 1115 | | |||
1116 | for (int line = startLine; (line <= endLine) && (line < lines()); line++) { | 1116 | for (int line = startLine; (line <= endLine) && (line < lines()); line++) { | ||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | 1873 | if (mode >= 0) { | |||
1875 | 1875 | | |||
1876 | // restore if set by user, too! see bug 332605, otherwise we loose the hl later again on save | 1876 | // restore if set by user, too! see bug 332605, otherwise we loose the hl later again on save | ||
1877 | m_hlSetByUser = kconfig.readEntry("Highlighting Set By User", false); | 1877 | m_hlSetByUser = kconfig.readEntry("Highlighting Set By User", false); | ||
1878 | } | 1878 | } | ||
1879 | } | 1879 | } | ||
1880 | } | 1880 | } | ||
1881 | 1881 | | |||
1882 | // indent mode | 1882 | // indent mode | ||
1883 | config()->setIndentationMode(kconfig.readEntry("Indentation Mode", config()->indentationMode())); | 1883 | config()->set("Indentation Mode", kconfig.readEntry("Indentation Mode", config()->stringVal("Indentation Mode"))); | ||
1884 | 1884 | | |||
1885 | // Restore Bookmarks | 1885 | // Restore Bookmarks | ||
1886 | const QList<int> marks = kconfig.readEntry("Bookmarks", QList<int>()); | 1886 | const QList<int> marks = kconfig.readEntry("Bookmarks", QList<int>()); | ||
1887 | for (int i = 0; i < marks.count(); i++) { | 1887 | for (int i = 0; i < marks.count(); i++) { | ||
1888 | addMark(marks.at(i), KTextEditor::DocumentPrivate::markType01); | 1888 | addMark(marks.at(i), KTextEditor::DocumentPrivate::markType01); | ||
1889 | } | 1889 | } | ||
1890 | } | 1890 | } | ||
1891 | 1891 | | |||
Show All 27 Lines | 1918 | if (!flags.contains(QStringLiteral("SkipHighlighting"))) { | |||
1919 | // save hl | 1919 | // save hl | ||
1920 | kconfig.writeEntry("Highlighting", highlight()->name()); | 1920 | kconfig.writeEntry("Highlighting", highlight()->name()); | ||
1921 | 1921 | | |||
1922 | // save if set by user, too! see bug 332605, otherwise we loose the hl later again on save | 1922 | // save if set by user, too! see bug 332605, otherwise we loose the hl later again on save | ||
1923 | kconfig.writeEntry("Highlighting Set By User", m_hlSetByUser); | 1923 | kconfig.writeEntry("Highlighting Set By User", m_hlSetByUser); | ||
1924 | } | 1924 | } | ||
1925 | 1925 | | |||
1926 | // indent mode | 1926 | // indent mode | ||
1927 | kconfig.writeEntry("Indentation Mode", config()->indentationMode()); | 1927 | kconfig.writeEntry("Indentation Mode", config()->stringVal("Indentation Mode")); | ||
1928 | 1928 | | |||
1929 | // Save Bookmarks | 1929 | // Save Bookmarks | ||
1930 | QList<int> marks; | 1930 | QList<int> marks; | ||
1931 | for (QHash<int, KTextEditor::Mark *>::const_iterator i = m_marks.constBegin(); i != m_marks.constEnd(); ++i) | 1931 | for (QHash<int, KTextEditor::Mark *>::const_iterator i = m_marks.constBegin(); i != m_marks.constEnd(); ++i) | ||
1932 | if (i.value()->type & KTextEditor::MarkInterface::markType01) { | 1932 | if (i.value()->type & KTextEditor::MarkInterface::markType01) { | ||
1933 | marks << i.value()->line; | 1933 | marks << i.value()->line; | ||
1934 | } | 1934 | } | ||
1935 | 1935 | | |||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | 3245 | } else { | |||
3247 | if (line >= 1) { | 3247 | if (line >= 1) { | ||
3248 | Kate::TextLine textLine = m_buffer->plainLine(line - 1); | 3248 | Kate::TextLine textLine = m_buffer->plainLine(line - 1); | ||
3249 | 3249 | | |||
3250 | // don't forget this check!!!! really!!!! | 3250 | // don't forget this check!!!! really!!!! | ||
3251 | if (!textLine) { | 3251 | if (!textLine) { | ||
3252 | return; | 3252 | return; | ||
3253 | } | 3253 | } | ||
3254 | 3254 | | |||
3255 | if (config()->wordWrap() && textLine->endsWith(QLatin1String(" "))) { | 3255 | if (config()->isSet("Word Wrap") && textLine->endsWith(QLatin1String(" "))) { | ||
3256 | // gg: in hard wordwrap mode, backspace must also eat the trailing space | 3256 | // gg: in hard wordwrap mode, backspace must also eat the trailing space | ||
3257 | removeText(KTextEditor::Range(line - 1, textLine->length() - 1, line, 0)); | 3257 | removeText(KTextEditor::Range(line - 1, textLine->length() - 1, line, 0)); | ||
3258 | } else { | 3258 | } else { | ||
3259 | removeText(KTextEditor::Range(line - 1, textLine->length(), line, 0)); | 3259 | removeText(KTextEditor::Range(line - 1, textLine->length(), line, 0)); | ||
3260 | } | 3260 | } | ||
3261 | } | 3261 | } | ||
3262 | } | 3262 | } | ||
3263 | if ( m_currentAutobraceRange ) { | 3263 | if ( m_currentAutobraceRange ) { | ||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | 4341 | { | |||
4366 | // KIO move, important: allow overwrite, we checked above! | 4366 | // KIO move, important: allow overwrite, we checked above! | ||
4367 | KIO::FileCopyJob *job = KIO::file_copy(QUrl::fromLocalFile(file.fileName()), saveUrl, permissions, KIO::Overwrite); | 4367 | KIO::FileCopyJob *job = KIO::file_copy(QUrl::fromLocalFile(file.fileName()), saveUrl, permissions, KIO::Overwrite); | ||
4368 | KJobWidgets::setWindow(job, QApplication::activeWindow()); | 4368 | KJobWidgets::setWindow(job, QApplication::activeWindow()); | ||
4369 | return job->exec(); | 4369 | return job->exec(); | ||
4370 | } | 4370 | } | ||
4371 | 4371 | | |||
4372 | void KTextEditor::DocumentPrivate::setWordWrap(bool on) | 4372 | void KTextEditor::DocumentPrivate::setWordWrap(bool on) | ||
4373 | { | 4373 | { | ||
4374 | config()->setWordWrap(on); | 4374 | config()->set("Word Wrap", on); | ||
4375 | } | 4375 | } | ||
4376 | 4376 | | |||
4377 | bool KTextEditor::DocumentPrivate::wordWrap() const | 4377 | bool KTextEditor::DocumentPrivate::wordWrap() const | ||
4378 | { | 4378 | { | ||
4379 | return config()->wordWrap(); | 4379 | return config()->isSet("Word Wrap"); | ||
4380 | } | 4380 | } | ||
4381 | 4381 | | |||
4382 | void KTextEditor::DocumentPrivate::setWordWrapAt(uint col) | 4382 | void KTextEditor::DocumentPrivate::setWordWrapAt(uint col) | ||
4383 | { | 4383 | { | ||
4384 | config()->setWordWrapAt(col); | 4384 | config()->set("Word Wrap Column", static_cast<int>(col)); | ||
4385 | } | 4385 | } | ||
4386 | 4386 | | |||
4387 | unsigned int KTextEditor::DocumentPrivate::wordWrapAt() const | 4387 | unsigned int KTextEditor::DocumentPrivate::wordWrapAt() const | ||
4388 | { | 4388 | { | ||
4389 | return config()->wordWrapAt(); | 4389 | return config()->intVal("Word Wrap Column"); | ||
4390 | } | 4390 | } | ||
4391 | 4391 | | |||
4392 | void KTextEditor::DocumentPrivate::setPageUpDownMovesCursor(bool on) | 4392 | void KTextEditor::DocumentPrivate::setPageUpDownMovesCursor(bool on) | ||
4393 | { | 4393 | { | ||
4394 | config()->setPageUpDownMovesCursor(on); | 4394 | config()->setPageUpDownMovesCursor(on); | ||
4395 | } | 4395 | } | ||
4396 | 4396 | | |||
4397 | bool KTextEditor::DocumentPrivate::pageUpDownMovesCursor() const | 4397 | bool KTextEditor::DocumentPrivate::pageUpDownMovesCursor() const | ||
Show All 12 Lines | 4409 | { | |||
4410 | return m_config->encoding(); | 4410 | return m_config->encoding(); | ||
4411 | } | 4411 | } | ||
4412 | 4412 | | |||
4413 | void KTextEditor::DocumentPrivate::updateConfig() | 4413 | void KTextEditor::DocumentPrivate::updateConfig() | ||
4414 | { | 4414 | { | ||
4415 | m_undoManager->updateConfig(); | 4415 | m_undoManager->updateConfig(); | ||
4416 | 4416 | | |||
4417 | // switch indenter if needed and update config.... | 4417 | // switch indenter if needed and update config.... | ||
4418 | m_indenter->setMode(m_config->indentationMode()); | 4418 | m_indenter->setMode(m_config->stringVal("Indentation Mode")); | ||
4419 | m_indenter->updateConfig(); | 4419 | m_indenter->updateConfig(); | ||
4420 | 4420 | | |||
4421 | // set tab width there, too | 4421 | // set tab width there, too | ||
4422 | m_buffer->setTabWidth(config()->tabWidth()); | 4422 | m_buffer->setTabWidth(config()->tabWidth()); | ||
4423 | 4423 | | |||
4424 | // update all views, does tagAll and updateView... | 4424 | // update all views, does tagAll and updateView... | ||
4425 | foreach (KTextEditor::ViewPrivate *view, m_views) { | 4425 | foreach (KTextEditor::ViewPrivate *view, m_views) { | ||
4426 | view->updateDocumentConfig(); | 4426 | view->updateDocumentConfig(); | ||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | 4575 | } else { | |||
4616 | } | 4616 | } | ||
4617 | 4617 | | |||
4618 | // INTEGER SETTINGS | 4618 | // INTEGER SETTINGS | ||
4619 | else if (var == QLatin1String("tab-width") && checkIntValue(val, &n)) { | 4619 | else if (var == QLatin1String("tab-width") && checkIntValue(val, &n)) { | ||
4620 | m_config->setTabWidth(n); | 4620 | m_config->setTabWidth(n); | ||
4621 | } else if (var == QLatin1String("indent-width") && checkIntValue(val, &n)) { | 4621 | } else if (var == QLatin1String("indent-width") && checkIntValue(val, &n)) { | ||
4622 | m_config->setIndentationWidth(n); | 4622 | m_config->setIndentationWidth(n); | ||
4623 | } else if (var == QLatin1String("indent-mode")) { | 4623 | } else if (var == QLatin1String("indent-mode")) { | ||
4624 | m_config->setIndentationMode(val); | 4624 | m_config->set("Indentation Mode", val); | ||
4625 | } else if (var == QLatin1String("word-wrap-column") && checkIntValue(val, &n) && n > 0) { // uint, but hard word wrap at 0 will be no fun ;) | 4625 | } else if (var == QLatin1String("word-wrap-column") && checkIntValue(val, &n)) { | ||
4626 | m_config->setWordWrapAt(n); | 4626 | m_config->set("Word Wrap Column", n); | ||
4627 | } | 4627 | } | ||
4628 | 4628 | | |||
4629 | // STRING SETTINGS | 4629 | // STRING SETTINGS | ||
4630 | else if (var == QLatin1String("eol") || var == QLatin1String("end-of-line")) { | 4630 | else if (var == QLatin1String("eol") || var == QLatin1String("end-of-line")) { | ||
4631 | const auto l = { QLatin1String("unix"), QLatin1String("dos"), QLatin1String("mac") }; | 4631 | const auto l = { QLatin1String("unix"), QLatin1String("dos"), QLatin1String("mac") }; | ||
4632 | if ((n = indexOf(l, val.toLower())) != -1) { | 4632 | if ((n = indexOf(l, val.toLower())) != -1) { | ||
4633 | /** | 4633 | /** | ||
4634 | * set eol + avoid that it is overwritten by auto-detection again! | 4634 | * set eol + avoid that it is overwritten by auto-detection again! | ||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | |||||
4947 | void KTextEditor::DocumentPrivate::removeTrailingSpaces() | 4947 | void KTextEditor::DocumentPrivate::removeTrailingSpaces() | ||
4948 | { | 4948 | { | ||
4949 | const int remove = config()->removeSpaces(); | 4949 | const int remove = config()->removeSpaces(); | ||
4950 | if (remove == 0) { | 4950 | if (remove == 0) { | ||
4951 | return; | 4951 | return; | ||
4952 | } | 4952 | } | ||
4953 | 4953 | | |||
4954 | // temporarily disable static word wrap (see bug #328900) | 4954 | // temporarily disable static word wrap (see bug #328900) | ||
4955 | const bool wordWrapEnabled = config()->wordWrap(); | 4955 | const bool wordWrapEnabled = config()->isSet("Word Wrap"); | ||
4956 | if (wordWrapEnabled) { | 4956 | if (wordWrapEnabled) { | ||
4957 | setWordWrap(false); | 4957 | setWordWrap(false); | ||
4958 | } | 4958 | } | ||
4959 | 4959 | | |||
4960 | editStart(); | 4960 | editStart(); | ||
4961 | 4961 | | |||
4962 | for (int line = 0; line < lines(); ++line) { | 4962 | for (int line = 0; line < lines(); ++line) { | ||
4963 | Kate::TextLine textline = plainKateTextLine(line); | 4963 | Kate::TextLine textline = plainKateTextLine(line); | ||
Show All 37 Lines | 4996 | if (!m_hlSetByUser && !KTextEditor::EditorPrivate::self()->modeManager()->fileType(newType).hl.isEmpty()) { | |||
5001 | } | 5001 | } | ||
5002 | } | 5002 | } | ||
5003 | 5003 | | |||
5004 | /** | 5004 | /** | ||
5005 | * set the indentation mode, if any in the mode... | 5005 | * set the indentation mode, if any in the mode... | ||
5006 | * and user did not set it before! | 5006 | * and user did not set it before! | ||
5007 | */ | 5007 | */ | ||
5008 | if (!m_indenterSetByUser && !KTextEditor::EditorPrivate::self()->modeManager()->fileType(newType).indenter.isEmpty()) { | 5008 | if (!m_indenterSetByUser && !KTextEditor::EditorPrivate::self()->modeManager()->fileType(newType).indenter.isEmpty()) { | ||
5009 | config()->setIndentationMode(KTextEditor::EditorPrivate::self()->modeManager()->fileType(newType).indenter); | 5009 | config()->set("Indentation Mode", KTextEditor::EditorPrivate::self()->modeManager()->fileType(newType).indenter); | ||
5010 | } | 5010 | } | ||
5011 | 5011 | | |||
5012 | // views! | 5012 | // views! | ||
5013 | KTextEditor::ViewPrivate *v; | 5013 | KTextEditor::ViewPrivate *v; | ||
5014 | foreach (v, m_views) { | 5014 | foreach (v, m_views) { | ||
5015 | v->config()->configStart(); | 5015 | v->config()->configStart(); | ||
5016 | v->renderer()->config()->configStart(); | 5016 | v->renderer()->config()->configStart(); | ||
5017 | } | 5017 | } | ||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |