(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.
This commit is contained in:
Jaidyn Ann 2021-07-16 15:40:34 -05:00
parent e1ec602be8
commit c6f907101a
2 changed files with 2 additions and 70 deletions

View File

@ -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)
{

View File

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