void BufferWidget::doSetEncoding(const QByteArray &e) { editor::Buffer *buf = currentBuffer(); if(buf == nullptr) return; buf->setEncoding(e); }
bool undo() { if (!currentBuffer().undoStack_.empty()) { currentBuffer().redoStack_.emplace_back(currentDoc(), cursorPos(), EditAction::UndoRedo); UndoState const& state = currentBuffer().undoStack_.back(); currentDoc() = state.doc_; cursorPos() = state.cursor_; currentBuffer().undoStack_.pop_back(); return true; } return false; }
void BufferWidget::doSaveAs() { editor::Buffer *buf = currentBuffer(); if(buf == nullptr) return; buf->saveAs(); }
void TreeWidget::closeBuffer(IrcBuffer* buffer) { if (!buffer) buffer = currentBuffer(); if (buffer) emit bufferClosed(buffer); }
Index selectionIndex(Index const& idx) { Index const& start = currentBuffer().selectionStart_; if (start.x < 0) return Index(); return Index(idx.x - start.x, idx.y - start.y); }
void BufferWidget::doLineWrapping(bool enabled) { editor::Buffer *buf = currentBuffer(); if(buf == NULL) return; buf->setLineWrapping(enabled); }
void BufferWidget::doDecreaseIndent() { editor::Buffer *buf = currentBuffer(); if(buf == NULL) return; buf->decreaseSelectionIndent(); }
void BufferWidget::doDeselect() { editor::Buffer *buf = currentBuffer(); if(buf == NULL) return; buf->deselect(); }
void BufferWidget::doSelectAll() { editor::Buffer *buf = currentBuffer(); if(buf == NULL) return; buf->selectAll(); }
void BufferWidget::doDuplicateLine() { editor::Buffer *buf = currentBuffer(); if(buf == NULL) return; buf->duplicateLine(); }
void BufferWidget::doPaste() { editor::Buffer *buf = currentBuffer(); if(buf == NULL) return; buf->paste(); }
void BufferWidget::doCopy() { editor::Buffer *buf = currentBuffer(); if(buf == NULL) return; buf->copy(); }
void BufferWidget::doRedo() { editor::Buffer *buf = currentBuffer(); if(buf == NULL) return; buf->redo(); }
void BufferWidget::doGoTo(int l) { editor::Buffer *buf = currentBuffer(); if(buf == NULL) return; buf->goToLine(l); }
void BufferWidget::doPrint(QPrinter *p) { editor::Buffer *buf = currentBuffer(); if(buf == NULL) return; buf->print(p); }
static void takeUndoSnapshot(EditAction action, bool canMerge) { bool createNew = true; if (!currentBuffer().undoStack_.empty()) { UndoState & state = currentBuffer().undoStack_.back(); if (state.action_ == action && (canMerge || forceUndoMerge_)) createNew = false; } if (createNew) { currentBuffer().undoStack_.emplace_back(currentDoc(), cursorPos(), action); currentBuffer().redoStack_.clear(); } }
editor::search::FindResult BufferWidget::doReplaceAll(editor::search::ReplaceQuery const &q) { editor::Buffer *buf = currentBuffer(); if(buf == NULL) return editor::search::FindResult::NoDocument; return buf->replaceAll(q); }
editor::search::FindResult BufferWidget::doFindPrevious(editor::search::FindQuery const &q) { editor::Buffer *buf = currentBuffer(); if(buf == NULL) return editor::search::FindResult::NoDocument; return buf->findPrevious(q); }
void BufferWidget::doClose() { editor::Buffer *buf = currentBuffer(); if(buf == nullptr) return; if(buf->prepareToClose()) { doTabClosing(tabWidget->indexOf(buf)); removeCurrentBuffer(); } }
std::vector<Index> selectedRows() { std::vector<Index> selection; Index const& start = currentBuffer().selectionStart_; const int height = currentBuffer().selectionEnd_.y - start.y; if (height == 0) { selection.push_back(currentBuffer().cursorPos_); } else { selection.reserve(height); for (int y = 0; y <= height; ++y) selection.emplace_back(start.x, start.y + y); } return selection; }
std::vector<Index> selectedColumns() { std::vector<Index> selection; Index const& start = currentBuffer().selectionStart_; const int width = currentBuffer().selectionEnd_.x - start.x; if (width == 0) { selection.push_back(currentBuffer().cursorPos_); } else { selection.reserve(width); for (int x = 0; x <= width; ++x) selection.emplace_back(start.x + x, start.y); } return selection; }
void BufferWidget::doBufferEncodingChanged(const QByteArray &e) { const editor::Buffer *b = dynamic_cast<const editor::Buffer *>(sender()); if(b == nullptr) return; const editor::Buffer *current = currentBuffer(); if(b == current) Q_EMIT(encodingChanged(e)); }
void BufferWidget::doTabPathChanged(const QString &p) { editor::Buffer *b = dynamic_cast<editor::Buffer *>(sender()); if(b != NULL) { if(b == currentBuffer()) { Q_EMIT pathChanged(p); } } }
uint SurfaceItem::textureId() { if (advance()) { if (m_textureId) glDeleteTextures(1, &m_textureId); glGenTextures(1, &m_textureId); glBindTexture(GL_TEXTURE_2D, m_textureId); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); currentBuffer().bindToTexture(); } return m_textureId; }
std::vector<Index> selectedCells() { std::vector<Index> selection; Index const& start = currentBuffer().selectionStart_; const int width = currentBuffer().selectionEnd_.x - start.x; const int height = currentBuffer().selectionEnd_.y - start.y; selection.reserve(width * height); if (width == 0 && height == 0) { selection.push_back(currentBuffer().cursorPos_); } else { for (int y = 0; y <= height; ++y) for (int x = 0; x <= width; ++x) selection.emplace_back(start.x + x, start.y + y); } return selection; }
static Document & currentDoc() { return currentBuffer().doc_; }
bool hasSelection() { return currentBuffer().selectionStart_.x >= 0 && currentBuffer().selectionStart_.y >= 0; }
Index & selectionEnd() { return currentBuffer().selectionEnd_; }
Index & selectionStart() { return currentBuffer().selectionStart_; }
Index & scroll() { return currentBuffer().scroll_; }