Add VTX hyperlink support for URLs
This commit is contained in:
parent
7837a2a7bd
commit
b0260049ba
|
@ -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}\\`;
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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!
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue