mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-24 14:22:40 -06:00
RichEdit: Ctrl+Click now opens http and https links
This commit is contained in:
parent
b2f942a3e1
commit
e144f2d3ce
3 changed files with 77 additions and 56 deletions
|
|
@ -662,6 +662,58 @@ void RichEdit::Skin()
|
|||
SetLastCharFormat(last_format);
|
||||
}
|
||||
|
||||
|
||||
void RichEditWithToolBar::TheBar(Bar& bar)
|
||||
{
|
||||
DefaultBar(bar, extended);
|
||||
}
|
||||
|
||||
void RichEditWithToolBar::RefreshBar()
|
||||
{
|
||||
toolbar.Set(THISBACK(TheBar));
|
||||
}
|
||||
|
||||
void RichEditWithToolBar::Skin()
|
||||
{
|
||||
RichEdit::Skin();
|
||||
RefreshBar();
|
||||
}
|
||||
|
||||
void RichEdit::EvaluateFields()
|
||||
{
|
||||
WhenStartEvaluating();
|
||||
text.EvaluateFields(vars);
|
||||
Finish();
|
||||
}
|
||||
|
||||
RichEditWithToolBar::RichEditWithToolBar()
|
||||
{
|
||||
InsertFrame(0, toolbar);
|
||||
WhenRefreshBar = callback(this, &RichEditWithToolBar::RefreshBar);
|
||||
extended = true;
|
||||
}
|
||||
|
||||
bool RichEdit::IsDarkContent() const
|
||||
{
|
||||
return dark_content || allow_dark_content && IsDarkTheme();
|
||||
}
|
||||
|
||||
RichEdit& RichEdit::DarkContent(bool b)
|
||||
{
|
||||
dark_content = b;
|
||||
Refresh();
|
||||
DoRefreshBar();
|
||||
return *this;
|
||||
}
|
||||
|
||||
RichEdit& RichEdit::AllowDarkContent(bool b)
|
||||
{
|
||||
allow_dark_content = b;
|
||||
Refresh();
|
||||
DoRefreshBar();
|
||||
return *this;
|
||||
}
|
||||
|
||||
RichEdit::RichEdit()
|
||||
{
|
||||
floating_zoom = Null;
|
||||
|
|
@ -803,59 +855,16 @@ RichEdit::RichEdit()
|
|||
ignore_physical_size = false;
|
||||
|
||||
SetLastCharFormat();
|
||||
|
||||
WhenLink = [](const String& s) {
|
||||
LaunchWebBrowser(s);
|
||||
};
|
||||
|
||||
WhenIsLink = [](const String& s) {
|
||||
return s.StartsWith("http://") || s.StartsWith("https://");
|
||||
};
|
||||
}
|
||||
|
||||
RichEdit::~RichEdit() {}
|
||||
|
||||
void RichEditWithToolBar::TheBar(Bar& bar)
|
||||
{
|
||||
DefaultBar(bar, extended);
|
||||
}
|
||||
|
||||
void RichEditWithToolBar::RefreshBar()
|
||||
{
|
||||
toolbar.Set(THISBACK(TheBar));
|
||||
}
|
||||
|
||||
void RichEditWithToolBar::Skin()
|
||||
{
|
||||
RichEdit::Skin();
|
||||
RefreshBar();
|
||||
}
|
||||
|
||||
void RichEdit::EvaluateFields()
|
||||
{
|
||||
WhenStartEvaluating();
|
||||
text.EvaluateFields(vars);
|
||||
Finish();
|
||||
}
|
||||
|
||||
RichEditWithToolBar::RichEditWithToolBar()
|
||||
{
|
||||
InsertFrame(0, toolbar);
|
||||
WhenRefreshBar = callback(this, &RichEditWithToolBar::RefreshBar);
|
||||
extended = true;
|
||||
}
|
||||
|
||||
bool RichEdit::IsDarkContent() const
|
||||
{
|
||||
return dark_content || allow_dark_content && IsDarkTheme();
|
||||
}
|
||||
|
||||
RichEdit& RichEdit::DarkContent(bool b)
|
||||
{
|
||||
dark_content = b;
|
||||
Refresh();
|
||||
DoRefreshBar();
|
||||
return *this;
|
||||
}
|
||||
|
||||
RichEdit& RichEdit::AllowDarkContent(bool b)
|
||||
{
|
||||
allow_dark_content = b;
|
||||
Refresh();
|
||||
DoRefreshBar();
|
||||
return *this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,14 +79,14 @@ void RichEdit::LeftDown(Point p, dword flags)
|
|||
NextUndo();
|
||||
SetFocus();
|
||||
selclick = false;
|
||||
tabmove = GetHotPos(p);
|
||||
tabmove = GetHotPos(p); // resizing table columns
|
||||
if(tabmove.table && tabmove.column >= -2) {
|
||||
SaveTableFormat(tabmove.table);
|
||||
SetCapture();
|
||||
Move(text.GetCellPos(tabmove.table, 0, max(tabmove.column, 0)).pos);
|
||||
return;
|
||||
}
|
||||
int c = GetHotSpot(p);
|
||||
int c = GetHotSpot(p); // resizing active object
|
||||
if(c >= 0 && objectpos >= 0) {
|
||||
int pos = objectpos;
|
||||
RectTracker tracker(*this);
|
||||
|
|
@ -123,11 +123,16 @@ void RichEdit::LeftDown(Point p, dword flags)
|
|||
}
|
||||
else {
|
||||
c = GetMousePos(p);
|
||||
RichPos pi = text.GetRichPos(c);
|
||||
if(c >= 0) {
|
||||
if(InSelection(c)) {
|
||||
selclick = true;
|
||||
return;
|
||||
}
|
||||
if((flags & K_CTRL) && WhenIsLink(pi.format.link)) {
|
||||
WhenLink(pi.format.link);
|
||||
return;
|
||||
}
|
||||
Move(c, flags & K_SHIFT);
|
||||
mpos = c;
|
||||
SetCapture();
|
||||
|
|
@ -422,7 +427,9 @@ Image RichEdit::CursorImage(Point p, dword flags)
|
|||
case 2:
|
||||
return Image::SizeHorz();
|
||||
default:
|
||||
if(text.GetRichPos(GetMousePos(p)).object) {
|
||||
int c = GetMousePos(p);
|
||||
RichPos pi = text.GetRichPos(c);
|
||||
if(pi.object) {
|
||||
return Image::Arrow();
|
||||
}
|
||||
else
|
||||
|
|
@ -433,8 +440,11 @@ Image RichEdit::CursorImage(Point p, dword flags)
|
|||
if(hp.table > 0)
|
||||
return Image::SizeHorz();
|
||||
else {
|
||||
int c = GetMousePos(p);
|
||||
return InSelection(c) && !HasCapture() ? Image::Arrow() : Image::IBeam();
|
||||
if(InSelection(c) && !HasCapture())
|
||||
return Image::Arrow();
|
||||
if((flags & K_CTRL) && WhenIsLink(pi.format.link))
|
||||
return Image::Hand();
|
||||
return Image::IBeam();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -695,6 +695,8 @@ public:
|
|||
Event<String&> WhenIndexEntry;
|
||||
Event<Bar&> WhenBar;
|
||||
Event<> WhenSel;
|
||||
Gate<const String&> WhenIsLink;
|
||||
Event<const String&> WhenLink;
|
||||
|
||||
void StdBar(Bar& menu);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue