From 11d0369852de959d410898441356377fb3ea712a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 27 Feb 2004 21:35:23 +0000 Subject: [PATCH] No longer displays the selection when the file size is 0. Also fixed a possibly wrong cursor position in that case. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6782 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/diskprobe/DataView.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/apps/diskprobe/DataView.cpp b/src/apps/diskprobe/DataView.cpp index 9a8643f10c..df384b0eca 100644 --- a/src/apps/diskprobe/DataView.cpp +++ b/src/apps/diskprobe/DataView.cpp @@ -306,7 +306,7 @@ DataView::ConvertLine(char *line, off_t offset, const uint8 *buffer, size_t size void DataView::Draw(BRect updateRect) { - if (fData == NULL) + if (fData == NULL || fFileSize == 0) return; // ToDo: take "updateRect" into account! @@ -415,6 +415,9 @@ DataView::SelectionFrame(view_focus which, int32 start, int32 end) void DataView::DrawSelectionFrame(view_focus which) { + if (fFileSize == 0) + return; + bool drawBlock = false; bool drawLastLine = false; BRect block, lastLine; @@ -529,6 +532,9 @@ DataView::DrawSelectionFrame(view_focus which) void DataView::DrawSelectionBlock(view_focus which) { + if (fFileSize == 0) + return; + // draw first line SetDrawingMode(B_OP_INVERT); @@ -586,14 +592,14 @@ DataView::SetSelection(int32 start, int32 end, view_focus focus) end = temp; } + if (start > (int32)fSizeInView - 1) + start = (int32)fSizeInView - 1; if (start < 0) start = 0; - else if (start > (int32)fSizeInView - 1) - start = (int32)fSizeInView - 1; if (end > (int32)fSizeInView - 1) end = (int32)fSizeInView - 1; - else if (end < 0) + if (end < 0) end = 0; if (fStart == start && fEnd == end) {