Merge branch 'xtversion'

Closes #359
This commit is contained in:
Daniel Eklöf 2021-06-13 17:20:47 +02:00
commit c3274fd97e
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
4 changed files with 30 additions and 4 deletions

View file

@ -301,6 +301,9 @@
(https://codeberg.org/dnkl/foot/issues/395).
* Completions for Bash shell
(https://codeberg.org/dnkl/foot/issues/10).
* Implement `XTVERSION` (`CSI > 0q`). Foot will reply with
`DCS>|foot(<major>.<minor>.<patch>)ST`
(https://codeberg.org/dnkl/foot/issues/359).
### Changed

16
csi.c
View file

@ -1565,6 +1565,22 @@ csi_dispatch(struct terminal *term, uint8_t final)
}
break; /* final == 'm' */
case 'q': {
/* XTVERSION */
if (vt_param_get(term, 0, 0) != 0) {
UNHANDLED();
break;
}
char reply[64];
size_t n = xsnprintf(
reply, sizeof(reply), "\033P>|foot(%u.%u.%u%s%s)\033\\",
FOOT_MAJOR, FOOT_MINOR, FOOT_PATCH,
FOOT_EXTRA[0] != '\0' ? "-" : "", FOOT_EXTRA);
term_to_slave(term, reply, n);
break;
}
default:
UNHANDLED();
break;

View file

@ -549,6 +549,11 @@ manipulation sequences. The generic format is:
: XTSMGRAPHICS
: xterm
: Set or request sixel attributes.
| \\E > _Ps_ q
: XTVERSION
: xterm
: _Ps_=0 -> report terminal name and version, in the form
*\\EP>|foot(version)\\E\\*.
# OSC

View file

@ -22,14 +22,16 @@ else
new_version="${default_version}"
fi
major=$(echo "${new_version}" | sed -r 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1/')
minor=$(echo "${new_version}" | sed -r 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\2/')
patch=$(echo "${new_version}" | sed -r 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\3/')
major=$(echo "${new_version}" | sed -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)(-([0-9]+-g[a-z0-9]+) .*)?/\1/')
minor=$(echo "${new_version}" | sed -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)(-([0-9]+-g[a-z0-9]+) .*)?/\2/')
patch=$(echo "${new_version}" | sed -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)(-([0-9]+-g[a-z0-9]+) .*)?/\3/')
extra=$(echo "${new_version}" | sed -r 's/([0-9]+)\.([0-9]+)\.([0-9]+)(-([0-9]+-g[a-z0-9]+) .*)?/\5/')
new_version="#define FOOT_VERSION \"${new_version}\"
#define FOOT_MAJOR ${major}
#define FOOT_MINOR ${minor}
#define FOOT_PATCH ${patch}"
#define FOOT_PATCH ${patch}
#define FOOT_EXTRA \"${extra}\""
if [ -f "${out_file}" ]; then
old_version=$(cat "${out_file}")