Add VTX hyperlink support for URLs

This commit is contained in:
Bryan Ashby 2017-09-21 21:23:30 -06:00
parent 7837a2a7bd
commit b0260049ba
5 changed files with 26 additions and 5 deletions

View File

@ -56,7 +56,7 @@ exports.getSyncTERMFontFromAlias = getSyncTERMFontFromAlias;
exports.setSyncTermFontWithAlias = setSyncTermFontWithAlias;
exports.setCursorStyle = setCursorStyle;
exports.setEmulatedBaudRate = setEmulatedBaudRate;
exports.getVtxHyperlink = getVtxHyperlink;
//
// See also
@ -485,3 +485,14 @@ function setEmulatedBaudRate(rate) {
}[rate] || 0;
return 0 === speed ? exports.emulationSpeed() : exports.emulationSpeed(1, speed);
}
function getVtxHyperlink(client, url, text) {
if(!client.terminalSupports('vtx_hyperlink')) {
return '';
}
text = text || url;
url = url.split('').map(c => c.charCodeAt(0)).join(';');
return `${ESC_CSI}1;${text.length};1;1;${url}\\`;
}

View File

@ -493,10 +493,15 @@ Client.prototype.defaultHandlerMissingMod = function(err) {
};
Client.prototype.terminalSupports = function(query) {
const termClient = this.term.termClient;
switch(query) {
case 'vtx_audio' :
// https://github.com/codewar65/VTX_ClientServer/blob/master/vtx.txt
return this.termClient === 'vtx';
return 'vtx' === termClient;
case 'vtx_hyperlink' :
return termClient === 'vtx';
default :
return false;

View File

@ -158,7 +158,10 @@ function getDefaultConfig() {
newUserNames : [ 'new', 'apply' ], // Names reserved for applying
// :TODO: Mystic uses TRASHCAN.DAT for this -- is there a reason to support something like that?
badUserNames : [ 'sysop', 'admin', 'administrator', 'root', 'all' ],
badUserNames : [
'sysop', 'admin', 'administrator', 'root', 'all',
'areamgr', 'filemgr', 'filefix', 'areafix', 'allfix'
],
},
// :TODO: better name for "defaults"... which is redundant here!

View File

@ -271,8 +271,10 @@ const transformers = {
styleMixed : (s) => stylizeString(s, 'mixed'),
styleL33t : (s) => stylizeString(s, 'l33t'),
// :TODO:
// toMegs(), toKilobytes(), ...
// toList(), toCommaList(),
sizeWithAbbr : (n) => formatByteSize(n, true, 2),
sizeWithoutAbbr : (n) => formatByteSize(n, false, 2),
sizeAbbr : (n) => formatByteSizeAbbr(n),

View File

@ -274,7 +274,7 @@ exports.getModule = class FileAreaList extends MenuModule {
} else {
const webDlExpireTimeFormat = config.webDlExpireTimeFormat || 'YYYY-MMM-DD @ h:mm';
entryInfo.webDlLink = serveItem.url;
entryInfo.webDlLink = ansi.getVtxHyperlink(this.client, serveItem.url) + serveItem.url;
entryInfo.webDlExpire = moment(serveItem.expireTimestamp).format(webDlExpireTimeFormat);
}
@ -497,7 +497,7 @@ exports.getModule = class FileAreaList extends MenuModule {
const webDlExpireTimeFormat = self.menuConfig.config.webDlExpireTimeFormat || 'YYYY-MMM-DD @ h:mm';
self.currentFileEntry.entryInfo.webDlLink = url;
self.currentFileEntry.entryInfo.webDlLink = ansi.getVtxHyperlink(self.client, url) + url;
self.currentFileEntry.entryInfo.webDlExpire = expireTime.format(webDlExpireTimeFormat);
return callback(null);