Skip to content
Snippets Groups Projects
Commit c1be4e98 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Add method: query_ctda() - Query CTerm Device Attributes

Returns an array of attributes (digits), if valid response

Now Nightfox, you can query SyncTERM (only) to see if it supports Pixel ops
(e.g. Sixel) is supported at the moment, using:

  cterm_lib.query_ctda(cterm_lib.cterm_device_attributes.pixelops_supported)

- will return true if pixel operations are supported

Other dynamic terminal capabilities (e.g. depdendant on the output mode that
SyncTERM is run in) can be detected with this method. But note: the values
returned in SyncTERM's CTDA query-response do not exaclty match the values
documented in cterm.txt. So use the constants from cterm_lib.js instead.
parent 980dad23
Branches
Tags
No related merge requests found
......@@ -21,6 +21,16 @@ const font_state_field_result = 1;
const font_state_field_style = 2;
const da_ver_major = 0;
const da_ver_minor = 1;
const cterm_device_attributes = {
valid:'0',
loadable_fonts:'1',
bright_background:'2',
palette_settable:'3',
pixelops_supported:'4',
font_selectable:'5',
extended_palette:'6',
mouse_available:'7'
};
if(console.cterm_version === undefined || console.cterm_version < 0) {
var response = query_da();
......@@ -192,6 +202,17 @@ function query_fontdim()
return false;
}
function query_ctda(which)
{
var response = query("\x1b[<c");
if(response.substr(0, 3) != "\x1b[<" || response.substr(-1) != "c")
return false;
var attributes = response.slice(3, -1).split(/;/);
if(which !== undefined)
return attributes.indexOf(which) >= 0;
return attributes;
}
function fontsize(n)
{
switch(n) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment