Skip to content

Commit

Permalink
Github Issue #29: adding method to extract the raw texts with all the…
Browse files Browse the repository at this point in the history
… data and symbols on a QTextBlock level
  • Loading branch information
AngryFender committed Apr 4, 2024
1 parent 824e76a commit 7dcf5d9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
31 changes: 31 additions & 0 deletions mktextdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,37 @@ void MkTextDocument::showSymbolsAtPos(QString &text, int pos, const QString &sym
text.insert(pos,symbol);
}

void MkTextDocument::extractSymbolsInBlock(QTextBlock &block)
{
QTextBlockUserData* data =block.userData();
if(data == nullptr){
return;
}

BlockData* blockData = dynamic_cast<BlockData*>(data);
if(blockData)
{
if(blockData->getStatus()!=BlockData::content)
{
showSymbols(block, CODEBLOCK_SYMBOL);
}
}
else{
LineData* lineData = dynamic_cast<LineData*>(data);
if(lineData){
lineData->setDraw(false);
showSymbols(block, lineData->getSymbol());
}
FormatData* formatData = dynamic_cast<FormatData*>(data);
if(formatData){
if(formatData->isHidden()){
formatData->setHidden(false);
showAllFormatSymbolsInTextBlock(block, formatData);
}
}
}
}

void MkTextDocument::autoCompleteCodeBlock(int blockNumber ,bool &success)
{
QTextCursor editCursor(this->findBlockByNumber(blockNumber));
Expand Down
2 changes: 2 additions & 0 deletions mktextdocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ public slots:
void showAllFormatSymbolsInTextBlock(QTextBlock &block, FormatData *formatData, SelectRange * selectRange = nullptr);
void showSymbolsAtPos(QString &text, int pos, const QString &symbol);

void extractSymbolsInBlock(QTextBlock &block);

void autoCompleteCodeBlock(int blockNumber,bool &success);
BlockData* checkValidCodeBlock(QTextBlock &block);

Expand Down

0 comments on commit 7dcf5d9

Please sign in to comment.