void KateCTagsView::gotoDeclaration( ) { QString currWord = currentWord(); if (currWord.isEmpty()) { return; } QStringList types; types << "L" << "c" << "e" << "g" << "m" << "n" << "p" << "s" << "u" << "x"; gotoTagForTypes(currWord, types); }
void KateCTagsView::gotoDefinition( ) { QString currWord = currentWord(); if (currWord.isEmpty()) { return; } QStringList types; types << "S" << "d" << "f" << "t" << "v"; gotoTagForTypes(currWord, types); }
void KateCTagsView::aboutToShow() { QString currWord = currentWord(); if (currWord.isEmpty()) { return; } if (Tags::hasTag(currWord)) { QString squeezed = KStringHandler::csqueeze(currWord, 30); m_gotoDec->setText(i18n("Go to Declaration: %1",squeezed)); m_gotoDef->setText(i18n("Go to Definition: %1",squeezed)); m_lookup->setText(i18n("Lookup: %1",squeezed)); } }
void KateCTagsView::lookupTag( ) { QString currWord = currentWord(); if (currWord.isEmpty()) { return; } setNewLookupText(currWord); Tags::TagList list = Tags::getExactMatches(m_ctagsUi.tagsFile->text(), currWord); if (list.size() == 0) list = Tags::getExactMatches(m_commonDB, currWord); displayHits(list); // activate the hits tab m_ctagsUi.tabWidget->setCurrentIndex(0); m_mWin->showToolView(m_toolView); }
std::string LGGAutoCorrect::replaceWords(std::string words) { static LLCachedControl<bool> doAnything(gSavedSettings, "PhoenixEnableAutoCorrect"); if(!doAnything)return words; //TODO update this function to use the "wordStyle" thing, //but so far this function is never used, so later boost_tokenizer tokens(words, boost::char_separator<char>(" ")); for (boost_tokenizer::iterator token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter) { std::string currentWord(*token_iter); LLSD::map_const_iterator loc_it = mAutoCorrects.beginMap(); LLSD::map_const_iterator loc_end = mAutoCorrects.endMap(); for ( ; loc_it != loc_end; ++loc_it) { const std::string& location = (*loc_it).first; //llinfos << "location is "<<location.c_str() << " word is "<<currentWord.c_str()<<llendl; const LLSD& loc_map = (*loc_it).second; if((loc_map["data"].has(currentWord))&&(loc_map["enabled"].asBoolean())) { std::string replacement = loc_map["data"][currentWord]; if(loc_map["announce"].asBoolean()) { LLSD args; //"[Before]" has been auto replaced by "[Replacement]" // based on your [ListName] list. args["BEFORE"] = currentWord; args["LISTNAME"]=location; args["REPLACEMENT"]=replacement; LLNotifications::getInstance()->add("PhoenixAutoReplace",args); } llinfos << "found a word in list " << location.c_str() << " and it will replace " << currentWord.c_str() << " => " << replacement.c_str() << llendl; int wordStart = words.find(currentWord); words.replace(wordStart,currentWord.length(),replacement); return replaceWords(words);//lol recursion! } } } return words; }
void Console::keyPressEvent(QKeyEvent *event) { if (event->key() == Qt::Key_Return) // process command { if (m_completer && m_completer->popup()->isVisible()) { event->ignore(); return; } else { processCommand(); } return; } if (inCommandLine()) { // clear selection that spans multiple blocks (or prefix characters) (would overwrite previous command lines): QTextCursor cur = textCursor(); if (cur.hasSelection()) { if (document()->findBlock(cur.selectionStart()) != document()->findBlock(cur.selectionEnd()) || // spans multiple blocks (including command line) cur.selectionStart()-cur.block().position() < m_prefix.length() || // spans prefix cur.selectionEnd()-cur.block().position() < m_prefix.length() ) // spans prefix { cur.clearSelection(); if (cur.positionInBlock() < m_prefix.length()) cur.setPosition(cur.block().position()+m_prefix.length()); setTextCursor(cur); } } if (cur.positionInBlock() == m_prefix.length()) { cur.setCharFormat(QTextCharFormat()); // make sure we don't pick up format from prefix setTextCursor(cur); } // react to keystroke: if (event->matches(QKeySequence::MoveToPreviousLine)) // history up { if (m_history.isEmpty() || m_historyPos >= m_history.size()-1) return; ++m_historyPos; int index = m_history.size()-m_historyPos-1; QTextCursor cur(document()->lastBlock()); cur.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, m_prefix.length()); cur.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); cur.removeSelectedText(); cur.setCharFormat(QTextCharFormat()); cur.insertText(m_history.at(index)); setTextCursor(cur); } else if (event->matches(QKeySequence::MoveToNextLine)) // history down { if (m_history.isEmpty() || m_historyPos <= 0) return; --m_historyPos; int index = m_history.size()-m_historyPos-1; QTextCursor cur(document()->lastBlock()); cur.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, m_prefix.length()); cur.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); cur.removeSelectedText(); cur.setCharFormat(QTextCharFormat()); cur.insertText(m_history.at(index)); setTextCursor(cur); } else if (event->matches(QKeySequence::Paste)) // paste text, do it manually to remove text char formatting and newlines { QString pasteText = QApplication::clipboard()->text(); pasteText.replace("\n", "").replace("\r", ""); cur.setCharFormat(QTextCharFormat()); cur.insertText(pasteText); setTextCursor(cur); } else if (event->key() == Qt::Key_Backspace || event->matches(QKeySequence::MoveToPreviousChar)) // only allow backspace if we wouldn't delete last char of prefix, similar left arrow { if (cur.positionInBlock() > m_prefix.length()) QPlainTextEdit::keyPressEvent(event); } else if (event->matches(QKeySequence::MoveToStartOfLine) || event->key() == Qt::Key_Home) { // Don't move past prefix when pressing home // OSX treats the home key as MoveToStartOfDocument, so including the key code here too cur.movePosition(QTextCursor::PreviousCharacter, event->modifiers() & Qt::ShiftModifier ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor, cur.positionInBlock() - m_prefix.length()); cur.setCharFormat(QTextCharFormat()); setTextCursor(cur); } else if (event->key() == Qt::Key_Escape) { if (m_completer && m_completer->popup()->isVisible()) { m_completer->popup()->hide(); } else { QTextCursor cur(document()->lastBlock()); cur.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, m_prefix.length()); cur.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); cur.removeSelectedText(); setTextCursor(cur); } } else if (event->key() == Qt::Key_Tab) { if (m_completer) { m_completer->setCompletionPrefix(currentWord()); QRect cr = cursorRect(); cr.setWidth(m_completer->popup()->sizeHintForColumn(0) + m_completer->popup()->verticalScrollBar()->sizeHint().width()); m_completer->complete(cr); } } else if (!event->matches(QKeySequence::Close) && !event->matches(QKeySequence::New) && !event->matches(QKeySequence::Open) && !event->matches(QKeySequence::Preferences) && !event->matches(QKeySequence::Bold) && !event->matches(QKeySequence::Italic) && !event->matches(QKeySequence::InsertLineSeparator) && !event->matches(QKeySequence::InsertParagraphSeparator) && !event->matches(QKeySequence::Redo) && !event->matches(QKeySequence::Undo) && !event->matches(QKeySequence::DeleteStartOfWord)) { QPlainTextEdit::keyPressEvent(event); } } else // cursor position not in command line { if (event->matches(QKeySequence::MoveToEndOfDocument) || event->matches(QKeySequence::MoveToEndOfBlock) || event->matches(QKeySequence::MoveToEndOfLine) || event->matches(QKeySequence::MoveToStartOfDocument) || event->matches(QKeySequence::MoveToStartOfBlock) || event->matches(QKeySequence::MoveToStartOfLine) || //event->matches(QKeySequence::MoveToNextLine) || event->matches(QKeySequence::MoveToNextWord) || event->matches(QKeySequence::MoveToNextChar) || //event->matches(QKeySequence::MoveToPreviousLine) || event->matches(QKeySequence::MoveToPreviousWord) || event->matches(QKeySequence::MoveToPreviousChar) || event->matches(QKeySequence::SelectAll) || event->matches(QKeySequence::SelectEndOfDocument) || event->matches(QKeySequence::SelectEndOfBlock) || event->matches(QKeySequence::SelectEndOfLine) || event->matches(QKeySequence::SelectStartOfDocument) || event->matches(QKeySequence::SelectStartOfBlock) || event->matches(QKeySequence::SelectStartOfLine) || event->matches(QKeySequence::SelectNextLine) || event->matches(QKeySequence::SelectNextWord) || event->matches(QKeySequence::SelectNextChar) || event->matches(QKeySequence::SelectPreviousLine) || event->matches(QKeySequence::SelectPreviousWord) || event->matches(QKeySequence::SelectPreviousChar) || event->matches(QKeySequence::Copy) || event->key() == Qt::Key_Shift || event->key() == Qt::Key_Alt || event->key() == Qt::Key_Control || event->key() == Qt::Key_Meta ) { QPlainTextEdit::keyPressEvent(event); } else { // Place cursor in command line moveToEndOfCommandLine(); QPlainTextEdit::keyPressEvent(event); } } }