Skip to content

Commit

Permalink
Add support for toggle raw values between hexadecimal and decimal
Browse files Browse the repository at this point in the history
  • Loading branch information
otakuto committed Nov 25, 2019
1 parent 2444b6e commit 64c1338
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ option(RAW_VALUES_DEC "Display Raw Values in Decimal instead of Hex" OFF)
project(CrazyDiskInfo CXX)
add_executable(CrazyDiskInfo main.cpp)
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)
target_link_libraries(CrazyDiskInfo atasmart)
target_link_libraries(CrazyDiskInfo tinfow)
Expand Down
22 changes: 14 additions & 8 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
std::string const TITLE = "CrazyDiskInfo";
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;

Expand All @@ -30,9 +30,11 @@ class Option
{
public:
bool hideSerial;
bool isRawHex;
Option()
:
hideSerial(false)
hideSerial(false),
isRawHex(true)
{
}
};
Expand Down Expand Up @@ -383,16 +385,14 @@ void drawStatus(WINDOW * window, SMART const & smart, Option const & option)
}

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));

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)
{
wattrset(window, COLOR_PAIR(HEALTH_COLOR + static_cast<int>(attributeToHealth(smart.attribute[i]))));
#ifndef RAWDEC
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
mvwprintw(window, 9 + i, 1, attributeFormat,
healthToString(attributeToHealth(smart.attribute[i])).c_str(),
smart.attribute[i].id,
smart.attribute[i].name.c_str(),
Expand Down Expand Up @@ -553,6 +553,12 @@ int main()
update();
break;

case 'd':
option.isRawHex = !option.isRawHex;
clear();
refresh();
update();
break;

case 'q':
endwin();
Expand Down

0 comments on commit 64c1338

Please sign in to comment.