当前位置: 首页>>代码示例>>C++>>正文


C++ ktexteditor::Cursor类代码示例

本文整理汇总了C++中ktexteditor::Cursor的典型用法代码示例。如果您正苦于以下问题:C++ Cursor类的具体用法?C++ Cursor怎么用?C++ Cursor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Cursor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getKeyword

	QString Help::getKeyword(KTextEditor::View *view)
	{
		if(!view) {
			return QString();
		}

		// get current position
		int row, col, col1, col2;
		QString word;
		KTextEditor::Document *doc = view->document();
		KTextEditor::Cursor cursor = view->cursorPosition();
		row = cursor.line();
		col = cursor.column();

		if (m_edit->getCurrentWord(doc, row, col, KileDocument::EditorExtension::smTex, word, col1, col2)) {
		   // There is no starred keyword in the references. So if     // dani 04.08.2004
			// we find one, we better try the unstarred keyword.
			if(word.right(1) == "*") {
				return word.left(word.length() - 1);
			}
			else {
				return word;
			}
		}
		else {
			return QString();
		}
	}
开发者ID:fagu,项目名称:kileip,代码行数:28,代码来源:kilehelp.cpp

示例2: completionRange

KTextEditor::Range IncludeHelperCompletionModel::completionRange(
    KTextEditor::View* view
  , const KTextEditor::Cursor& position
  )
{
    kDebug(DEBUG_AREA) << "cursor: " << position;
    auto line = view->document()->line(position.line());
    auto r = parseIncludeDirective(line, false);
    if (r.m_range.isValid())
    {
        auto start = line.lastIndexOf('/', r.m_range.end().column() - 1);
        kDebug(DEBUG_AREA) << "init start=" << start;
        start = start == -1 ? r.m_range.start().column() : start + 1;
        kDebug(DEBUG_AREA) << "fixed start=" << start;
        KTextEditor::Range range(
            position.line()
          , start
          , position.line()
          , r.m_range.end().column()
          );
        kDebug(DEBUG_AREA) << "selected range: " << range;
        return range;
    }
    kDebug(DEBUG_AREA) << "default select";
#if 0
    return KTextEditor::Range();
#else
    return KTextEditor::CodeCompletionModelControllerInterface3::completionRange(view, position);
#endif
}
开发者ID:arcan1s,项目名称:kate-cpp-helper-plugin,代码行数:30,代码来源:include_helper_completion_model.cpp

示例3: shouldStartCompletion

bool PythonCodeCompletionModel::shouldStartCompletion(KTextEditor::View* view, const QString& inserted,
                                                bool userInsertion, const KTextEditor::Cursor& position)
{
    QList<QString> words;
    words << "for" << "raise" << "except" << "in";
    foreach ( const QString& word, words ) {
        if ( view->document()->line(position.line()).mid(0, position.column()).endsWith(word + " ") ) {
            return true;
        }
    }
    // shebang / encoding lines
    if ( view->document()->line(position.line()).mid(0, position.column()).endsWith("#") && 
         position.line() < 2 )
    {
        return true;
    }

    // we're probably dealing with string formatting completion
    // is there any other case where this condition is true?
    if ( ! userInsertion && inserted.startsWith('{') ) {
        return true;
    }

    return KDevelop::CodeCompletionModel::shouldStartCompletion(view, inserted, userInsertion, position);
}
开发者ID:KDE,项目名称:kdev-python,代码行数:25,代码来源:model.cpp

示例4: wrapLine

void TextBuffer::wrapLine (const KTextEditor::Cursor &position)
{
  // only allowed if editing transaction running
  Q_ASSERT (m_editingTransactions > 0);

  // get block, this will assert on invalid line
  int blockIndex = blockForLine (position.line());

  // let the block handle the wrapLine
  // this can only lead to one more line in this block
  // no other blocks will change
  ++m_lines; // first alter the line counter, as functions called will need the valid one
  m_blocks.at(blockIndex)->wrapLine (position);

  // remember changes
  ++m_revision;

  // update changed line interval
  if (position.line() < m_editingMinimalLineChanged || m_editingMinimalLineChanged == -1)
    m_editingMinimalLineChanged = position.line();

  if (position.line() <= m_editingMaximalLineChanged)
    ++m_editingMaximalLineChanged;
  else
    m_editingMaximalLineChanged = position.line() + 1;

  // fixup all following blocks
  fixStartLines (blockIndex);

  // balance the changed block if needed
  balanceBlock (blockIndex);

  // emit signal about done change
  emit lineWrapped (position);
}
开发者ID:rtaycher,项目名称:kate,代码行数:35,代码来源:katetextbuffer.cpp

示例5: insertText

void TextBuffer::insertText (const KTextEditor::Cursor &position, const QString &text)
{
  // only allowed if editing transaction running
  Q_ASSERT (m_editingTransactions > 0);

  // skip work, if no text to insert
  if (text.isEmpty())
    return;

  // get block, this will assert on invalid line
  int blockIndex = blockForLine (position.line());

  // let the block handle the insertText
  m_blocks.at(blockIndex)->insertText (position, text);

  // remember changes
  ++m_revision;

  // update changed line interval
  if (position.line () < m_editingMinimalLineChanged || m_editingMinimalLineChanged == -1)
    m_editingMinimalLineChanged = position.line ();

  if (position.line () > m_editingMaximalLineChanged)
    m_editingMaximalLineChanged = position.line ();

  // emit signal about done change
  emit textInserted (position, text);
}
开发者ID:rtaycher,项目名称:kate,代码行数:28,代码来源:katetextbuffer.cpp

示例6: scriptIndent

void KateAutoIndent::scriptIndent (KateView *view, const KTextEditor::Cursor &position, QChar typedChar)
{
  QPair<int, int> result = m_script->indent (view, position, typedChar, indentWidth);
  int newIndentInChars = result.first;

  // handle negative values special
  if (newIndentInChars < -1)
    return;

  // reuse indentation of the previous line, just like the "normal" indenter
  if (newIndentInChars == -1)
  {
    // keep indent of previous line
    keepIndent (position.line());

    return;
  }

  int align = result.second;
  if (align > 0)
    kDebug (13060) << "Align: " << align;

  // we got a positive or zero indent to use...
  doIndent (position.line(), newIndentInChars, align);
}
开发者ID:UIKit0,项目名称:kate,代码行数:25,代码来源:kateautoindent.cpp

示例7: cursorToOffset_kte

unsigned int KDocumentTextBuffer::cursorToOffset_kte( const KTextEditor::Cursor &cursor )
{
    unsigned int offset = 0;
    for( int i = 0; i < cursor.line(); i++ ) {
        offset += countUnicodeCharacters(kDocument()->line(i)) + 1; // Add newline
    }
    offset += countUnicodeCharacters(kDocument()->line(cursor.line()).left(cursor.column()));
    return offset;
}
开发者ID:KDE,项目名称:kte-collaborative,代码行数:9,代码来源:document.cpp

示例8: wrapLine

void TextHistory::wrapLine(const KTextEditor::Cursor &position)
{
    // create and add new entry
    Entry entry;
    entry.type = Entry::WrapLine;
    entry.line = position.line();
    entry.column = position.column();
    addEntry(entry);
}
开发者ID:KDE,项目名称:ktexteditor,代码行数:9,代码来源:katetexthistory.cpp

示例9: jumpToCursor

void DebugSession::jumpToCursor()
{
    if (KDevelop::IDocument* doc = KDevelop::ICore::self()->documentController()->activeDocument()) {
        KTextEditor::Cursor cursor = doc->cursorPosition();
        if ( cursor.isValid() ) {
            // TODO disable all other breakpoints
            addSimpleUserCommand(QString("jump " + QString::number(cursor.line() + 1)).toAscii());
        }
    }
}
开发者ID:mali,项目名称:kdev-python,代码行数:10,代码来源:debugsession.cpp

示例10: QObject

Recorder::Recorder(KTextEditor::View *view, Manager *manager) : QObject(view), m_manager(manager), m_view(view)
{
	connect(m_manager, SIGNAL(watchedKeySequencesChanged()), this, SLOT(reloadWatchedKeySequences()));
	connect(this, SIGNAL(detectedTypedKeySequence(const QString&)), m_manager, SLOT(keySequenceTyped(const QString&)));
	KTextEditor::Cursor cursor = m_view->cursorPosition();
	m_oldLine = cursor.line();
	m_oldCol = cursor.column();

	reloadWatchedKeySequences();
}
开发者ID:fagu,项目名称:kileip,代码行数:10,代码来源:editorkeysequencemanager.cpp

示例11: wrapLine

void SwapFile::wrapLine (const KTextEditor::Cursor &position)
{
  // skip if not open
  if (!m_swapfile.isOpen ())
    return;
  
  // format: qint8, int, int
  m_stream << EA_WrapLine << position.line() << position.column();

  m_needSync = true;
}
开发者ID:dividedmind,项目名称:kate,代码行数:11,代码来源:kateswapfile.cpp

示例12: insertText

void SwapFile::insertText (const KTextEditor::Cursor &position, const QString &text)
{
  // skip if not open
  if (!m_swapfile.isOpen ())
    return;
  
  // format: qint8, int, int, bytearray
  m_stream << EA_InsertText << position.line() << position.column() << text.toUtf8 ();

  m_needSync = true;
}
开发者ID:dividedmind,项目名称:kate,代码行数:11,代码来源:kateswapfile.cpp

示例13: insertText

void TextHistory::insertText(const KTextEditor::Cursor &position, int length, int oldLineLength)
{
    // create and add new entry
    Entry entry;
    entry.type = Entry::InsertText;
    entry.line = position.line();
    entry.column = position.column();
    entry.length = length;
    entry.oldLineLength = oldLineLength;
    addEntry(entry);
}
开发者ID:KDE,项目名称:ktexteditor,代码行数:11,代码来源:katetexthistory.cpp

示例14: getCursorPos

/**
 * Returns the current position of the cursor.
 * @param	nLine	Holds the line on which the cursor is currently located
 * @param	nCol	Holds the column on which the cursor is currently located
 * @return	true if successful, false otherwise (cursor interface was not
 *			obtained)
 */
bool EditorPage::getCursorPos(uint& nLine, uint& nCol)
{
    int line, col;
	// Get the cursor position (adjusted to 1-based counting)
	const KTextEditor::Cursor c = m_pView->cursorPosition();
    c.position(line, col);
    nLine = line;
    nCol = col;
	nLine++;
	nCol++;
	
	return true;
}
开发者ID:choueric,项目名称:kscope-4,代码行数:20,代码来源:editorpage.cpp

示例15: shouldStartCompletion

bool KateNewCompletionModel::shouldStartCompletion(KTextEditor::View* view, const QString &insertedText, bool userInsertion, const KTextEditor::Cursor &position)
{
    if (!userInsertion) return false;
    if(insertedText.isEmpty())
        return false;

    KateView *v = qobject_cast<KateView*> (view);

    QString text = view->document()->line(position.line()).left(position.column());
    static const QRegExp ktuan_new_class("((new \\w*)|(gen\\w*)|(get\\w*))$");
    if (ktuan_new_class.indexIn(text) >= 0) return true;
    return false;
}
开发者ID:ktuan89,项目名称:kate-4.8.0,代码行数:13,代码来源:katenewcompletion.cpp


注:本文中的ktexteditor::Cursor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。