Skip to content

Commit

Permalink
Github Issue #175: Added method to hide markdown symbols from previou…
Browse files Browse the repository at this point in the history
…sly selected lines which are showing markdown symbols
  • Loading branch information
AngryFender committed Jun 14, 2024
1 parent 4d7d4d3 commit cc8f924
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
61 changes: 61 additions & 0 deletions mktextdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,67 @@ void MkTextDocument::hideMKSymbolsFromDrawingRect(int blockNumber, bool showAll,
}
}
}
this->selectRange.oldRawFirstBlock = selectRange.selectionFirstStartBlock;
this->selectRange.oldRawEndBlock = selectRange.selectionEndBlock;
}

void MkTextDocument::hideMKSymbolsFromPreviousSelectedBlocks(int blockNumber, bool showAll, SelectRange * const editSelectRange, const bool clearPushCheckBoxData)
{
//hide raw text from old selection but dont hide blocks from current selection
int fontSize =this->defaultFont().pointSize();
FormatCollection formatCollection(fontSize);
QTextBlock block;

int blockNo = this->selectRange.oldRawFirstBlock;
while(blockNo <= this->selectRange.oldRawEndBlock){
if(!(blockNo <= this->selectRange.rawFirstBlock && blockNo >= this->selectRange.rawEndBlock)){
//todo: hide mk symbols
block = this->findBlockByNumber(blockNo);
QTextBlockUserData *data = block.userData();
if(data == nullptr){
blockNo++;
continue;
}

BlockData* blockData = dynamic_cast<BlockData*>(data);
if(blockData)
{
switch(blockData->getStatus()){
case BlockData::content: break;
case BlockData::start:
case BlockData::end: hideSymbols(block, CODEBLOCK_SYMBOL);break;
}
blockNo++;
continue;
}

resetTextBlockFormat(block);
LineData* lineData = dynamic_cast<LineData*>(data);
if(lineData){
lineData->setDraw(true);
hideSymbols(block, lineData->getSymbol());
blockNo++;
continue;
}

FormatData* formatData = dynamic_cast<FormatData*>(data);
if(formatData){
QTextCursor cursor(block);

formatData->setHidden(true);
hideAllFormatSymbolsInTextBlock(block,formatData);

if(!formatData->isHiddenFormatsEmpty()){
for(QVector<FragmentData*>::Iterator it = formatData->hiddenFormats_begin(); it < formatData->hiddenFormats_end(); it++)
{
applyMkFormat(block, (*it)->getStart(), (*it)->getEnd(), (*it)->getStatus(), cursor, formatCollection, false);
}
}
}
}
blockNo++;
}
}

void MkTextDocument::showMKSymbolsFromCurrentSelectedBlocks(int blockNumber, bool showAll, SelectRange * const editSelectRange, const bool clearPushCheckBoxData)
{
Expand Down
2 changes: 2 additions & 0 deletions mktextdocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ public slots:
QString numberListGetNextNumber(const QString &text);

void hideMKSymbolsFromDrawingRect(int blockNumber, bool showAll,SelectRange * const editSelectRange, const bool clearPushCheckBoxData = true);
void hideMKSymbolsFromPreviousSelectedBlocks(int blockNumber, bool showAll,SelectRange * const editSelectRange, const bool clearPushCheckBoxData = true);
void showMKSymbolsFromCurrentSelectedBlocks(int blockNumber, bool showAll,SelectRange * const editSelectRange, const bool clearPushCheckBoxData = true);

};

enum EditType{
Expand Down

0 comments on commit cc8f924

Please sign in to comment.