1
0
mirror of synced 2024-11-30 18:34:29 +01:00

Improved byte highlighting

This commit is contained in:
WerWolv 2021-01-20 18:10:40 +01:00
parent 740619529c
commit be738eb5e7
3 changed files with 14 additions and 10 deletions

View File

@ -182,7 +182,7 @@ set_target_properties(imhex PROPERTIES CXX_VISIBILITY_PRESET hidden)
target_link_directories(imhex PRIVATE ${CRYPTO_LIBRARY_DIRS} ${CAPSTONE_LIBRARY_DIRS} ${MAGIC_LIBRARY_DIRS}) target_link_directories(imhex PRIVATE ${CRYPTO_LIBRARY_DIRS} ${CAPSTONE_LIBRARY_DIRS} ${MAGIC_LIBRARY_DIRS})
if (WIN32) if (WIN32)
target_link_libraries(imhex libdl.a libmagic.a libgnurx.a libtre.a libintl.a libiconv.a libshlwapi.a libcrypto.a libwinpthread.a libcapstone.a LLVMDemangle libimhex ${Python_LIBRARIES}) target_link_libraries(imhex libdl.a libmagic.a libgnurx.a libtre.a libintl.a libiconv.a libshlwapi.a libcrypto.a libwinpthread.a libcapstone.a LLVMDemangle libimhex ${Python_LIBRARIES} wsock32 ws2_32)
elseif (UNIX) elseif (UNIX)
target_link_libraries(imhex magic crypto ${CMAKE_DL_LIBS} capstone LLVMDemangle libimhex ${Python_LIBRARIES} dl) target_link_libraries(imhex magic crypto ${CMAKE_DL_LIBS} capstone LLVMDemangle libimhex ${Python_LIBRARIES} dl)
endif() endif()

View File

@ -183,7 +183,7 @@ namespace hex::lang {
class PatternDataPadding : public PatternData { class PatternDataPadding : public PatternData {
public: public:
PatternDataPadding(u64 offset, size_t size) : PatternData(offset, size, 0x00FFFFFF) { } PatternDataPadding(u64 offset, size_t size) : PatternData(offset, size, 0xFF000000) { }
PatternData* clone() override { PatternData* clone() override {
return new PatternDataPadding(*this); return new PatternDataPadding(*this);

View File

@ -46,22 +46,26 @@ namespace hex {
for (const auto &[region, name, comment, color] : _this->m_bookmarks) { for (const auto &[region, name, comment, color] : _this->m_bookmarks) {
if (off >= region.address && off < (region.address + region.size)) if (off >= region.address && off < (region.address + region.size))
currColor = (color & 0x00FFFFFF) | 0x40000000; currColor = (color & 0x00FFFFFF) | 0x80000000;
if ((off - 1) >= region.address && (off - 1) < (region.address + region.size)) if ((off - 1) >= region.address && (off - 1) < (region.address + region.size))
prevColor = (color & 0x00FFFFFF) | 0x40000000;; prevColor = (color & 0x00FFFFFF) | 0x80000000;
} }
if (_this->m_highlightedBytes.contains(off)) if (_this->m_highlightedBytes.contains(off)) {
currColor = _this->m_highlightedBytes[off]; auto color = (_this->m_highlightedBytes[off] & 0x00FFFFFF) | 0x80000000;
if (_this->m_highlightedBytes.contains(off - 1)) currColor = currColor.has_value() ? ImAlphaBlendColors(color, currColor.value()) : color;
prevColor = _this->m_highlightedBytes[off - 1]; }
if (_this->m_highlightedBytes.contains(off - 1)) {
auto color = (_this->m_highlightedBytes[off - 1] & 0x00FFFFFF) | 0x80000000;
prevColor = prevColor.has_value() ? ImAlphaBlendColors(color, prevColor.value()) : color;
}
if (next && prevColor != currColor) { if (next && prevColor != currColor) {
return false; return false;
} }
if (currColor.has_value()) { if (currColor.has_value() && (currColor.value() & 0x00FFFFFF) != 0x00) {
_this->m_memoryEditor.HighlightColor = currColor.value(); _this->m_memoryEditor.HighlightColor = (currColor.value() & 0x00FFFFFF) | 0x40000000;
return true; return true;
} }