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(); }
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); }
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( ); }
void Widget::setCursor(const Cursor& cursor) { GdkCursor* platformCursor = cursor.platformCursor().get(); // 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 (platformCursor == lastSetCursor) return; gdk_window_set_cursor(gdkDrawable(platformWidget()) ? GDK_WINDOW(gdkDrawable(platformWidget())) : gtk_widget_get_window(GTK_WIDGET(root()->hostWindow()->platformPageClient())), platformCursor); lastSetCursor = platformCursor; }
// Returns whether the loop should continue. bool insertNumberIntoRam(char c) { if (c < 48 || c > 57) { digits = vector<int>(); insertNumber = false; return false; } digits.insert(digits.begin(), c - 48); int numbersValue = 0; int i = 0; for (int digit : digits) { numbersValue += digit * pow(10, i++); } cursor.setWord(Util::getBoolByte(numbersValue)); redrawScreen(); return true; }
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; } }
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; }
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 ) ); } } }
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; }
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); }
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; }
/// 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; }
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; }
/* 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(); } } }
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()); }
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()); }
void WebChromeClient::setCursor(const Cursor& cursor) { HCURSOR platformCursor = cursor.platformCursor()->nativeCursor(); if (!platformCursor) return; if (COMPtr<IWebUIDelegate> delegate = uiDelegate()) { COMPtr<IWebUIDelegatePrivate> delegatePrivate(Query, delegate); if (delegatePrivate) { if (SUCCEEDED(delegatePrivate->webViewSetCursor(m_webView, reinterpret_cast<OLE_HANDLE>(platformCursor)))) return; } } m_webView->setLastCursor(platformCursor); ::SetCursor(platformCursor); return; }
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); }
void uiInput() { int nx = 0, ny = 0; if (MENU_CALLBACK) { if (MENU_ITEM_INDEX) { if (isTCODCharPressed(TCODK_UP)) { MENU_ITEM_INDEX--; } } if (MENU_ITEM_INDEX < MENU_ITEM_COUNT - 1) { if (isTCODCharPressed(TCODK_DOWN)) { MENU_ITEM_INDEX++; } } if (isTCODCharPressed(TCODK_ENTER)) { MENU_CALLBACK(MENU_ITEM_INDEX, MENU_ITEMS[MENU_ITEM_INDEX]); MENU_CALLBACK = NULL; MENU_ITEMS[0] = NULL; } } else if (CURSOR.map) { if (isTCODCharPressed(TCODK_DOWN)) { ny = 1; } else if (isTCODCharPressed(TCODK_UP)) { ny = -1; } else if (isTCODCharPressed(TCODK_LEFT)) { nx = -1; } else if (isTCODCharPressed(TCODK_RIGHT)) { nx = 1; } else if (isTCODCharPressed(TCODK_ENTER)) { CURSOR.callback(CURSOR.x, CURSOR.y); CURSOR.map = NULL; } if ((nx || ny) && TCOD_map_is_walkable(CURSOR.map, CURSOR.x + nx, CURSOR.y + ny)) { CURSOR.x += nx; CURSOR.y += ny; } } }
void ReflectionParser::buildClasses(const Cursor &cursor, Namespace ¤tNamespace) { for (auto &child : cursor.GetChildren()) { // skip classes from other files if (!IsInCurrentFile(child)) continue; auto kind = child.GetKind(); // actual definition and a class or struct if (child.IsDefinition() && (kind == CXCursor_ClassDecl || kind == CXCursor_StructDecl)) { m_classes.emplace_back(new Class(child, currentNamespace)); } RECURSE_NAMESPACES(kind, child, buildClasses, currentNamespace); } }
bool FastCGISession::parseRecordBegin(Cursor& cursor, size_t& available) { assert(m_phase == Phase::AT_RECORD_BEGIN); if (available < FastCGISession::k_recordBeginLength) { return false; } Version version = cursor.readBE<Version>(); if (version != k_version) { handleInvalidRecord(); return false; } m_recordType = static_cast<RecordType>(cursor.readBE<uint8_t>()); m_requestId = cursor.readBE<decltype(m_requestId)>(); m_contentLength = cursor.readBE<decltype(m_contentLength)>(); m_contentLeft = m_contentLength; m_paddingLength = cursor.readBE<decltype(m_paddingLength)>(); cursor.skip(k_recordReservedLength); available -= k_recordBeginLength; return true; }
Cursor* Region::setCursor(int sidnum, std::string sidsource, int millinow, NosuchVector pos, double depth, double area, OutlineMem* om) { if ( pos.x < x_min || pos.x > x_max || pos.y < y_min || pos.y > y_max ) { NosuchDebug("Ignoring out-of-bounds cursor pos=%f,%f,%f\n",pos.x,pos.y); return NULL; } if ( isButton() ) { // double buttonMinArea = 0.6f; double buttonMinArea = params.minbuttonarea; double buttonMaxArea = 1.3f; if ( area < buttonMinArea ) { NosuchDebug(2,"Ignoring setCursor for button, area %f too small",area); return NULL; } if ( area > buttonMaxArea ) { NosuchDebug(2,"Ignoring setCursor for button, area %f too big",area); return NULL; } } Cursor* c = getCursor(sidnum,sidsource); if ( c != NULL ) { c->settargetpos(pos); c->set_target_depth(depth); c->setarea(area); c->setoutline(om); cursorDrag(c); } else { c = new Cursor(palette, sidnum, sidsource, this, pos, depth,area); c->setoutline(om); if ( cursorlist_lock_write() ) { _cursors.push_back(c); cursorlist_unlock(); cursorDown(c); } else { NosuchDebug("Region::setCursor unable to lock cursorlist"); } } c->touch(millinow); return c; }
void WebChromeClient::setCursor(const Cursor& cursor) { HCURSOR platformCursor = cursor.platformCursor()->nativeCursor(); if (!platformCursor) return; bool shouldSetCursor = true; if (COMPtr<IWebUIDelegate> delegate = uiDelegate()) { COMPtr<IWebUIDelegatePrivate> delegatePrivate(Query, delegate); if (delegatePrivate) { if (SUCCEEDED(delegatePrivate->webViewSetCursor(m_webView, platformCursor))) shouldSetCursor = false; } } if (shouldSetCursor) ::SetCursor(platformCursor); setLastSetCursorToCurrentCursor(); }
bool KVParser::parseKeyValueLength(Cursor& cursor, size_t& available, size_t& lengthReturn) { if (!available) { return false; } auto peeked = cursor.peek(); if (*peeked.first & 0x80) { // highest bit is set if (available < sizeof(uint32_t)) { return false; } lengthReturn = cursor.readBE<uint32_t>(); lengthReturn &= ~(0x80 << 24); available -= sizeof(uint32_t); } else { lengthReturn = cursor.readBE<uint8_t>(); available--; } return true; }
static Cursor maybeLexEscapedIRValue(Cursor C, MIToken &Token, ErrorCallbackType ErrorCallback) { if (C.peek() != '`') return None; auto Range = C; C.advance(); auto StrRange = C; while (C.peek() != '`') { if (C.isEOF() || isNewlineChar(C.peek())) { ErrorCallback( C.location(), "end of machine instruction reached before the closing '`'"); Token.reset(MIToken::Error, Range.remaining()); return C; } C.advance(); } StringRef Value = StrRange.upto(C); C.advance(); Token.reset(MIToken::QuotedIRValue, Range.upto(C)).setStringValue(Value); return C; }
bool FastCGITransaction::parseKeyValueLength(Cursor& cursor, size_t& available, size_t& lengthReturn) { if (available < sizeof(ShortLength)) { return false; } auto peeked = cursor.peek(); if (*peeked.first & k_longLengthFlag) { if (available < sizeof(LongLength)) { return false; } lengthReturn = cursor.readBE<LongLength>(); lengthReturn &= ~(k_longLengthFlag << 24); available -= sizeof(LongLength); } else { lengthReturn = cursor.readBE<ShortLength>(); available -= sizeof(ShortLength); } return true; }
void write_polish_cursor( std::ostream &out , Cursor t , std::string const& sep , std::string const &opening , std::string const& closing , SymbolMapper const& mapper ) { if( t.size() != 0 ) out << opening; out << mapper( *t ); if( t.size() != 0 ) { out << sep; write_polish_cursor( out , t.children( 0 ) , sep , opening , closing , mapper ); } for( size_t i=1 ; i<t.size(); ++i ) { out << sep; write_polish_cursor( out , t.children( i ) , sep , opening , closing , mapper ); } if( t.size() != 0 ) out << closing; }
bool Initialize() { MessageInfo msg; uint32_t tid; if (monapi_name_whereis("/servers/process", tid) != M_OK) { monapi_warn("process server not found"); } if (Message::sendReceive(&msg, tid, MSG_PROCESS_GET_COMMON_PARAMS) != M_OK) { syscall_print("Mouse Server: can not get common parameters\n"); return false; } commonParams = (CommonParameters*)MemoryMap::map(msg.arg2); /* mouse information destination list */ this->destList = new HList<uint32_t>(); if (this->destList == NULL) { syscall_print("Mouse Server: destList error\n"); return false; } /* screen size */ this->w = screen.getWidth(); this->h = screen.getHeight(); /* cursor to center */ commonParams->mouse.x = this->posX = this->prevX = this->w / 2; commonParams->mouse.y = this->posY = this->prevY = this->h / 2; commonParams->mouse.buttons = this->button = this->prevButton = 0; /* server start ok */ if (!SendServerOK()) return false; cursor.Paint(this->posX, this->posY); return true; }
void draw(){ // Something change?? if(*iHasChanged != -1) { onFileChange(); *iHasChanged = -1; } shader.use(); shader.setUniform("u_time", getTime()); shader.setUniform("u_mouse", getMouseX(), getMouseY()); shader.setUniform("u_resolution",getWindowWidth(), getWindowHeight()); glm::mat4 mvp = glm::mat4(1.); if (iGeom != -1) { shader.setUniform("u_eye", -cam.getPosition()); shader.setUniform("u_normalMatrix", cam.getNormalMatrix()); shader.setUniform("u_modelMatrix", model_matrix); shader.setUniform("u_viewMatrix", cam.getViewMatrix()); shader.setUniform("u_projectionMatrix", cam.getProjectionMatrix()); mvp = cam.getProjectionViewMatrix() * model_matrix; } shader.setUniform("u_modelViewProjectionMatrix", mvp); unsigned int index = 0; for (std::map<std::string,Texture*>::iterator it = textures.begin(); it!=textures.end(); ++it) { shader.setUniform(it->first,it->second,index); shader.setUniform(it->first+"Resolution",it->second->getWidth(),it->second->getHeight()); index++; } vbo->draw(&shader); if(bCursor){ cursor.draw(); } }
void InsetFlex::doDispatch(Cursor & cur, FuncRequest & cmd) { switch (cmd.action()) { case LFUN_INSET_DISSOLVE: if (!cmd.argument().empty()) { InsetLayout const & il = getLayout(); InsetLayout::InsetLyXType const type = translateLyXType(to_utf8(cmd.argument())); if (il.lyxtype() == type) { FuncRequest temp_cmd(LFUN_INSET_DISSOLVE); InsetCollapsable::doDispatch(cur, temp_cmd); } else cur.undispatched(); break; } // fall-through default: InsetCollapsable::doDispatch(cur, cmd); break; } }