From dec094bb735bafc1e49888b1b0dcac22f1467bbf Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 28 Jun 2009 17:13:48 +0000 Subject: [PATCH] Added expression support to the position text control. It's not quite the direly missing "Go To" function, but better than nothing. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31300 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/diskprobe/Jamfile | 2 +- src/apps/diskprobe/ProbeView.cpp | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/apps/diskprobe/Jamfile b/src/apps/diskprobe/Jamfile index 622e3aac23..6b7ea3c58f 100644 --- a/src/apps/diskprobe/Jamfile +++ b/src/apps/diskprobe/Jamfile @@ -16,6 +16,6 @@ Application DiskProbe : ProbeView.cpp OpenWindow.cpp FindWindow.cpp - : be tracker translation + : be tracker translation libexpression_parser.a libmapm.a : DiskProbe.rdef ; diff --git a/src/apps/diskprobe/ProbeView.cpp b/src/apps/diskprobe/ProbeView.cpp index 6b9e992d1e..a620ac9779 100644 --- a/src/apps/diskprobe/ProbeView.cpp +++ b/src/apps/diskprobe/ProbeView.cpp @@ -37,6 +37,8 @@ #include #include +#include + #include "DataView.h" #include "DiskProbe.h" #include "TypeEditors.h" @@ -849,7 +851,7 @@ HeaderView::MessageReceived(BMessage *message) case kMsgPositionUpdate: { - fLastPosition = fPosition; + off_t lastPosition = fPosition; off_t position; int32 delta; @@ -862,10 +864,18 @@ HeaderView::MessageReceived(BMessage *message) } else if (message->FindInt32("delta", &delta) == B_OK) { fPosition += delta * off_t(fBlockSize); } else { - fPosition = strtoll(fPositionControl->Text(), NULL, 0) - * fBlockSize; + try { + ExpressionParser parser; + parser.SetSupportHexInput(true); + fPosition = parser.EvaluateToInt64( + fPositionControl->Text()) * fBlockSize; + } catch (...) { + beep(); + break; + } } + fLastPosition = lastPosition; fPosition = (fPosition / fBlockSize) * fBlockSize; // round to block size