本文整理汇总了C++中Cursor类的典型用法代码示例。如果您正苦于以下问题:C++ Cursor类的具体用法?C++ Cursor怎么用?C++ Cursor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cursor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LanguageType
Global::Global(const Cursor &cursor, const Namespace ¤tNamespace, Class *parent)
: LanguageType(cursor, currentNamespace)
, m_isConst(cursor.GetType().IsConst())
, m_hasExplicitGetter(m_metaData.GetFlag(kMetaExplicitGetter))
, m_hasExplicitSetter(m_metaData.GetFlag(kMetaExplicitSetter))
, m_parent(parent)
, m_name(cursor.GetSpelling())
, m_qualifiedName(utils::GetQualifiedName(cursor, currentNamespace))
, m_type(cursor.GetType().GetDisplayName())
{
auto displayName = m_metaData.GetNativeString(kMetaDisplayName);
if (displayName.empty())
{
m_displayName = m_qualifiedName;
}
else
{
m_displayName =
utils::GetQualifiedName(displayName, currentNamespace);
}
m_metaData.Check();
}
示例2: gtk_widget_get_window
void PageClientImpl::setCursor(const Cursor& cursor)
{
if (!gtk_widget_get_realized(m_viewWidget))
return;
// [GTK] Widget::setCursor() gets called frequently
// http://bugs.webkit.org/show_bug.cgi?id=16388
// Setting the cursor may be an expensive operation in some backends,
// so don't re-set the cursor if it's already set to the target value.
GdkWindow* window = gtk_widget_get_window(m_viewWidget);
GdkCursor* currentCursor = gdk_window_get_cursor(window);
GdkCursor* newCursor = cursor.platformCursor().get();
if (currentCursor != newCursor)
gdk_window_set_cursor(window, newCursor);
}
示例3: LanguageType
Field::Field(
const Cursor &cursor,
const Namespace ¤tNamespace,
Class *parent
)
: LanguageType( cursor, currentNamespace )
, m_isConst( cursor.GetType( ).IsConst( ) )
, m_parent( parent )
, m_name( cursor.GetSpelling( ) )
, m_type( cursor.GetType( ).GetDisplayName( ) )
{
auto displayName = m_metaData.GetNativeString( kMetaDisplayName );
if (displayName.empty( ))
m_displayName = m_name;
else
m_displayName = displayName;
m_explicitGetter = m_metaData.GetNativeString( kMetaExplicitGetter );
m_hasExplicitGetter = !m_explicitGetter.empty( );
m_explicitSetter = m_metaData.GetNativeString( kMetaExplicitSetter );
m_hasExplicitSetter = !m_explicitSetter.empty( );
}
示例4: lexStringConstant
/// Lex a string constant using the following regular expression: \"[^\"]*\"
static Cursor lexStringConstant(
Cursor C,
function_ref<void(StringRef::iterator Loc, const Twine &)> ErrorCallback) {
assert(C.peek() == '"');
for (C.advance(); C.peek() != '"'; C.advance()) {
if (C.isEOF()) {
ErrorCallback(
C.location(),
"end of machine instruction reached before the closing '\"'");
return None;
}
}
C.advance();
return C;
}
示例5: doDispatch
void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd)
{
switch (cmd.action()) {
case LFUN_INSET_MODIFY:
if (cmd.getArg(0) == "ert") {
cur.recordUndoInset(ATOMIC_UNDO, this);
setStatus(cur, string2params(to_utf8(cmd.argument())));
break;
}
//fall-through
default:
InsetCollapsable::doDispatch(cur, cmd);
break;
}
}
示例6: setCursor
void Widget::setCursor(const Cursor& cursor)
{
GdkCursor* pcur = cursor.impl();
// http://bugs.webkit.org/show_bug.cgi?id=16388
// [GTK] Widget::setCursor() gets called frequently
//
// gdk_window_set_cursor() in certain GDK backends seems to be an
// expensive operation, so avoid it if possible.
if (pcur == m_data->cursor)
return;
gdk_window_set_cursor(gdkDrawable(platformWidget()) ? GDK_WINDOW(gdkDrawable(platformWidget())) : GTK_WIDGET(root()->hostWindow()->platformWindow())->window, pcur);
m_data->cursor = pcur;
}
示例7: LoadAnonymous
void Enum::LoadAnonymous(
std::vector<Global*> &output,
const Cursor &cursor,
const Namespace ¤tNamespace
)
{
for (auto &child : cursor.GetChildren( ))
{
if (child.GetKind( ) == CXCursor_EnumConstantDecl)
{
output.emplace_back(
new Global( child, currentNamespace, nullptr )
);
}
}
}
示例8: maybeLexIndexAndName
static Cursor maybeLexIndexAndName(Cursor C, MIToken &Token, StringRef Rule,
MIToken::TokenKind Kind) {
if (!C.remaining().startswith(Rule) || !isdigit(C.peek(Rule.size())))
return None;
auto Range = C;
C.advance(Rule.size());
auto NumberRange = C;
while (isdigit(C.peek()))
C.advance();
StringRef Number = NumberRange.upto(C);
unsigned StringOffset = Rule.size() + Number.size();
if (C.peek() == '.') {
C.advance();
++StringOffset;
while (isIdentifierChar(C.peek()))
C.advance();
}
Token.reset(Kind, Range.upto(C))
.setIntegerValue(APSInt(Number))
.setStringValue(Range.upto(C).drop_front(StringOffset));
return C;
}
示例9: doDispatch
void InsetText::doDispatch(Cursor & cur, FuncRequest & cmd)
{
LYXERR(Debug::ACTION, "InsetText::doDispatch()"
<< " [ cmd.action() = " << cmd.action() << ']');
if (getLayout().isPassThru()) {
// Force any new text to latex_language FIXME: This
// should only be necessary in constructor, but new
// paragraphs that are created by pressing enter at
// the start of an existing paragraph get the buffer
// language and not latex_language, so we take this
// brute force approach.
cur.current_font.setLanguage(latex_language);
cur.real_current_font.setLanguage(latex_language);
}
switch (cmd.action()) {
case LFUN_PASTE:
case LFUN_CLIPBOARD_PASTE:
case LFUN_SELECTION_PASTE:
case LFUN_PRIMARY_SELECTION_PASTE:
text_.dispatch(cur, cmd);
// If we we can only store plain text, we must reset all
// attributes.
// FIXME: Change only the pasted paragraphs
fixParagraphsFont();
break;
case LFUN_INSET_DISSOLVE: {
bool const main_inset = &buffer().inset() == this;
bool const target_inset = cmd.argument().empty()
|| cmd.getArg(0) == insetName(lyxCode());
bool const one_cell = nargs() == 1;
if (!main_inset && target_inset && one_cell) {
// Text::dissolveInset assumes that the cursor
// is inside the Inset.
if (&cur.inset() != this)
cur.pushBackward(*this);
cur.beginUndoGroup();
text_.dispatch(cur, cmd);
cur.endUndoGroup();
} else
cur.undispatched();
break;
}
default:
text_.dispatch(cur, cmd);
}
if (!cur.result().dispatched())
Inset::doDispatch(cur, cmd);
}
示例10: maybeLexIntegerLiteral
static Cursor maybeLexIntegerLiteral(Cursor C, MIToken &Token) {
if (!isdigit(C.peek()) && (C.peek() != '-' || !isdigit(C.peek(1))))
return None;
auto Range = C;
C.advance();
while (isdigit(C.peek()))
C.advance();
StringRef StrVal = Range.upto(C);
Token = MIToken(MIToken::IntegerLiteral, StrVal, APSInt(StrVal));
return C;
}
示例11: hideInline
void GuiCompleter::hideInline(Cursor & cur)
{
gui_->bufferView().setInlineCompletion(cur, DocIterator(cur.buffer()), docstring());
inlineVisible_ = false;
if (inline_timer_.isActive())
inline_timer_.stop();
// Trigger asynchronous part of hideInline. We might be
// in a dispatcher here and the setModel call might
// trigger focus events which is are not healthy here.
QTimer::singleShot(0, this, SLOT(asyncHideInline()));
// mark that the asynchronous part will reset the model
if (!popupVisible())
modelActive_ = false;
}
示例12: lock
/* must call this on a delete so we clean up the cursors. */
void ClientCursor::aboutToDelete(const DiskLoc& dl) {
recursive_scoped_lock lock(ccmutex);
CCByLoc::iterator j = byLoc.lower_bound(dl);
CCByLoc::iterator stop = byLoc.upper_bound(dl);
if ( j == stop )
return;
vector<ClientCursor*> toAdvance;
while ( 1 ) {
toAdvance.push_back(j->second);
DEV assert( j->first == dl );
++j;
if ( j == stop )
break;
}
wassert( toAdvance.size() < 5000 );
for ( vector<ClientCursor*>::iterator i = toAdvance.begin(); i != toAdvance.end(); ++i ){
ClientCursor* cc = *i;
if ( cc->_doingDeletes ) continue;
Cursor *c = cc->c.get();
if ( c->capped() ){
delete cc;
continue;
}
c->checkLocation();
DiskLoc tmp1 = c->refLoc();
if ( tmp1 != dl ) {
/* this might indicate a failure to call ClientCursor::updateLocation() */
problem() << "warning: cursor loc " << tmp1 << " does not match byLoc position " << dl << " !" << endl;
}
c->advance();
if ( c->eof() ) {
// advanced to end -- delete cursor
delete cc;
}
else {
wassert( c->refLoc() != dl );
cc->updateLocation();
}
}
}
示例13: popupActivated
void GuiCompleter::popupActivated(const QString & completion)
{
Cursor cur = gui_->bufferView().cursor();
cur.screenUpdateFlags(Update::None);
cur.recordUndo();
docstring prefix = cur.inset().completionPrefix(cur);
docstring postfix = qstring_to_ucs4(completion.mid(prefix.length()));
cur.inset().insertCompletion(cur, postfix, true);
hidePopup(cur);
hideInline(cur);
if (cur.result().update())
gui_->bufferView().processUpdateFlags(cur.result().update());
}
示例14: updateModel
void GuiCompleter::updateModel(Cursor & cur, bool popupUpdate, bool inlineUpdate)
{
// value which should be kept selected
QString old = currentCompletion();
if (old.length() == 0)
old = last_selection_;
// set whether rtl
bool rtl = false;
if (cur.inTexted()) {
Paragraph const & par = cur.paragraph();
Font const & font =
par.getFontSettings(cur.bv().buffer().params(), cur.pos());
rtl = font.isVisibleRightToLeft();
}
popup()->setLayoutDirection(rtl ? Qt::RightToLeft : Qt::LeftToRight);
// set new model
CompletionList const * list = cur.inset().createCompletionList(cur);
model_->setList(list);
modelActive_ = true;
if (list->sorted())
setModelSorting(QCompleter::CaseSensitivelySortedModel);
else
setModelSorting(QCompleter::UnsortedModel);
// set prefix
QString newPrefix = toqstr(cur.inset().completionPrefix(cur));
if (newPrefix != completionPrefix())
setCompletionPrefix(newPrefix);
// show popup
if (popupUpdate)
updatePopup(cur);
// restore old selection
setCurrentCompletion(old);
// if popup is not empty, the new selection will
// be our last valid one
if (popupVisible() || inlineVisible()) {
QString const & s = currentCompletion();
if (s.length() > 0)
last_selection_ = s;
else
last_selection_ = old;
}
// show inline completion
if (inlineUpdate)
updateInline(cur, currentCompletion());
}
示例15: findWordStart
Range CodeCompletionModelControllerInterface::completionRange(View* view, const Cursor &position)
{
Cursor end = position;
QString text = view->document()->line(end.line());
static QRegExp findWordStart( "\\b([_\\w]+)$" );
static QRegExp findWordEnd( "^([_\\w]*)\\b" );
Cursor start = end;
if (findWordStart.lastIndexIn(text.left(end.column())) >= 0)
start.setColumn(findWordStart.pos(1));
if (findWordEnd.indexIn(text.mid(end.column())) >= 0)
end.setColumn(end.column() + findWordEnd.cap(1).length());
//kDebug()<<"returning:"<<Range(start,end);
return Range(start, end);
}