summaryrefslogtreecommitdiff
path: root/src/monitor-cmd.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/monitor-cmd.cc')
-rw-r--r--src/monitor-cmd.cc46
1 files changed, 6 insertions, 40 deletions
diff --git a/src/monitor-cmd.cc b/src/monitor-cmd.cc
index ba02703..8aa8b99 100644
--- a/src/monitor-cmd.cc
+++ b/src/monitor-cmd.cc
@@ -11,6 +11,8 @@
#include "args.hh"
#include "buffer.hh"
+#include "gui_hexdump.hh"
+#include "gui_plainattrtext.hh"
#include "io.hh"
#include "ios_save.hh"
#include "looper.hh"
@@ -120,50 +122,14 @@ private:
}
out_ << "* Size: " << size << '\n';
if (size > 0) {
- ios_save save(out_);
- auto d = reinterpret_cast<uint8_t const*>(data);
- out_.flags(std::ios::hex);
- out_.fill('0');
- for (size_t i = 0; i < size; i += 16) {
- out_ << std::setw(8) << i << ' ';
- unsigned j = 0;
- for (; j < 8; ++j) {
- auto k = i + j;
- if (k >= size) break;
- out_ << ' ' << std::setw(2) << static_cast<int>(d[k]);
- }
- for (; j < 8; ++j) {
- out_ << " ";
- }
- out_ << ' ';
- for (; j < 16; ++j) {
- auto k = i + j;
- if (k >= size) break;
- out_ << ' ' << std::setw(2) << static_cast<int>(d[k]);
- }
- for (; j < 16; ++j) {
- out_ << " ";
- }
- out_ << " |";
- j = 0;
- for (; j < 16; ++j) {
- auto k = i + j;
- if (k >= size) break;
- out_ << printable(data[k]);
- }
- for (; j < 16; ++j) {
- out_ << ' ';
- }
- out_ << "|\n";
- }
+ std::unique_ptr<PlainAttributedText> text(PlainAttributedText::create());
+ HexDump::write(text.get(), HexDump::ADDRESS | HexDump::CHARS
+ | HexDump::ASCII, data, 0, size);
+ out_ << text->text();
}
out_ << std::endl;
}
- static char printable(char c) {
- return (c & 0x80 || c < ' ' || c >= 0x7f) ? '.' : c;
- }
-
std::ostream& out_;
bool interleave_;
Looper* looper_;