From c6f907101ad9ffb8e2ea8c63b95f67654759794c Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Fri, 16 Jul 2021 15:40:34 -0500 Subject: [PATCH] (librunview) Remove URL hovering It's less stable than I'd anticipated, and needs more workshopping. I'll keep it in another branch (and git history) for later use. --- libs/librunview/RunView.cpp | 63 ++----------------------------------- libs/librunview/RunView.h | 9 ------ 2 files changed, 2 insertions(+), 70 deletions(-) diff --git a/libs/librunview/RunView.cpp b/libs/librunview/RunView.cpp index f9febe7..ec1d469 100644 --- a/libs/librunview/RunView.cpp +++ b/libs/librunview/RunView.cpp @@ -38,12 +38,6 @@ RunView::RunView(const char* name) urlFont.SetFace(B_REGULAR_FACE | B_UNDERSCORE_FACE); text_run urlRun = { 0, urlFont, ui_color(B_LINK_TEXT_COLOR) }; fUrlRun = { 1, {urlRun} }; - - text_run urlHoverRun = { 0, urlFont, ui_color(B_LINK_HOVER_COLOR) }; - fUrlHoverRun = { 1, {urlHoverRun} }; - - text_run urlVisitedRun = { 0, urlFont, ui_color(B_LINK_VISITED_COLOR) }; - fUrlVisitedRun = { 1, {urlVisitedRun} }; } @@ -150,8 +144,6 @@ RunView::MouseUp(BPoint where) if (fMouseDown && fSelecting == false && fLastClicked.IsValid() == true) { fLastClicked.OpenWithPreferredApplication(true); fLastClicked = BUrl(); - // When cursor moves off URL, change color - fCurrentUrlRuns = fUrlVisitedRun; } fMouseDown = false; fSelecting = false; @@ -164,35 +156,11 @@ RunView::MouseMoved(BPoint where, uint32 code, const BMessage* drag) if (fSelecting == true) return; - // Change the cursor and "hover-over" highlight for URLs if (code == B_INSIDE_VIEW) - if (OverUrl(where) == true) { - int32 start = 0; - int32 end = 0; - FindWordAround(OffsetAt(where), &start, &end); - if (fCurrentUrlEnd == 0 - || (OffsetAt(where) < fCurrentUrlStart - || OffsetAt(where) > fCurrentUrlEnd)) - { - if (fCurrentUrlEnd != 0) - ReplaceRuns(fCurrentUrlStart, fCurrentUrlEnd, - &fCurrentUrlRuns); - fCurrentUrlRuns = *RunArray(start, end); - fCurrentUrlStart = start; - fCurrentUrlEnd = end; - - ReplaceRuns(start, end, &fUrlHoverRun); - } + if (OverUrl(where) == true) SetViewCursor(fUrlCursor); - } - else { - if (fCurrentUrlEnd != 0) { - ReplaceRuns(fCurrentUrlStart, fCurrentUrlEnd, &fCurrentUrlRuns); - fCurrentUrlStart = 0; - fCurrentUrlEnd = 0; - } + else SetViewCursor(B_CURSOR_SYSTEM_DEFAULT); - } } @@ -230,33 +198,6 @@ RunView::Append(const char* text) } -void -RunView::Replace(int32 start, int32 end, const char* text, text_run_array* runs) -{ - Delete(start, end); - BTextView::Insert(start, text, strlen(text), runs); -} - - -void -RunView::ReplaceRuns(int32 start, int32 end, text_run_array* runs) -{ - char* buffer = new char[end - start]; - GetText(start, end - start, buffer); - - // Need to make sure nothing visibly changes to the user - float current = ScrollBar(B_VERTICAL)->Value(); - int32 selStart = 0, selEnd = 0; - GetSelection(&selStart, &selEnd); - - Replace(start, end, buffer, runs); - - ScrollBar(B_VERTICAL)->SetValue(current); - if (end > 0) - Select(selStart, selEnd); -} - - BString RunView::WordAt(BPoint point) { diff --git a/libs/librunview/RunView.h b/libs/librunview/RunView.h index c878b9c..8bd0fdb 100644 --- a/libs/librunview/RunView.h +++ b/libs/librunview/RunView.h @@ -30,10 +30,6 @@ public: uint16 fontFace = B_REGULAR_FACE); void Append(const char* text); - void Replace(int32 start, int32 end, const char* text, - text_run_array* runs); - void ReplaceRuns(int32 start, int32 end, text_run_array* runs); - BString WordAt(BPoint point); void FindWordAround(int32 offset, int32* start, int32* end, BString* _word = NULL); @@ -60,11 +56,6 @@ private: // Whether or not the run was changed from default bool fLastStyled; - // Used for the "hover over" URL highlighting - text_run_array fCurrentUrlRuns; - int32 fCurrentUrlStart; - int32 fCurrentUrlEnd; - // Information between MouseDown and MouseUp BUrl fLastClicked; bool fMouseDown;