Image placement using Unicode placeholders

This commit introduces the Unicode placeholder image placement method.
In particular:
- Virtual placements can be created by passing `U=1` in a put command.
- Images with virtual placements can be displayed using the placeholder
  character `U+10EEEE` with diacritics indicating rows and columns.
- The image ID is indicated by the foreground color of the placeholder.
  Additionally, the most significant byte of the ID can be specified via
  the third diacritic.
- Underline color can be optionally used to specify the placement ID.
- A bug was fixed, which caused incomplete image removal when it was
  overwritten by another image with the same ID.
This commit is contained in:
Sergei Grechanik
2022-10-29 19:48:06 -07:00
parent 1f84e2d4e5
commit d63eeada73
20 changed files with 1288 additions and 17 deletions

View File

@@ -529,6 +529,52 @@ def gen_wcwidth() -> None:
subprocess.check_call(['gofmt', '-w', '-s', gof.name])
def gen_rowcolumn_diacritics() -> None:
# codes of all row/column diacritics
codes = []
with open("./rowcolumn-diacritics.txt", "r") as file:
for line in file.readlines():
if line.startswith('#'):
continue
code = int(line.split(";")[0], 16)
codes.append(code)
with create_header('kitty/rowcolumn-diacritics.c') as p:
p('#include "unicode-data.h"')
p('int diacritic_to_num(char_type code) {')
p('\tswitch (code) {')
range_start_num = 1
range_start = 0
range_end = 0
def print_range() -> None:
if range_start >= range_end:
return
write_case((range_start, range_end), p)
p('\t\treturn code - ' + hex(range_start) + ' + ' +
str(range_start_num) + ';')
for code in codes:
if range_end == code:
range_end += 1
else:
print_range()
range_start_num += range_end - range_start
range_start = code
range_end = code + 1
print_range()
p('\t}')
p('\treturn 0;')
p('}')
with open('kittens/icat/rowcolumn_diacritics.py', 'w') as f:
f.write('# generated by gen-wcwidth.py, do not edit\n\n')
strings_utf8 = ', '.join(repr(chr(c).encode('utf-8')) for c in codes)
f.write("rowcolumn_diacritics_utf8 = ({}) # noqa\n".format(strings_utf8))
parse_ucd()
parse_prop_list()
parse_emoji()
@@ -537,3 +583,4 @@ gen_ucd()
gen_wcwidth()
gen_emoji()
gen_names()
gen_rowcolumn_diacritics()