void SciDoc::print() { QsciPrinter prn; QPrintDialog dlg(&prn, this); if (dlg.exec() == QDialog::Accepted) { prn.setWrapMode(EditorSettings::get(EditorSettings::WrapWords) || PrintSettings::get(PrintSettings::AlwaysWrap) ? QsciScintilla::WrapWord : QsciScintilla::WrapNone); int line1(-1), line2(-1), col1(-1), col2(-1); JuffScintilla* edit = int_->curEdit_; if ( edit ) { QsciLexer* lexer = edit->lexer(); if ( !PrintSettings::get(PrintSettings::KeepBgColor) ) { lexer->setDefaultPaper(Qt::white); lexer->setPaper(Qt::white); lexer->setDefaultColor(Qt::black); } if ( !PrintSettings::get(PrintSettings::KeepColors) ) { lexer->setColor(Qt::black); } edit->getSelection(&line1, &col1, &line2, &col2); if (line1 >=0 && line2 >= 0 && col1 >= 0 && col2 >= 0) { // We have selection. Print it. --line2; prn.printRange(edit, line1, line2); } else { // We don't have selection. Print the whole text. prn.printRange(edit, 0); } QFont font = EditorSettings::font(); LexerStorage::instance()->updateLexers(font); } } }
void TextView::onLexerChanged(int index) { QsciLexer *prevLexer = scintEditor->lexer(); QsciLexer *newLexer = nullptr; switch (index) { // do nothing by default case 0: break; case 1: newLexer = new(std::nothrow) QsciLexerHTML(); break; case 2: newLexer = new(std::nothrow) QsciLexerJavaScript(); break; case 3: newLexer = new(std::nothrow) QsciLexerYAML(); break; case 4: newLexer = new(std::nothrow) QsciLexerXML(); break; case 5: newLexer = new(std::nothrow) QsciLexerProperties(); break; default: logger->logError(tr("Unknown Lexer index: %1 T_T").arg(index)); } if (newLexer != nullptr) { newLexer->setDefaultFont(GlobalsValues::GLOBAL_REGULAR_FONT); newLexer->setDefaultColor(QApplication::palette().text().color()); } scintEditor->setLexer(newLexer); scintEditor->setBackgroundRole(QPalette::Base); delete prevLexer; if (newLexer == nullptr) { scintEditor->setFont(GlobalsValues::GLOBAL_REGULAR_FONT); } }