MCPcopy Create free account
hub / github.com/clementgallet/libTAS / drawFormat

Method drawFormat

src/external/qhexview/src/qhexview.cpp:978–1095  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

976}
977
978QTextCharFormat QHexView::drawFormat(QTextCursor& c, quint8 b, const QString& s,
979 QHexArea area, qint64 line, qint64 column,
980 bool applyformat) const {
981 QTextCharFormat cf, selcf;
982 QHexPosition pos{line, column};
983
984 if(applyformat) {
985 auto offset = m_hexcursor->positionToOffset(pos);
986 bool hasdelegate =
987 m_hexdelegate && m_hexdelegate->render(offset, b, cf, this);
988
989 if(!hasdelegate) {
990 auto it = m_options.bytecolors.find(b);
991
992 if(it != m_options.bytecolors.end()) {
993 if(it->background.isValid())
994 cf.setBackground(it->background);
995 if(it->foreground.isValid())
996 cf.setForeground(it->foreground);
997 }
998 }
999
1000 const auto* metadataline = m_hexmetadata->find(line);
1001
1002 if(metadataline) {
1003 for(const auto& metadata : *metadataline) {
1004 if(offset < metadata.begin || offset >= metadata.end)
1005 continue;
1006
1007 if(!hasdelegate) {
1008 if(metadata.foreground.isValid())
1009 cf.setForeground(metadata.foreground);
1010
1011 if(metadata.background.isValid()) {
1012 cf.setBackground(metadata.background);
1013
1014 if(!metadata.foreground.isValid())
1015 cf.setForeground(
1016 this->getReadableColor(metadata.background));
1017 }
1018 }
1019
1020 if(!metadata.comment.isEmpty()) {
1021 cf.setUnderlineColor(
1022 m_options.commentcolor.isValid()
1023 ? m_options.commentcolor
1024 : this->palette().color(QPalette::WindowText));
1025 cf.setUnderlineStyle(
1026 QTextCharFormat::UnderlineStyle::SingleUnderline);
1027 }
1028
1029 if(offset ==
1030 metadata
1031 .begin) // Remove previous metadata's style, if needed
1032 {
1033 if(metadata.comment.isEmpty())
1034 selcf.setUnderlineStyle(
1035 QTextCharFormat::UnderlineStyle::NoUnderline);

Callers 1

drawDocumentMethod · 0.95

Calls 15

getReadableColorMethod · 0.95
getLastColumnMethod · 0.95
hexCursorMethod · 0.95
positionToOffsetMethod · 0.80
isSelectedMethod · 0.80
modeMethod · 0.80
renderMethod · 0.45
findMethod · 0.45
endMethod · 0.45
isValidMethod · 0.45
setBackgroundMethod · 0.45
setForegroundMethod · 0.45

Tested by

no test coverage detected