Skip to content

Commit

Permalink
Implement semi-standard "\e]8" escape sequence for links.
Browse files Browse the repository at this point in the history
  • Loading branch information
PerBothner committed May 9, 2018
1 parent b32d6ca commit 19771fa
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 15 deletions.
30 changes: 29 additions & 1 deletion doc/DomTerm.texi
Original file line number Diff line number Diff line change
Expand Up @@ -2208,7 +2208,7 @@ For example @code{.html} matches html files.
Suceeds if @var{condition} fails and vice versa.
@end table
@item @var{custom template}
Useing @samp{%}-escapes to create a susyem shell command.
Using @samp{%}-escapes to create a system shell command.
The following escapes are supported:
@table @asis
@item @code{%U}
Expand Down Expand Up @@ -2575,6 +2575,27 @@ can be moved between windows.

Implement ``drop-down'' mode.

@subsubheading Implement our own menus

We should implement our own context-menu and optionally a menubar
using some portable JavaScript library.
Currently, menus are implemented when embedded in Electron, Qt, or Atom,
but not for other embeddings or when using a desktop browser.

If we implement our menubar and context menu and they look reasonably nice,
then there is little need to use Electron or Qt:
Using Chrome with the @code{--app} flag should be just as nice,
and presumably use less memory.
@uref{https://github.com/zserge/webview/,Webview} is another (zippier) option.

Most promising is PhosphorJS
(has other useful features, but uses TypeScript, and is a bit heavy).
Other options:
@uref{https://github.com/s-yadav/contextMenu.js,contextMenu.js}
(not actively maintained, doesn't have all we need,
but has the basics and can be enhanced);
@uref{https://jqueryui.com/menu/,JQuery UI Menu}.

@subheading Support other embeddable browsers

Some toolkits to explore for integrated browser/application:
Expand Down Expand Up @@ -3082,6 +3103,13 @@ Specifies the current directory of the process.
(This is generated by some shells by default.
On Fedora this is done by the script @code{/etc/profile.d/vte.sh}.)

@item @code{"\e]8;"} @var{options} @code{";"} @var{url} @code{"\a"} @var{text} @code{"\e]8;;\a"}

Create a link with the given @var{url} and
display @var{text} (which can contain other escape sequences for styling).
The @var{options} are ignored. The link has @code{class="subtle"}.
See @uref{https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda,this link}.

@item @code{"\e]30;" @var{name} "\a"}
Sets the ``session name'' to @var{name}, which is shown in the window title.
Specifically sets the @code{name} attribute of the top-level
Expand Down
48 changes: 34 additions & 14 deletions hlib/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5397,6 +5397,26 @@ DomTerm.prototype.handleOperatingSystemControl = function(code, text) {
case 31:
this.topNode.setAttribute("pid", text);
break;
case 8:
var semi = text.indexOf(';');
if (semi >= 0) {
let options = text.substring(0, semi);
let url = text.substring(semi+1);
let oldLink = DomTerm._isInElement(this.outputContainer, "A");
if (oldLink) {
while (this.outputContainer != oldLink)
this._popStyleSpan();
this._popStyleSpan();
}
if (url) {
let newLink = document.createElement("A");
newLink.setAttribute("href", url);
newLink.setAttribute("class", "subtle");
this._pushIntoElement(newLink);
DomTerm._addMouseEnterHandlers(this, newLink.parentNode);
}
}
break;
case 10:
case 11:
case 12:
Expand Down Expand Up @@ -8437,22 +8457,22 @@ DomTerm.isDelimiter = (function() {
let mask2 = 0; // mask for char values 64..95
let mask3 = 0; // mask for char values 96..127
for (let i = delimiterChars.length; --i >= 0; ) {
let ch = delimiterChars.charCodeAt(i);
if (ch >= 32 && ch < 64)
mask1 |= 1 << (ch - 32);
else if (ch >= 64 && ch < 96)
mask2 |= 1 << (ch - 64);
else if (ch >= 96 && ch < 128)
mask3 |= 1 << (ch - 96);
let ch = delimiterChars.charCodeAt(i);
if (ch >= 32 && ch < 64)
mask1 |= 1 << (ch - 32);
else if (ch >= 64 && ch < 96)
mask2 |= 1 << (ch - 64);
else if (ch >= 96 && ch < 128)
mask3 |= 1 << (ch - 96);
}
return function(ch) {
if (ch < 64)
return ch <= 32 ? true : (mask1 & (1 << (ch - 32))) != 0;
else if (ch < 128)
return ch < 96 ? (mask2 & (1 << (ch - 64))) != 0
: (mask3 & (1 << (ch - 96))) != 0;
else
return false;
if (ch < 64)
return ch <= 32 ? true : (mask1 & (1 << (ch - 32))) != 0;
else if (ch < 128)
return ch < 96 ? (mask2 & (1 << (ch - 64))) != 0
: (mask3 & (1 << (ch - 96))) != 0;
else
return false;
}
})();

Expand Down

0 comments on commit 19771fa

Please sign in to comment.