1
0
Fork 0
mirror of https://github.com/otakuto/crazydiskinfo.git synced 2025-08-14 01:34:27 +00:00

Add support for toggle raw values between hexadecimal and decimal

This commit is contained in:
otakuto 2019-11-26 05:12:07 +09:00
parent 2444b6e829
commit 64c1338e90
2 changed files with 14 additions and 11 deletions

View file

@ -3,9 +3,6 @@ option(RAW_VALUES_DEC "Display Raw Values in Decimal instead of Hex" OFF)
project(CrazyDiskInfo CXX) project(CrazyDiskInfo CXX)
add_executable(CrazyDiskInfo main.cpp) add_executable(CrazyDiskInfo main.cpp)
set(CMAKE_CXX_FLAGS "-Wall -std=c++11") set(CMAKE_CXX_FLAGS "-Wall -std=c++11")
if(RAW_VALUES_DEC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DRAWDEC")
endif()
SET_TARGET_PROPERTIES(CrazyDiskInfo PROPERTIES OUTPUT_NAME crazy) SET_TARGET_PROPERTIES(CrazyDiskInfo PROPERTIES OUTPUT_NAME crazy)
target_link_libraries(CrazyDiskInfo atasmart) target_link_libraries(CrazyDiskInfo atasmart)
target_link_libraries(CrazyDiskInfo tinfow) target_link_libraries(CrazyDiskInfo tinfow)

View file

@ -12,7 +12,7 @@
std::string const TITLE = "CrazyDiskInfo"; std::string const TITLE = "CrazyDiskInfo";
std::string const VERSION = "1.0.2"; std::string const VERSION = "1.0.2";
constexpr int const STATUS_WIDTH = 80; constexpr int const STATUS_WIDTH = 83;
constexpr int const DEVICE_BAR_HEIGHT = 4; constexpr int const DEVICE_BAR_HEIGHT = 4;
@ -30,9 +30,11 @@ class Option
{ {
public: public:
bool hideSerial; bool hideSerial;
bool isRawHex;
Option() Option()
: :
hideSerial(false) hideSerial(false),
isRawHex(true)
{ {
} }
}; };
@ -383,16 +385,14 @@ void drawStatus(WINDOW * window, SMART const & smart, Option const & option)
} }
wattrset(window, COLOR_PAIR(ATTRIBUTE_LEGEND_COLOR)); wattrset(window, COLOR_PAIR(ATTRIBUTE_LEGEND_COLOR));
mvwprintw(window, 8, 1, " Status ID AttributeName Current Worst Threshold Raw Values "); mvwprintw(window, 8, 1, " Status ID AttributeName Current Worst Threshold RawValues(%s) ", option.isRawHex ? "Hex" : "Dec");
wattroff(window, COLOR_PAIR(ATTRIBUTE_LEGEND_COLOR)); wattroff(window, COLOR_PAIR(ATTRIBUTE_LEGEND_COLOR));
auto attributeFormat = option.isRawHex ? " %-7s %02X %-28s %7d %5d %9d %012llX " : " %-7s %02X %-28s %7d %5d %9d %15llu ";
for (int i = 0; i < static_cast<int>(smart.attribute.size()); ++i) for (int i = 0; i < static_cast<int>(smart.attribute.size()); ++i)
{ {
wattrset(window, COLOR_PAIR(HEALTH_COLOR + static_cast<int>(attributeToHealth(smart.attribute[i])))); wattrset(window, COLOR_PAIR(HEALTH_COLOR + static_cast<int>(attributeToHealth(smart.attribute[i]))));
#ifndef RAWDEC mvwprintw(window, 9 + i, 1, attributeFormat,
mvwprintw(window, 9 + i, 1, " %-7s %02X %-28s %7d %5d %9d %012X ",
#else
mvwprintw(window, 9 + i, 1, " %-7s %02X %-28s %7d %5d %9d %012d ",
#endif//RAWDEC
healthToString(attributeToHealth(smart.attribute[i])).c_str(), healthToString(attributeToHealth(smart.attribute[i])).c_str(),
smart.attribute[i].id, smart.attribute[i].id,
smart.attribute[i].name.c_str(), smart.attribute[i].name.c_str(),
@ -553,6 +553,12 @@ int main()
update(); update();
break; break;
case 'd':
option.isRawHex = !option.isRawHex;
clear();
refresh();
update();
break;
case 'q': case 'q':
endwin(); endwin();