2010-07-10 08:58:15 -05:00
|
|
|
/*
|
2021-07-14 13:17:00 -05:00
|
|
|
* Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
|
|
|
|
* All rights reserved. Distributed under the terms of the MIT license.
|
2010-05-07 04:47:10 -05:00
|
|
|
*/
|
2021-07-14 13:17:00 -05:00
|
|
|
#ifndef _RUN_VIEW_H
|
|
|
|
#define _RUN_VIEW_H
|
2010-07-10 08:58:15 -05:00
|
|
|
|
2021-07-14 13:17:00 -05:00
|
|
|
#include <TextView.h>
|
2021-07-14 20:08:14 -05:00
|
|
|
#include <Url.h>
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2021-07-14 22:10:23 -05:00
|
|
|
class BPopUpMenu;
|
|
|
|
|
2010-07-10 08:58:15 -05:00
|
|
|
|
2021-07-14 13:17:00 -05:00
|
|
|
class RunView : public BTextView {
|
2010-07-10 08:58:15 -05:00
|
|
|
public:
|
2021-07-14 13:17:00 -05:00
|
|
|
RunView(const char* name);
|
2010-07-10 08:58:15 -05:00
|
|
|
|
2021-07-14 22:10:23 -05:00
|
|
|
virtual void MessageReceived(BMessage* msg);
|
2021-07-14 15:13:36 -05:00
|
|
|
|
|
|
|
// Only differs in that it changes font face and color of any URLs
|
|
|
|
virtual void Insert(const char* text, const text_run_array* runs = NULL);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2021-07-14 20:08:14 -05:00
|
|
|
virtual void MouseDown(BPoint where);
|
|
|
|
virtual void MouseUp(BPoint where);
|
|
|
|
virtual void MouseMoved(BPoint where, uint32 code, const BMessage* drag);
|
|
|
|
|
|
|
|
virtual void Select(int32 startOffset, int32 endOffset);
|
|
|
|
|
2021-07-14 22:10:23 -05:00
|
|
|
void Append(const char* text, rgb_color color,
|
|
|
|
uint16 fontFace = B_REGULAR_FACE);
|
|
|
|
void Append(const char* text);
|
|
|
|
|
2021-07-15 13:01:21 -05:00
|
|
|
void Replace(int32 start, int32 end, const char* text,
|
|
|
|
text_run_array* runs);
|
|
|
|
void ReplaceRuns(int32 start, int32 end, text_run_array* runs);
|
|
|
|
|
2021-07-14 20:08:14 -05:00
|
|
|
BString WordAt(BPoint point);
|
2021-07-14 22:10:23 -05:00
|
|
|
void FindWordAround(int32 offset, int32* start, int32* end,
|
|
|
|
BString* _word = NULL);
|
2021-07-14 20:08:14 -05:00
|
|
|
const char* GetLine(int32 line);
|
|
|
|
|
|
|
|
bool OverText(BPoint where);
|
2021-07-15 13:01:21 -05:00
|
|
|
bool OverUrl(BPoint where);
|
2021-07-14 20:08:14 -05:00
|
|
|
|
|
|
|
void ScrollToBottom();
|
|
|
|
|
2021-07-14 13:17:00 -05:00
|
|
|
private:
|
2021-07-14 22:10:23 -05:00
|
|
|
BPopUpMenu* _RightClickPopUp(BPoint where);
|
|
|
|
|
2021-07-15 13:01:21 -05:00
|
|
|
bool _FindUrlString(BString text, int32* start, int32* end,
|
|
|
|
int32 offset);
|
|
|
|
|
|
|
|
// For safe-keeping
|
2021-07-14 13:17:00 -05:00
|
|
|
text_run_array fDefaultRun;
|
2021-07-14 15:13:36 -05:00
|
|
|
text_run_array fUrlRun;
|
2021-07-15 13:01:21 -05:00
|
|
|
text_run_array fUrlHoverRun;
|
|
|
|
text_run_array fUrlVisitedRun;
|
2021-07-14 20:08:14 -05:00
|
|
|
BCursor* fUrlCursor;
|
2021-07-15 13:01:21 -05:00
|
|
|
|
|
|
|
// 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
|
2021-07-14 20:08:14 -05:00
|
|
|
BUrl fLastClicked;
|
|
|
|
bool fMouseDown;
|
|
|
|
bool fSelecting;
|
2010-05-07 04:47:10 -05:00
|
|
|
};
|
|
|
|
|
2021-07-14 13:17:00 -05:00
|
|
|
#endif // _RUN_VIEW_H
|