| 119 | } |
| 120 | |
| 121 | void URLFinder::notify(const Scintilla::NotificationData *pscn) |
| 122 | { |
| 123 | // TODO: handle editor folding/unfolding |
| 124 | // Currently there is no generic notification for this |
| 125 | |
| 126 | // Reprocess any time the content was updated or the editor was vertically scrolled |
| 127 | if ((pscn->nmhdr.code == Scintilla::Notification::UpdateUI)) { |
| 128 | if (FlagSet(pscn->updated, Scintilla::Update::VScroll)) { |
| 129 | timer->start(); |
| 130 | } |
| 131 | } |
| 132 | else if (pscn->nmhdr.code == Scintilla::Notification::Modified) { |
| 133 | if (FlagSet(pscn->modificationType, Scintilla::ModificationFlags::InsertText) || FlagSet(pscn->modificationType, Scintilla::ModificationFlags::DeleteText)) { |
| 134 | timer->start(); |
| 135 | } |
| 136 | } |
| 137 | else if (pscn->nmhdr.code == Scintilla::Notification::Zoom) { |
| 138 | timer->start(); |
| 139 | } |
| 140 | else if (pscn->nmhdr.code == Scintilla::Notification::IndicatorClick && FlagSet(pscn->modifiers, Scintilla::KeyMod::Ctrl)) { |
| 141 | const int indicators = editor->indicatorAllOnFor(pscn->position); |
| 142 | |
| 143 | if (indicators & (1 << indicator)) { |
| 144 | |
| 145 | const int indicatorStart = editor->indicatorStart(indicator, pscn->position); |
| 146 | const int indicatorEnd = editor->indicatorEnd(indicator, pscn->position); |
| 147 | |
| 148 | QUrl url(editor->get_text_range(indicatorStart, indicatorEnd)); |
| 149 | |
| 150 | if (url.isValid()) { |
| 151 | qInfo("URL hotspot click: \"%s\"", editor->get_text_range(indicatorStart, indicatorEnd).constData()); |
| 152 | QDesktopServices::openUrl(url); |
| 153 | } |
| 154 | else { |
| 155 | qWarning("Invalid url \"%s\"", qUtf8Printable(url.errorString())); |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | bool URLFinder::isURL(int position) const |
| 162 | { |