Compare commits
135 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
350cfeb7ef | ||
|
|
97d379b13e | ||
|
|
2154d555e5 | ||
|
|
1389c36657 | ||
|
|
bd1e7d6942 | ||
|
|
91299a279b | ||
|
|
fb1c318a09 | ||
|
|
2a07b3f46a | ||
|
|
ffc4e99717 | ||
|
|
fe807dd66f | ||
|
|
40ce5db812 | ||
|
|
649a9f4a6f | ||
|
|
e17ce875be | ||
|
|
415701c58a | ||
|
|
f16f80b459 | ||
|
|
628e6cc87f | ||
|
|
8f9a225c3a | ||
|
|
7b41bc95e1 | ||
|
|
2d06ee5822 | ||
|
|
40b4fb966f | ||
|
|
be696a9d76 | ||
|
|
1ffe9bef35 | ||
|
|
ed70d95c44 | ||
|
|
49bf876f73 | ||
|
|
e512b4d3e3 | ||
|
|
e78b6c7c7c | ||
|
|
a7403c0005 | ||
|
|
5bed0dddaa | ||
|
|
bc302dad23 | ||
|
|
41b0f8852f | ||
|
|
2fadd3e7ba | ||
|
|
dcfd2b8d60 | ||
|
|
7fe63a7aad | ||
|
|
67f2ec2421 | ||
|
|
8e7a23a7b9 | ||
|
|
8e96a27d51 | ||
|
|
b337d4d9d5 | ||
|
|
d9404c0362 | ||
|
|
e4ba5f449f | ||
|
|
17fd749e8d | ||
|
|
f3be5b5e57 | ||
|
|
e619eb9cbb | ||
|
|
a65ee155c5 | ||
|
|
4037480d2b | ||
|
|
97e6978ed8 | ||
|
|
f05eefcc20 | ||
|
|
3f926dfd8b | ||
|
|
59f64c5e33 | ||
|
|
87059a2004 | ||
|
|
7c52dd2bd8 | ||
|
|
70c2765a6e | ||
|
|
3618f4d642 | ||
|
|
698569536d | ||
|
|
c398d3d16e | ||
|
|
9dbc54aad6 | ||
|
|
931cb223cd | ||
|
|
336ee53fea | ||
|
|
34350af61c | ||
|
|
72f7cb3b7d | ||
|
|
481047a446 | ||
|
|
3bf1d73b07 | ||
|
|
b3b830bb5f | ||
|
|
def0c55df3 | ||
|
|
b995e00850 | ||
|
|
32dfc94909 | ||
|
|
20f7118432 | ||
|
|
37e6c3f0cb | ||
|
|
0459dda5c2 | ||
|
|
a10c816c05 | ||
|
|
c0c7cfacc2 | ||
|
|
8cdb6647ed | ||
|
|
b68e3c85b9 | ||
|
|
ef25d5bbd5 | ||
|
|
278bf6e897 | ||
|
|
90a985b73a | ||
|
|
b016353809 | ||
|
|
bc222af2e2 | ||
|
|
44599c9460 | ||
|
|
902fc22670 | ||
|
|
d84e22fbf1 | ||
|
|
6cc720a350 | ||
|
|
c905978874 | ||
|
|
bfe595a8e8 | ||
|
|
94d56d1a9e | ||
|
|
bd3f0b5363 | ||
|
|
6fae3545c7 | ||
|
|
297963f6ab | ||
|
|
a0ceba407e | ||
|
|
35fa91fba2 | ||
|
|
a5d6cd169e | ||
|
|
06c2263657 | ||
|
|
472c6f6b8d | ||
|
|
afcaca85da | ||
|
|
2575349ec2 | ||
|
|
77054f688d | ||
|
|
c5cb24378f | ||
|
|
d66123dd14 | ||
|
|
4ef8f11f9e | ||
|
|
599be7ddc9 | ||
|
|
685497fc8c | ||
|
|
57542fc204 | ||
|
|
8d9323aec6 | ||
|
|
4984a25b19 | ||
|
|
3bdcb29e01 | ||
|
|
b9ab8e6348 | ||
|
|
4a851701e9 | ||
|
|
eafd8af937 | ||
|
|
28bb123be8 | ||
|
|
8e1ed2f8c3 | ||
|
|
4a0fcb3cff | ||
|
|
b5c2163238 | ||
|
|
d0ecdfb330 | ||
|
|
bdf7d98a36 | ||
|
|
e4b0980d15 | ||
|
|
d99c57aeae | ||
|
|
5f855ce547 | ||
|
|
68f3b6fbeb | ||
|
|
dc6d14943e | ||
|
|
05f7334db9 | ||
|
|
cd707e9335 | ||
|
|
505ed5e43b | ||
|
|
9dc8bf5f62 | ||
|
|
f8098662b6 | ||
|
|
de7a0e86c4 | ||
|
|
ca55438fda | ||
|
|
a4b60e7eef | ||
|
|
5d22e07738 | ||
|
|
bdade7e151 | ||
|
|
6958ded4c4 | ||
|
|
cc06104be6 | ||
|
|
059c34c345 | ||
|
|
9cbb726566 | ||
|
|
e8b4356a88 | ||
|
|
634138cd3b | ||
|
|
3f6b07de81 |
3
.github/FUNDING.yml
vendored
Normal file
3
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
patreon: kovidgoyal
|
||||
liberapay: kovidgoyal
|
||||
custom: https://sw.kovidgoyal.net/kitty/support.html
|
||||
27
.gitignore
vendored
27
.gitignore
vendored
@@ -1,18 +1,17 @@
|
||||
*.so
|
||||
*.pyc
|
||||
*.pyo
|
||||
tags
|
||||
build
|
||||
linux-package
|
||||
kitty.app
|
||||
compile_commands.json
|
||||
link_commands.json
|
||||
glad/out
|
||||
kitty/launcher
|
||||
*.dSYM
|
||||
dev
|
||||
__pycache__
|
||||
glfw/wayland-*-client-protocol.[ch]
|
||||
docs/_build
|
||||
docs/generated
|
||||
/tags
|
||||
/build/
|
||||
/linux-package/
|
||||
/kitty.app/
|
||||
/compile_commands.json
|
||||
/link_commands.json
|
||||
/glad/out/
|
||||
/kitty/launcher/
|
||||
/*.dSYM/
|
||||
__pycache__/
|
||||
/glfw/wayland-*-client-protocol.[ch]
|
||||
/docs/_build/
|
||||
/docs/generated/
|
||||
.DS_Store
|
||||
|
||||
6
Makefile
6
Makefile
@@ -1,8 +1,8 @@
|
||||
ifdef V
|
||||
VVAL=--verbose
|
||||
VVAL=--verbose
|
||||
endif
|
||||
ifdef VERBOSE
|
||||
VVAL=--verbose
|
||||
VVAL=--verbose
|
||||
endif
|
||||
|
||||
all:
|
||||
@@ -28,7 +28,7 @@ asan:
|
||||
profile:
|
||||
python3 setup.py build $(VVAL) --profile
|
||||
|
||||
app:
|
||||
app:
|
||||
python3 setup.py kitty.app $(VVAL)
|
||||
|
||||
man:
|
||||
|
||||
@@ -4,6 +4,78 @@ Changelog
|
||||
|kitty| is a feature full, cross-platform, *fast*, GPU based terminal emulator.
|
||||
To update |kitty|, :doc:`follow the instructions <binary>`.
|
||||
|
||||
0.14.6 [2019-09-25]
|
||||
---------------------
|
||||
|
||||
- macOS: Fix a regression in the previous release that caused a crash when
|
||||
pressing a unprintable key, such as the POWER key (:iss:`1997`)
|
||||
|
||||
- Fix a regression in the previous release that caused kitty to not always
|
||||
respond to DPI changes (:pull:`1999`)
|
||||
|
||||
|
||||
0.14.5 [2019-09-23]
|
||||
---------------------
|
||||
|
||||
- Implement a hack to (mostly) preserve tabs when cat-ting a file with them and then
|
||||
copying the text or passing screen contents to another program (:iss:`1829`)
|
||||
|
||||
- When all visible windows have the same background color, use that as the
|
||||
color for the global padding, instead of the configured background color
|
||||
(:iss:`1957`)
|
||||
|
||||
- When resetting the terminal, also reset parser state, this allows easy
|
||||
recovery from incomplete escape codes (:iss:`1961`)
|
||||
|
||||
- Allow mapping keys commonly found on European keyboards (:pull:`1928`)
|
||||
|
||||
- Fix incorrect rendering of some symbols when followed by a space while using
|
||||
the PowerLine font which does not have a space glyph (:iss:`1225`)
|
||||
|
||||
- Linux: Allow using fonts with spacing=90 in addition to fonts with
|
||||
spacing=100 (:iss:`1968`)
|
||||
|
||||
- Use selection foreground color for underlines as well (:iss:`1982`)
|
||||
|
||||
0.14.4 [2019-08-31]
|
||||
---------------------
|
||||
|
||||
- hints kitten: Add a :option:`kitty +kitten hints --alphabet` option to
|
||||
control what alphabets are used for hints (:iss:`1879`)
|
||||
|
||||
- hints kitten: Allow specifying :option:`kitty +kitten hints --program`
|
||||
multiple times to run multiple programs (:iss:`1879`)
|
||||
|
||||
- Add a :opt:`kitten_alias` option that can be used to alias kitten invocation
|
||||
for brevity and to change kitten option defaults globally (:iss:`1879`)
|
||||
|
||||
- macOS: Add an option :opt:`macos_show_window_title_in` to control
|
||||
showing the window title in the menubar/titlebar (:pull:`1837`)
|
||||
|
||||
- macOS: Allow drag and drop of text from other applications into kitty
|
||||
(:pull:`1921`)
|
||||
|
||||
- When running kittens, use the colorscheme of the current window
|
||||
rather than the configured colorscheme (:iss:`1906`)
|
||||
|
||||
- Don't fail to start if running the shell to read the EDITOR env var fails
|
||||
(:iss:`1869`)
|
||||
|
||||
- Disable the ``liga`` and ``dlig`` OpenType features for broken fonts
|
||||
such as Nimbus Mono.
|
||||
|
||||
- Fix a regression that broke setting background_opacity via remote control
|
||||
(:iss:`1895`)
|
||||
|
||||
- Fix piping PNG images into the icat kitten not working (:iss:`1920`)
|
||||
|
||||
- When the OS returns a fallback font that does not actually contain glyphs
|
||||
for the text, do not exhaust the list of fallback fonts (:iss:`1918`)
|
||||
|
||||
- Fix formatting attributes not reset across line boundaries when passing
|
||||
buffer as ANSI (:iss:`1924`)
|
||||
|
||||
|
||||
0.14.3 [2019-07-29]
|
||||
---------------------
|
||||
|
||||
@@ -192,7 +264,7 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
||||
|
||||
- macOS: Fix :kbd:`cmd+period` key not working (:iss:`1318`)
|
||||
|
||||
- macOS: Add an option :opt:`macos_show_window_title_in_menubar` to not
|
||||
- macOS: Add an option `macos_show_window_title_in_menubar` to not
|
||||
show the current window title in the menu-bar (:iss:`1066`)
|
||||
|
||||
- macOS: Workaround for cocoa bug that could cause the mouse cursor to become
|
||||
|
||||
36
docs/faq.rst
36
docs/faq.rst
@@ -63,6 +63,18 @@ Really, the correct solution for this is to convince the OpenSSH maintainers to
|
||||
have ssh do this automatically, if possible, when connecting to a server, so that
|
||||
all terminals work transparently.
|
||||
|
||||
If the server is running FreeBSD, or another system that relies on termcap
|
||||
rather than terminfo, you will need to convert the terminfo file on your local
|
||||
machine by running (on local machine with |kitty|)::
|
||||
|
||||
infocmp -C xterm-kitty
|
||||
|
||||
The output of this command is the termcap description, which should be appended
|
||||
to :file:`/usr/share/misc/termcap` on the remote server. Then run the following
|
||||
command to apply your change (on the server)::
|
||||
|
||||
cap_mkdb /usr/share/misc/termcap
|
||||
|
||||
|
||||
Keys such as arrow keys, backspace, delete, home/end, etc. do not work when using su or sudo?
|
||||
-------------------------------------------------------------------------------------------------
|
||||
@@ -152,7 +164,27 @@ only monospace fonts, since every cell in the grid has to be the same size. If
|
||||
your font is not listed in ``kitty list-fonts`` it means that it is not
|
||||
monospace. On Linux you can list all monospace fonts with::
|
||||
|
||||
fc-list : family spacing | grep spacing=100
|
||||
fc-list : family spacing | grep -e spacing=100 -e spacing=90
|
||||
|
||||
Note that the spacing property is calculated by fontconfig based on actual
|
||||
glyph widths in the font. If for some reason fontconfig concludes your favorite
|
||||
monospace font does not have ``spacing=100`` you can override it by using the
|
||||
following :file:`~/.config/fontconfig/fonts.conf`::
|
||||
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
|
||||
<fontconfig>
|
||||
<match target="scan">
|
||||
<test name="family">
|
||||
<string>Your Font Family Name</string>
|
||||
</test>
|
||||
<edit name="spacing">
|
||||
<int>100</int>
|
||||
</edit>
|
||||
</match>
|
||||
</fontconfig>
|
||||
|
||||
Then, the font will be available in ``kitty list-fonts``.
|
||||
|
||||
|
||||
How can I assign a single global shortcut to bring up the kitty terminal?
|
||||
@@ -172,7 +204,7 @@ For example::
|
||||
|
||||
map alt+s send_text all \x13
|
||||
|
||||
This maps :kbd:`alt+s`` to :kbd:`ctrl+s`. To figure out what bytes to use for
|
||||
This maps :kbd:`alt+s` to :kbd:`ctrl+s`. To figure out what bytes to use for
|
||||
the :sc:`send_text <send_text>` you can use the ``showkey`` utility. Run::
|
||||
|
||||
showkey -a
|
||||
|
||||
@@ -107,7 +107,8 @@ features of the graphics protocol:
|
||||
sys.stdout.flush()
|
||||
cmd.clear()
|
||||
|
||||
write_chunked({'a': 'T', 'f': 100}, open(sys.argv[-1], 'rb').read())
|
||||
with open(sys.argv[-1], 'rb') as f:
|
||||
write_chunked({'a': 'T', 'f': 100}, f.read())
|
||||
|
||||
|
||||
Save this script as :file:`png.py`, then you can use it to display any PNG
|
||||
@@ -255,7 +256,10 @@ sequence of escape codes to the terminal emulator::
|
||||
Note that only the first escape code needs to have the full set of control
|
||||
codes such as width, height, format etc. Subsequent chunks must have
|
||||
only the ``m`` key. The client **must** finish sending all chunks for a single image
|
||||
before sending any other graphics related escape codes.
|
||||
before sending any other graphics related escape codes. Note that the cursor
|
||||
position used to display the image **must** be the position when the final chunk is
|
||||
received. Finally, terminals must not display anything, until the entire sequence is
|
||||
received and validated.
|
||||
|
||||
|
||||
Detecting available transmission mediums
|
||||
|
||||
@@ -20,6 +20,10 @@ import tempfile
|
||||
py3 = sys.version_info[0] > 2
|
||||
is64bit = platform.architecture()[0] == '64bit'
|
||||
is_macos = 'darwin' in sys.platform.lower()
|
||||
if is_macos:
|
||||
mac_ver = tuple(map(int, platform.mac_ver()[0].split('.')))
|
||||
if mac_ver[:2] < (10, 12):
|
||||
raise SystemExit('Your version of macOS is too old, at least 10.12 is required')
|
||||
|
||||
try:
|
||||
__file__
|
||||
@@ -225,7 +229,8 @@ def script_launch():
|
||||
|
||||
def update_intaller_wrapper():
|
||||
# To run: python3 -c "import runpy; runpy.run_path('installer.py', run_name='update_wrapper')" installer.sh
|
||||
src = open(__file__, 'rb').read().decode('utf-8')
|
||||
with open(__file__, 'rb') as f:
|
||||
src = f.read().decode('utf-8')
|
||||
wrapper = sys.argv[-1]
|
||||
with open(wrapper, 'r+b') as f:
|
||||
raw = f.read().decode('utf-8')
|
||||
|
||||
@@ -2,7 +2,7 @@ Documentation for the kitty remote control protocol
|
||||
======================================================
|
||||
|
||||
The kitty remote control protocol is a simple protocol that involves sending
|
||||
data to kitty in the form of JSON. Any individual command ot kitty has the
|
||||
data to kitty in the form of JSON. Any individual command of kitty has the
|
||||
form::
|
||||
|
||||
<ESC>P@kitty-cmd<JSON object><ESC>\
|
||||
@@ -21,7 +21,7 @@ standalone client, use the kitty version that you are developing against. Using
|
||||
a version greater than the version of the kitty instance you are talking to,
|
||||
will cause a failure.
|
||||
|
||||
Set ``no_response`` to True if you dont want a response from kitty.
|
||||
Set ``no_response`` to True if you don't want a response from kitty.
|
||||
|
||||
The optional payload is a JSON object that is specific to the actual command being sent.
|
||||
The fields in the object for every command are documented below.
|
||||
|
||||
@@ -29,10 +29,12 @@ def get_data(fname, folder='UCD'):
|
||||
bn = os.path.basename(url)
|
||||
local = os.path.join('/tmp', bn)
|
||||
if os.path.exists(local):
|
||||
data = open(local, 'rb').read()
|
||||
with open(local, 'rb') as f:
|
||||
data = f.read()
|
||||
else:
|
||||
data = urlopen(url).read()
|
||||
open(local, 'wb').write(data)
|
||||
with open(local, 'wb') as f:
|
||||
f.write(data)
|
||||
for line in data.decode('utf-8').splitlines():
|
||||
line = line.strip()
|
||||
if line and not line.startswith('#'):
|
||||
@@ -166,21 +168,20 @@ def write_case(spec, p):
|
||||
|
||||
@contextmanager
|
||||
def create_header(path, include_data_types=True):
|
||||
f = open(path, 'w')
|
||||
p = partial(print, file=f)
|
||||
p('// unicode data, built from the unicode standard on:', date.today())
|
||||
p('// see gen-wcwidth.py')
|
||||
if path.endswith('.h'):
|
||||
p('#pragma once')
|
||||
if include_data_types:
|
||||
p('#include "data-types.h"\n')
|
||||
p('START_ALLOW_CASE_RANGE')
|
||||
p()
|
||||
yield p
|
||||
p()
|
||||
if include_data_types:
|
||||
p('END_ALLOW_CASE_RANGE')
|
||||
f.close()
|
||||
with open(path, 'w') as f:
|
||||
p = partial(print, file=f)
|
||||
p('// unicode data, built from the unicode standard on:', date.today())
|
||||
p('// see gen-wcwidth.py')
|
||||
if path.endswith('.h'):
|
||||
p('#pragma once')
|
||||
if include_data_types:
|
||||
p('#include "data-types.h"\n')
|
||||
p('START_ALLOW_CASE_RANGE')
|
||||
p()
|
||||
yield p
|
||||
p()
|
||||
if include_data_types:
|
||||
p('END_ALLOW_CASE_RANGE')
|
||||
|
||||
|
||||
def gen_emoji():
|
||||
@@ -282,7 +283,9 @@ def gen_ucd():
|
||||
p('combining_type mark_for_codepoint(char_type c) {')
|
||||
rmap = codepoint_to_mark_map(p, mark_map)
|
||||
p('}\n')
|
||||
expected = int(re.search(r'^#define VS15 (\d+)', open('kitty/unicode-data.h').read(), re.M).group(1))
|
||||
with open('kitty/unicode-data.h') as f:
|
||||
unicode_data = f.read()
|
||||
expected = int(re.search(r'^#define VS15 (\d+)', unicode_data, re.M).group(1))
|
||||
if rmap[0xfe0e] != expected:
|
||||
raise ValueError('The mark for 0xfe0e has changed, you have to update VS15 to {} and VS16 to {} in unicode-data.h'.format(
|
||||
rmap[0xfe0e], rmap[0xfe0f]
|
||||
|
||||
2
glfw/backend_utils.h
vendored
2
glfw/backend_utils.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 Wayland - www.glfw.org
|
||||
// GLFW 3.4 Wayland - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
|
||||
//
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 macOS - www.glfw.org
|
||||
// GLFW 3.4 macOS - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
|
||||
2
glfw/cocoa_joystick.h
vendored
2
glfw/cocoa_joystick.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 Cocoa - www.glfw.org
|
||||
// GLFW 3.4 Cocoa - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 Cocoa - www.glfw.org
|
||||
// GLFW 3.4 Cocoa - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 macOS - www.glfw.org
|
||||
// GLFW 3.4 macOS - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
2
glfw/cocoa_platform.h
vendored
2
glfw/cocoa_platform.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 macOS - www.glfw.org
|
||||
// GLFW 3.4 macOS - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
|
||||
2
glfw/cocoa_time.c
vendored
2
glfw/cocoa_time.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 macOS - www.glfw.org
|
||||
// GLFW 3.4 macOS - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 macOS - www.glfw.org
|
||||
// GLFW 3.4 macOS - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
@@ -34,6 +34,61 @@
|
||||
// Needed for _NSGetProgname
|
||||
#include <crt_externs.h>
|
||||
|
||||
|
||||
#define PARAGRAPH_UTF_8 0xc2a7 // §
|
||||
#define MASCULINE_UTF_8 0xc2ba // º
|
||||
#define A_DIAERESIS_UPPER_CASE_UTF_8 0xc384 // Ä
|
||||
#define O_DIAERESIS_UPPER_CASE_UTF_8 0xc396 // Ö
|
||||
#define U_DIAERESIS_UPPER_CASE_UTF_8 0xc39c // Ü
|
||||
#define S_SHARP_UTF_8 0xc39f // ß
|
||||
#define A_GRAVE_LOWER_CASE_UTF_8 0xc3a0 // à
|
||||
#define A_DIAERESIS_LOWER_CASE_UTF_8 0xc3a4 // ä
|
||||
#define A_RING_LOWER_CASE_UTF_8 0xc3a5 // å
|
||||
#define AE_LOWER_CASE_UTF_8 0xc3a6 // æ
|
||||
#define C_CEDILLA_LOWER_CASE_UTF_8 0xc3a7 // ç
|
||||
#define E_GRAVE_LOWER_CASE_UTF_8 0xc3a8 // è
|
||||
#define E_ACUTE_LOWER_CASE_UTF_8 0xc3a9 // é
|
||||
#define I_GRAVE_LOWER_CASE_UTF_8 0xc3ac // ì
|
||||
#define N_TILDE_LOWER_CASE_UTF_8 0xc3b1 // ñ
|
||||
#define O_GRAVE_LOWER_CASE_UTF_8 0xc3b2 // ò
|
||||
#define O_DIAERESIS_LOWER_CASE_UTF_8 0xc3b6 // ö
|
||||
#define O_SLASH_LOWER_CASE_UTF_8 0xc3b8 // ø
|
||||
#define U_GRAVE_LOWER_CASE_UTF_8 0xc3b9 // ù
|
||||
#define U_DIAERESIS_LOWER_CASE_UTF_8 0xc3bc // ü
|
||||
#define CYRILLIC_A_LOWER_CASE_UTF_8 0xd0b0 // а
|
||||
#define CYRILLIC_BE_LOWER_CASE_UTF_8 0xd0b1 // б
|
||||
#define CYRILLIC_VE_LOWER_CASE_UTF_8 0xd0b2 // в
|
||||
#define CYRILLIC_GHE_LOWER_CASE_UTF_8 0xd0b3 // г
|
||||
#define CYRILLIC_DE_LOWER_CASE_UTF_8 0xd0b4 // д
|
||||
#define CYRILLIC_IE_LOWER_CASE_UTF_8 0xd0b5 // е
|
||||
#define CYRILLIC_ZHE_LOWER_CASE_UTF_8 0xd0b6 // ж
|
||||
#define CYRILLIC_ZE_LOWER_CASE_UTF_8 0xd0b7 // з
|
||||
#define CYRILLIC_I_LOWER_CASE_UTF_8 0xd0b8 // и
|
||||
#define CYRILLIC_SHORT_I_LOWER_CASE_UTF_8 0xd0b9 // й
|
||||
#define CYRILLIC_KA_LOWER_CASE_UTF_8 0xd0ba // к
|
||||
#define CYRILLIC_EL_LOWER_CASE_UTF_8 0xd0bb // л
|
||||
#define CYRILLIC_EM_LOWER_CASE_UTF_8 0xd0bc // м
|
||||
#define CYRILLIC_EN_LOWER_CASE_UTF_8 0xd0bd // н
|
||||
#define CYRILLIC_O_LOWER_CASE_UTF_8 0xd0be // о
|
||||
#define CYRILLIC_PE_LOWER_CASE_UTF_8 0xd0bf // п
|
||||
#define CYRILLIC_ER_LOWER_CASE_UTF_8 0xd180 // р
|
||||
#define CYRILLIC_ES_LOWER_CASE_UTF_8 0xd181 // с
|
||||
#define CYRILLIC_TE_LOWER_CASE_UTF_8 0xd182 // т
|
||||
#define CYRILLIC_U_LOWER_CASE_UTF_8 0xd183 // у
|
||||
#define CYRILLIC_EF_LOWER_CASE_UTF_8 0xd184 // ф
|
||||
#define CYRILLIC_HA_LOWER_CASE_UTF_8 0xd185 // х
|
||||
#define CYRILLIC_TSE_LOWER_CASE_UTF_8 0xd186 // ц
|
||||
#define CYRILLIC_CHE_LOWER_CASE_UTF_8 0xd187 // ч
|
||||
#define CYRILLIC_SHA_LOWER_CASE_UTF_8 0xd188 // ш
|
||||
#define CYRILLIC_SHCHA_LOWER_CASE_UTF_8 0xd189 // щ
|
||||
#define CYRILLIC_HARD_SIGN_LOWER_CASE_UTF_8 0xd18a // ъ
|
||||
#define CYRILLIC_YERU_LOWER_CASE_UTF_8 0xd18b // ы
|
||||
#define CYRILLIC_SOFT_SIGN_LOWER_CASE_UTF_8 0xd18c // ь
|
||||
#define CYRILLIC_E_LOWER_CASE_UTF_8 0xd18d // э
|
||||
#define CYRILLIC_YU_LOWER_CASE_UTF_8 0xd18e // ю
|
||||
#define CYRILLIC_YA_LOWER_CASE_UTF_8 0xd18f // я
|
||||
#define CYRILLIC_IO_LOWER_CASE_UTF_8 0xd191 // ё
|
||||
|
||||
// Returns the style mask corresponding to the window settings
|
||||
//
|
||||
static NSUInteger getStyleMask(_GLFWwindow* window)
|
||||
@@ -261,9 +316,13 @@ static inline const char*
|
||||
format_text(const char *src) {
|
||||
static char buf[256];
|
||||
char *p = buf;
|
||||
const char *last_char = buf + sizeof(buf) - 1;
|
||||
if (!src[0]) return "<none>";
|
||||
while (*src) {
|
||||
p += snprintf(p, sizeof(buf) - (p - buf), "0x%x ", (unsigned char)*(src++));
|
||||
int num = snprintf(p, sizeof(buf) - (p - buf), "0x%x ", (unsigned char)*(src++));
|
||||
if (num < 0) return "<error>";
|
||||
if (p + num >= last_char) break;
|
||||
p += num;
|
||||
}
|
||||
if (p != buf) *(--p) = 0;
|
||||
return buf;
|
||||
@@ -284,11 +343,47 @@ static int translateKey(unsigned int key, bool apply_keymap)
|
||||
{
|
||||
if (apply_keymap) {
|
||||
// Look for the effective key name after applying any keyboard layouts/mappings
|
||||
const char *name = _glfwPlatformGetScancodeName(key);
|
||||
if (name && name[1] == 0) {
|
||||
// Single letter key name
|
||||
switch(name[0]) {
|
||||
const char *name_chars = _glfwPlatformGetScancodeName(key);
|
||||
uint32_t name = 0;
|
||||
if (name_chars) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (!name_chars[i]) break;
|
||||
name <<= 8;
|
||||
name |= (uint8_t)name_chars[i];
|
||||
}
|
||||
}
|
||||
if (name) {
|
||||
// Key name
|
||||
switch(name) {
|
||||
#define K(ch, name) case ch: return GLFW_KEY_##name
|
||||
K('!', EXCLAM);
|
||||
K('"', DOUBLE_QUOTE);
|
||||
K('#', NUMBER_SIGN);
|
||||
K('$', DOLLAR);
|
||||
K('&', AMPERSAND);
|
||||
K('\'', APOSTROPHE);
|
||||
K('(', PARENTHESIS_LEFT);
|
||||
K(')', PARENTHESIS_RIGHT);
|
||||
K('+', PLUS);
|
||||
K(',', COMMA);
|
||||
K('-', MINUS);
|
||||
K('.', PERIOD);
|
||||
K('/', SLASH);
|
||||
K('0', 0);
|
||||
K('1', 1);
|
||||
K('2', 2);
|
||||
K('3', 3);
|
||||
K('5', 5);
|
||||
K('6', 6);
|
||||
K('7', 7);
|
||||
K('8', 8);
|
||||
K('9', 9);
|
||||
K(':', COLON);
|
||||
K(';', SEMICOLON);
|
||||
K('<', LESS);
|
||||
K('=', EQUAL);
|
||||
K('>', GREATER);
|
||||
K('@', AT);
|
||||
K('A', A); K('a', A);
|
||||
K('B', B); K('b', B);
|
||||
K('C', C); K('c', C);
|
||||
@@ -315,28 +410,64 @@ static int translateKey(unsigned int key, bool apply_keymap)
|
||||
K('X', X); K('x', X);
|
||||
K('Y', Y); K('y', Y);
|
||||
K('Z', Z); K('z', Z);
|
||||
K('0', 0);
|
||||
K('1', 1);
|
||||
K('2', 2);
|
||||
K('3', 3);
|
||||
K('5', 5);
|
||||
K('6', 6);
|
||||
K('7', 7);
|
||||
K('8', 8);
|
||||
K('9', 9);
|
||||
K('\'', APOSTROPHE);
|
||||
K(',', COMMA);
|
||||
K('.', PERIOD);
|
||||
K('/', SLASH);
|
||||
K('-', MINUS);
|
||||
K('=', EQUAL);
|
||||
K(';', SEMICOLON);
|
||||
K('[', LEFT_BRACKET);
|
||||
K('\\', BACKSLASH);
|
||||
K(']', RIGHT_BRACKET);
|
||||
K('+', PLUS);
|
||||
K('_', UNDERSCORE);
|
||||
K('`', GRAVE_ACCENT);
|
||||
K('\\', BACKSLASH);
|
||||
K(PARAGRAPH_UTF_8, PARAGRAPH);
|
||||
K(MASCULINE_UTF_8, MASCULINE);
|
||||
K(A_DIAERESIS_UPPER_CASE_UTF_8, A_DIAERESIS);
|
||||
K(O_DIAERESIS_UPPER_CASE_UTF_8, O_DIAERESIS);
|
||||
K(U_DIAERESIS_UPPER_CASE_UTF_8, U_DIAERESIS);
|
||||
K(S_SHARP_UTF_8, S_SHARP);
|
||||
K(A_GRAVE_LOWER_CASE_UTF_8, A_GRAVE);
|
||||
K(A_DIAERESIS_LOWER_CASE_UTF_8, A_DIAERESIS);
|
||||
K(A_RING_LOWER_CASE_UTF_8, A_RING);
|
||||
K(AE_LOWER_CASE_UTF_8, AE);
|
||||
K(C_CEDILLA_LOWER_CASE_UTF_8, C_CEDILLA);
|
||||
K(E_GRAVE_LOWER_CASE_UTF_8, E_GRAVE);
|
||||
K(E_ACUTE_LOWER_CASE_UTF_8, E_ACUTE);
|
||||
K(I_GRAVE_LOWER_CASE_UTF_8, I_GRAVE);
|
||||
K(N_TILDE_LOWER_CASE_UTF_8, N_TILDE);
|
||||
K(O_GRAVE_LOWER_CASE_UTF_8, O_GRAVE);
|
||||
K(O_DIAERESIS_LOWER_CASE_UTF_8, O_DIAERESIS);
|
||||
K(O_SLASH_LOWER_CASE_UTF_8, O_SLASH);
|
||||
K(U_GRAVE_LOWER_CASE_UTF_8, U_GRAVE);
|
||||
K(U_DIAERESIS_LOWER_CASE_UTF_8, U_DIAERESIS);
|
||||
K(CYRILLIC_A_LOWER_CASE_UTF_8, CYRILLIC_A);
|
||||
K(CYRILLIC_BE_LOWER_CASE_UTF_8, CYRILLIC_BE);
|
||||
K(CYRILLIC_VE_LOWER_CASE_UTF_8, CYRILLIC_VE);
|
||||
K(CYRILLIC_GHE_LOWER_CASE_UTF_8, CYRILLIC_GHE);
|
||||
K(CYRILLIC_DE_LOWER_CASE_UTF_8, CYRILLIC_DE);
|
||||
K(CYRILLIC_IE_LOWER_CASE_UTF_8, CYRILLIC_IE);
|
||||
K(CYRILLIC_ZHE_LOWER_CASE_UTF_8, CYRILLIC_ZHE);
|
||||
K(CYRILLIC_ZE_LOWER_CASE_UTF_8, CYRILLIC_ZE);
|
||||
K(CYRILLIC_I_LOWER_CASE_UTF_8, CYRILLIC_I);
|
||||
K(CYRILLIC_SHORT_I_LOWER_CASE_UTF_8, CYRILLIC_SHORT_I);
|
||||
K(CYRILLIC_KA_LOWER_CASE_UTF_8, CYRILLIC_KA);
|
||||
K(CYRILLIC_EL_LOWER_CASE_UTF_8, CYRILLIC_EL);
|
||||
K(CYRILLIC_EM_LOWER_CASE_UTF_8, CYRILLIC_EM);
|
||||
K(CYRILLIC_EN_LOWER_CASE_UTF_8, CYRILLIC_EN);
|
||||
K(CYRILLIC_O_LOWER_CASE_UTF_8, CYRILLIC_O);
|
||||
K(CYRILLIC_PE_LOWER_CASE_UTF_8, CYRILLIC_PE);
|
||||
K(CYRILLIC_ER_LOWER_CASE_UTF_8, CYRILLIC_ER);
|
||||
K(CYRILLIC_ES_LOWER_CASE_UTF_8, CYRILLIC_ES);
|
||||
K(CYRILLIC_TE_LOWER_CASE_UTF_8, CYRILLIC_TE);
|
||||
K(CYRILLIC_U_LOWER_CASE_UTF_8, CYRILLIC_U);
|
||||
K(CYRILLIC_EF_LOWER_CASE_UTF_8, CYRILLIC_EF);
|
||||
K(CYRILLIC_HA_LOWER_CASE_UTF_8, CYRILLIC_HA);
|
||||
K(CYRILLIC_TSE_LOWER_CASE_UTF_8, CYRILLIC_TSE);
|
||||
K(CYRILLIC_CHE_LOWER_CASE_UTF_8, CYRILLIC_CHE);
|
||||
K(CYRILLIC_SHA_LOWER_CASE_UTF_8, CYRILLIC_SHA);
|
||||
K(CYRILLIC_SHCHA_LOWER_CASE_UTF_8, CYRILLIC_SHCHA);
|
||||
K(CYRILLIC_HARD_SIGN_LOWER_CASE_UTF_8, CYRILLIC_HARD_SIGN);
|
||||
K(CYRILLIC_YERU_LOWER_CASE_UTF_8, CYRILLIC_YERU);
|
||||
K(CYRILLIC_SOFT_SIGN_LOWER_CASE_UTF_8, CYRILLIC_SOFT_SIGN);
|
||||
K(CYRILLIC_E_LOWER_CASE_UTF_8, CYRILLIC_E);
|
||||
K(CYRILLIC_YU_LOWER_CASE_UTF_8, CYRILLIC_YU);
|
||||
K(CYRILLIC_YA_LOWER_CASE_UTF_8, CYRILLIC_YA);
|
||||
K(CYRILLIC_IO_LOWER_CASE_UTF_8, CYRILLIC_IO);
|
||||
#undef K
|
||||
default:
|
||||
break;
|
||||
@@ -630,7 +761,7 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL;
|
||||
markedRect = NSMakeRect(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
[self updateTrackingAreas];
|
||||
[self registerForDraggedTypes:@[NSPasteboardTypeFileURL]];
|
||||
[self registerForDraggedTypes:@[NSPasteboardTypeFileURL, NSPasteboardTypeString]];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -692,8 +823,8 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL;
|
||||
[window->context.nsgl.object update];
|
||||
} @catch (NSException *e) {
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Failed to update NSGL Context object with error: %s (%s)",
|
||||
[[e name] UTF8String], [[e reason] UTF8String]);
|
||||
"Failed to update NSGL Context object with error: %s (%s)",
|
||||
[[e name] UTF8String], [[e reason] UTF8String]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -948,13 +1079,13 @@ is_ascii_control_char(char x) {
|
||||
&char_count,
|
||||
text
|
||||
) != noErr) {
|
||||
debug_key(@"UCKeyTranslate failed for scancode: 0x%x (%s) %s\n",
|
||||
scancode, safe_name_for_scancode(scancode), format_mods(mods));
|
||||
debug_key(@"UCKeyTranslate failed for scancode: 0x%x (%@) %@\n",
|
||||
scancode, @(safe_name_for_scancode(scancode)), @(format_mods(mods)));
|
||||
window->ns.deadKeyState = 0;
|
||||
return;
|
||||
}
|
||||
debug_key(@"scancode: 0x%x (%s) %schar_count: %lu deadKeyState: %u repeat: %d",
|
||||
scancode, safe_name_for_scancode(scancode), format_mods(mods), char_count, window->ns.deadKeyState, event.ARepeat);
|
||||
debug_key(@"scancode: 0x%x (%@) %@char_count: %lu deadKeyState: %u repeat: %d",
|
||||
scancode, @(safe_name_for_scancode(scancode)), @(format_mods(mods)), char_count, window->ns.deadKeyState, event.ARepeat);
|
||||
if (process_text) {
|
||||
// this will call insertText which will fill up _glfw.ns.text
|
||||
[self interpretKeyEvents:[NSArray arrayWithObject:event]];
|
||||
@@ -963,7 +1094,7 @@ is_ascii_control_char(char x) {
|
||||
}
|
||||
if (window->ns.deadKeyState && (char_count == 0 || scancode == 0x75)) {
|
||||
// 0x75 is the delete key which needs to be ignored during a compose sequence
|
||||
debug_key(@"Sending pre-edit text for dead key (text: %s markedText: %@).\n", format_text(_glfw.ns.text), markedText);
|
||||
debug_key(@"Sending pre-edit text for dead key (text: %@ markedText: %@).\n", @(format_text(_glfw.ns.text)), markedText);
|
||||
_glfwInputKeyboard(window, key, scancode, GLFW_PRESS, mods,
|
||||
[[markedText string] UTF8String], 1); // update pre-edit text
|
||||
return;
|
||||
@@ -975,8 +1106,8 @@ is_ascii_control_char(char x) {
|
||||
}
|
||||
}
|
||||
if (is_ascii_control_char(_glfw.ns.text[0])) _glfw.ns.text[0] = 0; // don't send text for ascii control codes
|
||||
debug_key(@"text: %s glfw_key: %s marked_text: %@\n",
|
||||
format_text(_glfw.ns.text), _glfwGetKeyName(key), markedText);
|
||||
debug_key(@"text: %@ glfw_key: %@ marked_text: %@\n",
|
||||
@(format_text(_glfw.ns.text)), @(_glfwGetKeyName(key)), markedText);
|
||||
if (!window->ns.deadKeyState) {
|
||||
if ([self hasMarkedText]) {
|
||||
_glfwInputKeyboard(window, key, scancode, GLFW_PRESS, mods,
|
||||
@@ -1073,16 +1204,27 @@ is_ascii_control_char(char x) {
|
||||
|
||||
NSPasteboard* pasteboard = [sender draggingPasteboard];
|
||||
NSDictionary* options = @{NSPasteboardURLReadingFileURLsOnlyKey:@YES};
|
||||
NSArray* urls = [pasteboard readObjectsForClasses:@[[NSURL class]]
|
||||
NSArray* objs = [pasteboard readObjectsForClasses:@[[NSURL class], [NSString class]]
|
||||
options:options];
|
||||
if (!urls) return NO;
|
||||
const NSUInteger count = [urls count];
|
||||
if (!objs) return NO;
|
||||
const NSUInteger count = [objs count];
|
||||
if (count)
|
||||
{
|
||||
char** paths = calloc(count, sizeof(char*));
|
||||
|
||||
for (NSUInteger i = 0; i < count; i++)
|
||||
paths[i] = _glfw_strdup([urls[i] fileSystemRepresentation]);
|
||||
{
|
||||
id obj = objs[i];
|
||||
if ([obj isKindOfClass:[NSURL class]]) {
|
||||
paths[i] = _glfw_strdup([obj fileSystemRepresentation]);
|
||||
} else if ([obj isKindOfClass:[NSString class]]) {
|
||||
paths[i] = _glfw_strdup([obj UTF8String]);
|
||||
} else {
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa: Object is neither a URL nor a string");
|
||||
paths[i] = _glfw_strdup("");
|
||||
}
|
||||
}
|
||||
|
||||
_glfwInputDrop(window, (int) count, (const char**) paths);
|
||||
|
||||
@@ -1623,7 +1765,14 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||
acquireMonitor(window);
|
||||
}
|
||||
else
|
||||
[window->ns.object setContentSize:NSMakeSize(width, height)];
|
||||
{
|
||||
NSRect contentRect =
|
||||
[window->ns.object contentRectForFrameRect:[window->ns.object frame]];
|
||||
contentRect.origin.y += contentRect.size.height - height;
|
||||
contentRect.size = NSMakeSize(width, height);
|
||||
[window->ns.object setFrame:[window->ns.object frameRectForContentRect:contentRect]
|
||||
display:YES];
|
||||
}
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
||||
@@ -2268,6 +2417,39 @@ GLFWAPI void glfwGetCocoaKeyEquivalent(int glfw_key, int glfw_mods, unsigned sho
|
||||
START_ALLOW_CASE_RANGE
|
||||
switch(glfw_key) {
|
||||
#define K(ch, name) case GLFW_KEY_##name: *cocoa_key = ch; break;
|
||||
K('!', EXCLAM);
|
||||
K('"', DOUBLE_QUOTE);
|
||||
K('#', NUMBER_SIGN);
|
||||
K('$', DOLLAR);
|
||||
K('&', AMPERSAND);
|
||||
K('\'', APOSTROPHE);
|
||||
K('(', PARENTHESIS_LEFT);
|
||||
K(')', PARENTHESIS_RIGHT);
|
||||
K('+', PLUS);
|
||||
K(',', COMMA);
|
||||
K('-', MINUS);
|
||||
K('.', PERIOD);
|
||||
K('/', SLASH);
|
||||
K('0', 0);
|
||||
K('1', 1);
|
||||
K('2', 2);
|
||||
K('3', 3);
|
||||
K('5', 5);
|
||||
K('6', 6);
|
||||
K('7', 7);
|
||||
K('8', 8);
|
||||
K('9', 9);
|
||||
K(':', COLON);
|
||||
K(';', SEMICOLON);
|
||||
K('<', LESS);
|
||||
K('=', EQUAL);
|
||||
K('>', GREATER);
|
||||
K('@', AT);
|
||||
K('[', LEFT_BRACKET);
|
||||
K('\\', BACKSLASH);
|
||||
K(']', RIGHT_BRACKET);
|
||||
K('_', UNDERSCORE);
|
||||
K('`', GRAVE_ACCENT);
|
||||
K('a', A);
|
||||
K('b', B);
|
||||
K('c', C);
|
||||
@@ -2294,28 +2476,56 @@ START_ALLOW_CASE_RANGE
|
||||
K('x', X);
|
||||
K('y', Y);
|
||||
K('z', Z);
|
||||
K('0', 0);
|
||||
K('1', 1);
|
||||
K('2', 2);
|
||||
K('3', 3);
|
||||
K('5', 5);
|
||||
K('6', 6);
|
||||
K('7', 7);
|
||||
K('8', 8);
|
||||
K('9', 9);
|
||||
K('\'', APOSTROPHE);
|
||||
K(',', COMMA);
|
||||
K('.', PERIOD);
|
||||
K('/', SLASH);
|
||||
K('-', MINUS);
|
||||
K('=', EQUAL);
|
||||
K(';', SEMICOLON);
|
||||
K('[', LEFT_BRACKET);
|
||||
K(']', RIGHT_BRACKET);
|
||||
K('+', PLUS);
|
||||
K('_', UNDERSCORE);
|
||||
K('`', GRAVE_ACCENT);
|
||||
K('\\', BACKSLASH);
|
||||
K(PARAGRAPH_UTF_8, PARAGRAPH);
|
||||
K(MASCULINE_UTF_8, MASCULINE);
|
||||
K(S_SHARP_UTF_8, S_SHARP);
|
||||
K(A_GRAVE_LOWER_CASE_UTF_8, A_GRAVE);
|
||||
K(A_DIAERESIS_LOWER_CASE_UTF_8, A_DIAERESIS);
|
||||
K(A_RING_LOWER_CASE_UTF_8, A_RING);
|
||||
K(AE_LOWER_CASE_UTF_8, AE);
|
||||
K(C_CEDILLA_LOWER_CASE_UTF_8, C_CEDILLA);
|
||||
K(E_GRAVE_LOWER_CASE_UTF_8, E_GRAVE);
|
||||
K(E_ACUTE_LOWER_CASE_UTF_8, E_ACUTE);
|
||||
K(I_GRAVE_LOWER_CASE_UTF_8, I_GRAVE);
|
||||
K(N_TILDE_LOWER_CASE_UTF_8, N_TILDE);
|
||||
K(O_GRAVE_LOWER_CASE_UTF_8, O_GRAVE);
|
||||
K(O_DIAERESIS_LOWER_CASE_UTF_8, O_DIAERESIS);
|
||||
K(O_SLASH_LOWER_CASE_UTF_8, O_SLASH);
|
||||
K(U_GRAVE_LOWER_CASE_UTF_8, U_GRAVE);
|
||||
K(U_DIAERESIS_LOWER_CASE_UTF_8, U_DIAERESIS);
|
||||
K(CYRILLIC_A_LOWER_CASE_UTF_8, CYRILLIC_A);
|
||||
K(CYRILLIC_BE_LOWER_CASE_UTF_8, CYRILLIC_BE);
|
||||
K(CYRILLIC_VE_LOWER_CASE_UTF_8, CYRILLIC_VE);
|
||||
K(CYRILLIC_GHE_LOWER_CASE_UTF_8, CYRILLIC_GHE);
|
||||
K(CYRILLIC_DE_LOWER_CASE_UTF_8, CYRILLIC_DE);
|
||||
K(CYRILLIC_IE_LOWER_CASE_UTF_8, CYRILLIC_IE);
|
||||
K(CYRILLIC_ZHE_LOWER_CASE_UTF_8, CYRILLIC_ZHE);
|
||||
K(CYRILLIC_ZE_LOWER_CASE_UTF_8, CYRILLIC_ZE);
|
||||
K(CYRILLIC_I_LOWER_CASE_UTF_8, CYRILLIC_I);
|
||||
K(CYRILLIC_SHORT_I_LOWER_CASE_UTF_8, CYRILLIC_SHORT_I);
|
||||
K(CYRILLIC_KA_LOWER_CASE_UTF_8, CYRILLIC_KA);
|
||||
K(CYRILLIC_EL_LOWER_CASE_UTF_8, CYRILLIC_EL);
|
||||
K(CYRILLIC_EM_LOWER_CASE_UTF_8, CYRILLIC_EM);
|
||||
K(CYRILLIC_EN_LOWER_CASE_UTF_8, CYRILLIC_EN);
|
||||
K(CYRILLIC_O_LOWER_CASE_UTF_8, CYRILLIC_O);
|
||||
K(CYRILLIC_PE_LOWER_CASE_UTF_8, CYRILLIC_PE);
|
||||
K(CYRILLIC_ER_LOWER_CASE_UTF_8, CYRILLIC_ER);
|
||||
K(CYRILLIC_ES_LOWER_CASE_UTF_8, CYRILLIC_ES);
|
||||
K(CYRILLIC_TE_LOWER_CASE_UTF_8, CYRILLIC_TE);
|
||||
K(CYRILLIC_U_LOWER_CASE_UTF_8, CYRILLIC_U);
|
||||
K(CYRILLIC_EF_LOWER_CASE_UTF_8, CYRILLIC_EF);
|
||||
K(CYRILLIC_HA_LOWER_CASE_UTF_8, CYRILLIC_HA);
|
||||
K(CYRILLIC_TSE_LOWER_CASE_UTF_8, CYRILLIC_TSE);
|
||||
K(CYRILLIC_CHE_LOWER_CASE_UTF_8, CYRILLIC_CHE);
|
||||
K(CYRILLIC_SHA_LOWER_CASE_UTF_8, CYRILLIC_SHA);
|
||||
K(CYRILLIC_SHCHA_LOWER_CASE_UTF_8, CYRILLIC_SHCHA);
|
||||
K(CYRILLIC_HARD_SIGN_LOWER_CASE_UTF_8, CYRILLIC_HARD_SIGN);
|
||||
K(CYRILLIC_YERU_LOWER_CASE_UTF_8, CYRILLIC_YERU);
|
||||
K(CYRILLIC_SOFT_SIGN_LOWER_CASE_UTF_8, CYRILLIC_SOFT_SIGN);
|
||||
K(CYRILLIC_E_LOWER_CASE_UTF_8, CYRILLIC_E);
|
||||
K(CYRILLIC_YU_LOWER_CASE_UTF_8, CYRILLIC_YU);
|
||||
K(CYRILLIC_YA_LOWER_CASE_UTF_8, CYRILLIC_YA);
|
||||
K(CYRILLIC_IO_LOWER_CASE_UTF_8, CYRILLIC_IO);
|
||||
|
||||
K(0x35, ESCAPE);
|
||||
K('\r', ENTER);
|
||||
|
||||
2
glfw/context.c
vendored
2
glfw/context.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 - www.glfw.org
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
2
glfw/dbus_glfw.c
vendored
2
glfw/dbus_glfw.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 XKB - www.glfw.org
|
||||
// GLFW 3.4 XKB - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2018 Kovid Goyal <kovid@kovidgoyal.net>
|
||||
//
|
||||
|
||||
2
glfw/dbus_glfw.h
vendored
2
glfw/dbus_glfw.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 XKB - www.glfw.org
|
||||
// GLFW 3.4 XKB - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2018 Kovid Goyal <kovid@kovidgoyal.net>
|
||||
//
|
||||
|
||||
2
glfw/egl_context.c
vendored
2
glfw/egl_context.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 EGL - www.glfw.org
|
||||
// GLFW 3.4 EGL - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
2
glfw/egl_context.h
vendored
2
glfw/egl_context.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 EGL - www.glfw.org
|
||||
// GLFW 3.4 EGL - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
29
glfw/glfw.py
29
glfw/glfw.py
@@ -8,11 +8,7 @@ import re
|
||||
import sys
|
||||
|
||||
_plat = sys.platform.lower()
|
||||
is_macos = 'darwin' in _plat
|
||||
is_freebsd = 'freebsd' in _plat
|
||||
is_netbsd = 'netbsd' in _plat
|
||||
is_dragonflybsd = 'dragonfly' in _plat
|
||||
is_bsd = is_freebsd or is_netbsd or is_dragonflybsd
|
||||
is_linux = 'linux' in _plat
|
||||
base = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
@@ -23,31 +19,24 @@ def wayland_protocol_file_name(base, ext='c'):
|
||||
|
||||
def init_env(env, pkg_config, at_least_version, test_compile, module='x11'):
|
||||
ans = env.copy()
|
||||
if not is_macos:
|
||||
ans.cflags.append('-pthread')
|
||||
ans.ldpaths.append('-pthread')
|
||||
ans.cflags.append('-fpic')
|
||||
ans.cppflags.append('-D_GLFW_' + module.upper())
|
||||
ans.cppflags.append('-D_GLFW_BUILD_DLL')
|
||||
|
||||
if is_macos:
|
||||
ans.cppflags.append('-DGL_SILENCE_DEPRECATION')
|
||||
ans.ldpaths.extend(
|
||||
"-framework Cocoa -framework IOKit -framework CoreFoundation -framework CoreVideo".
|
||||
split()
|
||||
)
|
||||
else:
|
||||
ans.ldpaths.extend('-lrt -lm -ldl'.split())
|
||||
sinfo = json.load(open(os.path.join(base, 'source-info.json')))
|
||||
with open(os.path.join(base, 'source-info.json')) as f:
|
||||
sinfo = json.load(f)
|
||||
module_sources = list(sinfo[module]['sources'])
|
||||
if module in ('x11', 'wayland'):
|
||||
remove = 'linux_joystick.c' if is_bsd else 'null_joystick.c'
|
||||
remove = 'null_joystick.c' if is_linux else 'linux_joystick.c'
|
||||
module_sources.remove(remove)
|
||||
|
||||
ans.sources = sinfo['common']['sources'] + module_sources
|
||||
ans.all_headers = [x for x in os.listdir(base) if x.endswith('.h')]
|
||||
|
||||
if module in ('x11', 'wayland'):
|
||||
ans.cflags.append('-pthread')
|
||||
ans.ldpaths.append('-pthread')
|
||||
ans.ldpaths.extend('-lrt -lm -ldl'.split())
|
||||
at_least_version('xkbcommon', 0, 5)
|
||||
|
||||
if module == 'x11':
|
||||
@@ -56,6 +45,7 @@ def init_env(env, pkg_config, at_least_version, test_compile, module='x11'):
|
||||
ans.ldpaths.extend(pkg_config(dep, '--libs'))
|
||||
|
||||
elif module == 'cocoa':
|
||||
ans.cppflags.append('-DGL_SILENCE_DEPRECATION')
|
||||
for f in 'Cocoa IOKit CoreFoundation CoreVideo'.split():
|
||||
ans.ldpaths.extend(('-framework', f))
|
||||
|
||||
@@ -157,7 +147,8 @@ class Function:
|
||||
|
||||
|
||||
def generate_wrappers(glfw_header):
|
||||
src = open(glfw_header).read()
|
||||
with open(glfw_header) as f:
|
||||
src = f.read()
|
||||
functions = []
|
||||
first = None
|
||||
for m in re.finditer(r'^GLFWAPI\s+(.+[)]);\s*$', src, flags=re.MULTILINE):
|
||||
|
||||
158
glfw/glfw3.h
vendored
158
glfw/glfw3.h
vendored
@@ -1,5 +1,5 @@
|
||||
/*************************************************************************
|
||||
* GLFW 3.3 - www.glfw.org
|
||||
* GLFW 3.4 - www.glfw.org
|
||||
* A library for OpenGL, window and input
|
||||
*------------------------------------------------------------------------
|
||||
* Copyright (c) 2002-2006 Marcus Geelnard
|
||||
@@ -261,7 +261,7 @@ extern "C" {
|
||||
* backward-compatible.
|
||||
* @ingroup init
|
||||
*/
|
||||
#define GLFW_VERSION_MINOR 3
|
||||
#define GLFW_VERSION_MINOR 4
|
||||
/*! @brief The revision number of the GLFW library.
|
||||
*
|
||||
* This is incremented when a bug fix release is made that does not contain any
|
||||
@@ -324,7 +324,7 @@ extern "C" {
|
||||
*
|
||||
* The naming of the key codes follow these rules:
|
||||
* - The US keyboard layout is used
|
||||
* - Names of printable alpha-numeric characters are used (e.g. "A", "R",
|
||||
* - Names of printable alphanumeric characters are used (e.g. "A", "R",
|
||||
* "3", etc.)
|
||||
* - For non-alphanumeric characters, Unicode:ish names are used (e.g.
|
||||
* "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
|
||||
@@ -342,7 +342,15 @@ extern "C" {
|
||||
|
||||
/* Printable keys */
|
||||
#define GLFW_KEY_SPACE 32
|
||||
#define GLFW_KEY_EXCLAM 33 /* ! */
|
||||
#define GLFW_KEY_DOUBLE_QUOTE 34 /* " */
|
||||
#define GLFW_KEY_NUMBER_SIGN 35 /* # */
|
||||
#define GLFW_KEY_DOLLAR 36 /* $ */
|
||||
#define GLFW_KEY_AMPERSAND 38 /* & */
|
||||
#define GLFW_KEY_APOSTROPHE 39 /* ' */
|
||||
#define GLFW_KEY_PARENTHESIS_LEFT 40 /* ( */
|
||||
#define GLFW_KEY_PARENTHESIS_RIGHT 41 /* ) */
|
||||
#define GLFW_KEY_PLUS 43 /* + */
|
||||
#define GLFW_KEY_COMMA 44 /* , */
|
||||
#define GLFW_KEY_MINUS 45 /* - */
|
||||
#define GLFW_KEY_PERIOD 46 /* . */
|
||||
@@ -357,8 +365,12 @@ extern "C" {
|
||||
#define GLFW_KEY_7 55
|
||||
#define GLFW_KEY_8 56
|
||||
#define GLFW_KEY_9 57
|
||||
#define GLFW_KEY_COLON 58 /* : */
|
||||
#define GLFW_KEY_SEMICOLON 59 /* ; */
|
||||
#define GLFW_KEY_LESS 60 /* < */
|
||||
#define GLFW_KEY_EQUAL 61 /* = */
|
||||
#define GLFW_KEY_GREATER 62 /* > */
|
||||
#define GLFW_KEY_AT 64 /* @ */
|
||||
#define GLFW_KEY_A 65
|
||||
#define GLFW_KEY_B 66
|
||||
#define GLFW_KEY_C 67
|
||||
@@ -388,11 +400,62 @@ extern "C" {
|
||||
#define GLFW_KEY_LEFT_BRACKET 91 /* [ */
|
||||
#define GLFW_KEY_BACKSLASH 92 /* \ */
|
||||
#define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
|
||||
#define GLFW_KEY_UNDERSCORE 95 /* _ */
|
||||
#define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
|
||||
#define GLFW_KEY_WORLD_1 161 /* non-US #1 */
|
||||
#define GLFW_KEY_WORLD_2 162 /* non-US #2 */
|
||||
#define GLFW_KEY_PLUS 163
|
||||
#define GLFW_KEY_UNDERSCORE 164
|
||||
#define GLFW_KEY_PARAGRAPH 167 /* § */
|
||||
#define GLFW_KEY_MASCULINE 186 /* º */
|
||||
#define GLFW_KEY_A_GRAVE 192 /* À */
|
||||
#define GLFW_KEY_A_DIAERESIS 196 /* Ä */
|
||||
#define GLFW_KEY_A_RING 197 /* Å */
|
||||
#define GLFW_KEY_AE 198 /* Æ */
|
||||
#define GLFW_KEY_C_CEDILLA 199 /* Ç */
|
||||
#define GLFW_KEY_E_GRAVE 200 /* È */
|
||||
#define GLFW_KEY_E_ACUTE 201 /* É */
|
||||
#define GLFW_KEY_I_GRAVE 204 /* Ì */
|
||||
#define GLFW_KEY_N_TILDE 209 /* Ñ */
|
||||
#define GLFW_KEY_O_GRAVE 210 /* Ò */
|
||||
#define GLFW_KEY_O_DIAERESIS 214 /* Ö */
|
||||
#define GLFW_KEY_O_SLASH 216 /* Ø */
|
||||
#define GLFW_KEY_U_GRAVE 217 /* Ù */
|
||||
#define GLFW_KEY_U_DIAERESIS 220 /* Ü */
|
||||
#define GLFW_KEY_S_SHARP 222 /* ß */
|
||||
#define GLFW_KEY_CYRILLIC_A 223 /* А */
|
||||
#define GLFW_KEY_CYRILLIC_BE 224 /* Б */
|
||||
#define GLFW_KEY_CYRILLIC_VE 225 /* В */
|
||||
#define GLFW_KEY_CYRILLIC_GHE 226 /* Г */
|
||||
#define GLFW_KEY_CYRILLIC_DE 227 /* Д */
|
||||
#define GLFW_KEY_CYRILLIC_IE 228 /* Е */
|
||||
#define GLFW_KEY_CYRILLIC_ZHE 229 /* Ж */
|
||||
#define GLFW_KEY_CYRILLIC_ZE 230 /* З */
|
||||
#define GLFW_KEY_CYRILLIC_I 231 /* И */
|
||||
#define GLFW_KEY_CYRILLIC_SHORT_I 232 /* Й */
|
||||
#define GLFW_KEY_CYRILLIC_KA 233 /* К */
|
||||
#define GLFW_KEY_CYRILLIC_EL 234 /* Л */
|
||||
#define GLFW_KEY_CYRILLIC_EM 235 /* М */
|
||||
#define GLFW_KEY_CYRILLIC_EN 236 /* Н */
|
||||
#define GLFW_KEY_CYRILLIC_O 237 /* О */
|
||||
#define GLFW_KEY_CYRILLIC_PE 238 /* П */
|
||||
#define GLFW_KEY_CYRILLIC_ER 239 /* Р */
|
||||
#define GLFW_KEY_CYRILLIC_ES 240 /* С */
|
||||
#define GLFW_KEY_CYRILLIC_TE 241 /* Т */
|
||||
#define GLFW_KEY_CYRILLIC_U 242 /* У */
|
||||
#define GLFW_KEY_CYRILLIC_EF 243 /* Ф */
|
||||
#define GLFW_KEY_CYRILLIC_HA 244 /* Х */
|
||||
#define GLFW_KEY_CYRILLIC_TSE 245 /* Ц */
|
||||
#define GLFW_KEY_CYRILLIC_CHE 246 /* Ч */
|
||||
#define GLFW_KEY_CYRILLIC_SHA 247 /* Ш */
|
||||
#define GLFW_KEY_CYRILLIC_SHCHA 248 /* Щ */
|
||||
#define GLFW_KEY_CYRILLIC_HARD_SIGN 249 /* Ъ */
|
||||
#define GLFW_KEY_CYRILLIC_YERU 250 /* Ы */
|
||||
#define GLFW_KEY_CYRILLIC_SOFT_SIGN 251 /* Ь */
|
||||
#define GLFW_KEY_CYRILLIC_E 252 /* Э */
|
||||
#define GLFW_KEY_CYRILLIC_YU 253 /* Ю */
|
||||
#define GLFW_KEY_CYRILLIC_YA 254 /* Я */
|
||||
#define GLFW_KEY_CYRILLIC_IO 255 /* Ё */
|
||||
|
||||
#define GLFW_KEY_LAST_PRINTABLE GLFW_KEY_CYRILLIC_IO
|
||||
|
||||
/* Function keys */
|
||||
#define GLFW_KEY_ESCAPE 256
|
||||
@@ -1405,7 +1468,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow*,double,double,int);
|
||||
* @param[in] mods Bit field describing which [modifier keys](@ref mods) were
|
||||
* held down.
|
||||
* @param[in] text UTF-8 encoded text generated by this key event or empty string.
|
||||
* @param[in] Used for Input Method events. Zero for normal key events.
|
||||
* @param[in] status Used for Input Method events. Zero for normal key events.
|
||||
* A value of 1 means the pre-edit text for the input event has been changed.
|
||||
* A value of 2 means the text should be committed.
|
||||
*
|
||||
@@ -2175,7 +2238,7 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark @wayland Gamma handling is a priviledged protocol, this function
|
||||
* @remark @wayland Gamma handling is a privileged protocol, this function
|
||||
* will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
@@ -2199,7 +2262,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark @wayland Gamma handling is a priviledged protocol, this function
|
||||
* @remark @wayland Gamma handling is a privileged protocol, this function
|
||||
* will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR while
|
||||
* returning `NULL`.
|
||||
*
|
||||
@@ -2243,7 +2306,7 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
|
||||
*
|
||||
* @remark @win32 The gamma ramp size must be 256.
|
||||
*
|
||||
* @remark @wayland Gamma handling is a priviledged protocol, this function
|
||||
* @remark @wayland Gamma handling is a privileged protocol, this function
|
||||
* will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @pointer_lifetime The specified gamma ramp is copied before this function
|
||||
@@ -2462,7 +2525,7 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value);
|
||||
*
|
||||
* @remark @macos When activating frame autosaving with
|
||||
* [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified
|
||||
* window size and position may be overriden by previously saved values.
|
||||
* window size and position may be overridden by previously saved values.
|
||||
*
|
||||
* @remark @x11 Some window managers will not respect the placement of
|
||||
* initially hidden windows.
|
||||
@@ -3844,20 +3907,85 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
|
||||
* [key callback](@ref input_key) without modification.
|
||||
*
|
||||
* The printable keys are:
|
||||
* - `GLFW_KEY_SPACE`
|
||||
* - `GLFW_KEY_EXCLAM`
|
||||
* - `GLFW_KEY_DOUBLE_QUOTE`
|
||||
* - `GLFW_KEY_NUMBER_SIGN`
|
||||
* - `GLFW_KEY_DOLLAR`
|
||||
* - `GLFW_KEY_AMPERSAND`
|
||||
* - `GLFW_KEY_APOSTROPHE`
|
||||
* - `GLFW_KEY_PARENTHESIS_LEFT`
|
||||
* - `GLFW_KEY_PARENTHESIS_RIGHT`
|
||||
* - `GLFW_KEY_PLUS`
|
||||
* - `GLFW_KEY_COMMA`
|
||||
* - `GLFW_KEY_MINUS`
|
||||
* - `GLFW_KEY_PERIOD`
|
||||
* - `GLFW_KEY_SLASH`
|
||||
* - `GLFW_KEY_0` to `GLFW_KEY_9`
|
||||
* - `GLFW_KEY_COLON`
|
||||
* - `GLFW_KEY_SEMICOLON`
|
||||
* - `GLFW_KEY_LESS`
|
||||
* - `GLFW_KEY_EQUAL`
|
||||
* - `GLFW_KEY_GREATER`
|
||||
* - `GLFW_KEY_AT`
|
||||
* - `GLFW_KEY_A` to `GLFW_KEY_Z`
|
||||
* - `GLFW_KEY_LEFT_BRACKET`
|
||||
* - `GLFW_KEY_RIGHT_BRACKET`
|
||||
* - `GLFW_KEY_BACKSLASH`
|
||||
* - `GLFW_KEY_RIGHT_BRACKET`
|
||||
* - `GLFW_KEY_UNDERSCORE`
|
||||
* - `GLFW_KEY_GRAVE_ACCENT`
|
||||
* - `GLFW_KEY_WORLD_1`
|
||||
* - `GLFW_KEY_WORLD_2`
|
||||
* - `GLFW_KEY_0` to `GLFW_KEY_9`
|
||||
* - `GLFW_KEY_A` to `GLFW_KEY_Z`
|
||||
* - `GLFW_KEY_PARAGRAPH`
|
||||
* - `GLFW_KEY_MASCULINE`
|
||||
* - `GLFW_KEY_A_GRAVE`
|
||||
* - `GLFW_KEY_A_DIAERESIS`
|
||||
* - `GLFW_KEY_A_RING`
|
||||
* - `GLFW_KEY_AE`
|
||||
* - `GLFW_KEY_C_CEDILLA`
|
||||
* - `GLFW_KEY_E_GRAVE`
|
||||
* - `GLFW_KEY_E_ACUTE`
|
||||
* - `GLFW_KEY_I_GRAVE`
|
||||
* - `GLFW_KEY_N_TILDE`
|
||||
* - `GLFW_KEY_O_GRAVE`
|
||||
* - `GLFW_KEY_O_DIAERESIS`
|
||||
* - `GLFW_KEY_O_SLASH`
|
||||
* - `GLFW_KEY_U_GRAVE`
|
||||
* - `GLFW_KEY_U_DIAERESIS`
|
||||
* - `GLFW_KEY_S_SHARP`
|
||||
* - `GLFW_KEY_CYRILLIC_A`
|
||||
* - `GLFW_KEY_CYRILLIC_BE`
|
||||
* - `GLFW_KEY_CYRILLIC_VE`
|
||||
* - `GLFW_KEY_CYRILLIC_GHE`
|
||||
* - `GLFW_KEY_CYRILLIC_DE`
|
||||
* - `GLFW_KEY_CYRILLIC_IE`
|
||||
* - `GLFW_KEY_CYRILLIC_ZHE`
|
||||
* - `GLFW_KEY_CYRILLIC_ZE`
|
||||
* - `GLFW_KEY_CYRILLIC_I`
|
||||
* - `GLFW_KEY_CYRILLIC_SHORT_I`
|
||||
* - `GLFW_KEY_CYRILLIC_KA`
|
||||
* - `GLFW_KEY_CYRILLIC_EL`
|
||||
* - `GLFW_KEY_CYRILLIC_EM`
|
||||
* - `GLFW_KEY_CYRILLIC_EN`
|
||||
* - `GLFW_KEY_CYRILLIC_O`
|
||||
* - `GLFW_KEY_CYRILLIC_PE`
|
||||
* - `GLFW_KEY_CYRILLIC_ER`
|
||||
* - `GLFW_KEY_CYRILLIC_ES`
|
||||
* - `GLFW_KEY_CYRILLIC_TE`
|
||||
* - `GLFW_KEY_CYRILLIC_U`
|
||||
* - `GLFW_KEY_CYRILLIC_EF`
|
||||
* - `GLFW_KEY_CYRILLIC_HA`
|
||||
* - `GLFW_KEY_CYRILLIC_TSE`
|
||||
* - `GLFW_KEY_CYRILLIC_CHE`
|
||||
* - `GLFW_KEY_CYRILLIC_SHA`
|
||||
* - `GLFW_KEY_CYRILLIC_SHCHA`
|
||||
* - `GLFW_KEY_CYRILLIC_HARD_SIGN`
|
||||
* - `GLFW_KEY_CYRILLIC_YERU`
|
||||
* - `GLFW_KEY_CYRILLIC_SOFT_SIGN`
|
||||
* - `GLFW_KEY_CYRILLIC_E`
|
||||
* - `GLFW_KEY_CYRILLIC_YU`
|
||||
* - `GLFW_KEY_CYRILLIC_YA`
|
||||
* - `GLFW_KEY_CYRILLIC_IO`
|
||||
* - `GLFW_KEY_KP_0` to `GLFW_KEY_KP_9`
|
||||
* - `GLFW_KEY_KP_DECIMAL`
|
||||
* - `GLFW_KEY_KP_DIVIDE`
|
||||
@@ -4524,7 +4652,7 @@ GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count);
|
||||
*/
|
||||
GLFWAPI const char* glfwGetJoystickName(int jid);
|
||||
|
||||
/*! @brief Returns the SDL comaptible GUID of the specified joystick.
|
||||
/*! @brief Returns the SDL compatible GUID of the specified joystick.
|
||||
*
|
||||
* This function returns the SDL compatible GUID, as a UTF-8 encoded
|
||||
* hexadecimal string, of the specified joystick. The returned string is
|
||||
@@ -4738,7 +4866,7 @@ GLFWAPI const char* glfwGetGamepadName(int jid);
|
||||
|
||||
/*! @brief Retrieves the state of the specified joystick remapped as a gamepad.
|
||||
*
|
||||
* This function retrives the state of the specified joystick remapped to
|
||||
* This function retrieves the state of the specified joystick remapped to
|
||||
* an Xbox-like gamepad.
|
||||
*
|
||||
* If the specified joystick is not present or does not have a gamepad mapping
|
||||
|
||||
2
glfw/glx_context.c
vendored
2
glfw/glx_context.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 GLX - www.glfw.org
|
||||
// GLFW 3.4 GLX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
26
glfw/glx_context.h
vendored
26
glfw/glx_context.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 GLX - www.glfw.org
|
||||
// GLFW 3.4 GLX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
@@ -153,18 +153,18 @@ typedef struct _GLFWlibraryGLX
|
||||
PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT;
|
||||
PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA;
|
||||
PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
|
||||
bool SGI_swap_control;
|
||||
bool EXT_swap_control;
|
||||
bool MESA_swap_control;
|
||||
bool ARB_multisample;
|
||||
bool ARB_framebuffer_sRGB;
|
||||
bool EXT_framebuffer_sRGB;
|
||||
bool ARB_create_context;
|
||||
bool ARB_create_context_profile;
|
||||
bool ARB_create_context_robustness;
|
||||
bool EXT_create_context_es2_profile;
|
||||
bool ARB_create_context_no_error;
|
||||
bool ARB_context_flush_control;
|
||||
bool SGI_swap_control;
|
||||
bool EXT_swap_control;
|
||||
bool MESA_swap_control;
|
||||
bool ARB_multisample;
|
||||
bool ARB_framebuffer_sRGB;
|
||||
bool EXT_framebuffer_sRGB;
|
||||
bool ARB_create_context;
|
||||
bool ARB_create_context_profile;
|
||||
bool ARB_create_context_robustness;
|
||||
bool EXT_create_context_es2_profile;
|
||||
bool ARB_create_context_no_error;
|
||||
bool ARB_context_flush_control;
|
||||
|
||||
} _GLFWlibraryGLX;
|
||||
|
||||
|
||||
2
glfw/ibus_glfw.c
vendored
2
glfw/ibus_glfw.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 XKB - www.glfw.org
|
||||
// GLFW 3.4 XKB - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2018 Kovid Goyal <kovid@kovidgoyal.net>
|
||||
//
|
||||
|
||||
2
glfw/ibus_glfw.h
vendored
2
glfw/ibus_glfw.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 XKB - www.glfw.org
|
||||
// GLFW 3.4 XKB - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2018 Kovid Goyal <kovid@kovidgoyal.net>
|
||||
//
|
||||
|
||||
2
glfw/init.c
vendored
2
glfw/init.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 - www.glfw.org
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
311
glfw/input.c
vendored
311
glfw/input.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 - www.glfw.org
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
@@ -439,132 +439,193 @@ const char* _glfwGetKeyName(int key)
|
||||
switch (key)
|
||||
{
|
||||
// Printable keys
|
||||
case GLFW_KEY_A: return "A";
|
||||
case GLFW_KEY_B: return "B";
|
||||
case GLFW_KEY_C: return "C";
|
||||
case GLFW_KEY_D: return "D";
|
||||
case GLFW_KEY_E: return "E";
|
||||
case GLFW_KEY_F: return "F";
|
||||
case GLFW_KEY_G: return "G";
|
||||
case GLFW_KEY_H: return "H";
|
||||
case GLFW_KEY_I: return "I";
|
||||
case GLFW_KEY_J: return "J";
|
||||
case GLFW_KEY_K: return "K";
|
||||
case GLFW_KEY_L: return "L";
|
||||
case GLFW_KEY_M: return "M";
|
||||
case GLFW_KEY_N: return "N";
|
||||
case GLFW_KEY_O: return "O";
|
||||
case GLFW_KEY_P: return "P";
|
||||
case GLFW_KEY_Q: return "Q";
|
||||
case GLFW_KEY_R: return "R";
|
||||
case GLFW_KEY_S: return "S";
|
||||
case GLFW_KEY_T: return "T";
|
||||
case GLFW_KEY_U: return "U";
|
||||
case GLFW_KEY_V: return "V";
|
||||
case GLFW_KEY_W: return "W";
|
||||
case GLFW_KEY_X: return "X";
|
||||
case GLFW_KEY_Y: return "Y";
|
||||
case GLFW_KEY_Z: return "Z";
|
||||
case GLFW_KEY_1: return "1";
|
||||
case GLFW_KEY_2: return "2";
|
||||
case GLFW_KEY_3: return "3";
|
||||
case GLFW_KEY_4: return "4";
|
||||
case GLFW_KEY_5: return "5";
|
||||
case GLFW_KEY_6: return "6";
|
||||
case GLFW_KEY_7: return "7";
|
||||
case GLFW_KEY_8: return "8";
|
||||
case GLFW_KEY_9: return "9";
|
||||
case GLFW_KEY_0: return "0";
|
||||
case GLFW_KEY_SPACE: return "SPACE";
|
||||
case GLFW_KEY_MINUS: return "MINUS";
|
||||
case GLFW_KEY_EQUAL: return "EQUAL";
|
||||
case GLFW_KEY_LEFT_BRACKET: return "LEFT BRACKET";
|
||||
case GLFW_KEY_RIGHT_BRACKET: return "RIGHT BRACKET";
|
||||
case GLFW_KEY_BACKSLASH: return "BACKSLASH";
|
||||
case GLFW_KEY_SEMICOLON: return "SEMICOLON";
|
||||
case GLFW_KEY_APOSTROPHE: return "APOSTROPHE";
|
||||
case GLFW_KEY_GRAVE_ACCENT: return "GRAVE ACCENT";
|
||||
case GLFW_KEY_COMMA: return "COMMA";
|
||||
case GLFW_KEY_PERIOD: return "PERIOD";
|
||||
case GLFW_KEY_SLASH: return "SLASH";
|
||||
case GLFW_KEY_WORLD_1: return "WORLD 1";
|
||||
case GLFW_KEY_WORLD_2: return "WORLD 2";
|
||||
case GLFW_KEY_PLUS: return "PLUS";
|
||||
case GLFW_KEY_UNDERSCORE: return "UNDERSCORE";
|
||||
case GLFW_KEY_SPACE: return "SPACE";
|
||||
case GLFW_KEY_EXCLAM: return "EXCLAM";
|
||||
case GLFW_KEY_DOUBLE_QUOTE: return "DOUBLE_QUOTE";
|
||||
case GLFW_KEY_NUMBER_SIGN: return "NUMBER_SIGN";
|
||||
case GLFW_KEY_DOLLAR: return "DOLLAR";
|
||||
case GLFW_KEY_AMPERSAND: return "AMPERSAND";
|
||||
case GLFW_KEY_APOSTROPHE: return "APOSTROPHE";
|
||||
case GLFW_KEY_PARENTHESIS_LEFT: return "PARENTHESIS_LEFT";
|
||||
case GLFW_KEY_PARENTHESIS_RIGHT: return "PARENTHESIS_RIGHT";
|
||||
case GLFW_KEY_PLUS: return "PLUS";
|
||||
case GLFW_KEY_COMMA: return "COMMA";
|
||||
case GLFW_KEY_MINUS: return "MINUS";
|
||||
case GLFW_KEY_PERIOD: return "PERIOD";
|
||||
case GLFW_KEY_SLASH: return "SLASH";
|
||||
case GLFW_KEY_0: return "0";
|
||||
case GLFW_KEY_1: return "1";
|
||||
case GLFW_KEY_2: return "2";
|
||||
case GLFW_KEY_3: return "3";
|
||||
case GLFW_KEY_4: return "4";
|
||||
case GLFW_KEY_5: return "5";
|
||||
case GLFW_KEY_6: return "6";
|
||||
case GLFW_KEY_7: return "7";
|
||||
case GLFW_KEY_8: return "8";
|
||||
case GLFW_KEY_9: return "9";
|
||||
case GLFW_KEY_COLON: return "COLON";
|
||||
case GLFW_KEY_SEMICOLON: return "SEMICOLON";
|
||||
case GLFW_KEY_LESS: return "LESS";
|
||||
case GLFW_KEY_EQUAL: return "EQUAL";
|
||||
case GLFW_KEY_GREATER: return "GREATER";
|
||||
case GLFW_KEY_AT: return "AT";
|
||||
case GLFW_KEY_A: return "A";
|
||||
case GLFW_KEY_B: return "B";
|
||||
case GLFW_KEY_C: return "C";
|
||||
case GLFW_KEY_D: return "D";
|
||||
case GLFW_KEY_E: return "E";
|
||||
case GLFW_KEY_F: return "F";
|
||||
case GLFW_KEY_G: return "G";
|
||||
case GLFW_KEY_H: return "H";
|
||||
case GLFW_KEY_I: return "I";
|
||||
case GLFW_KEY_J: return "J";
|
||||
case GLFW_KEY_K: return "K";
|
||||
case GLFW_KEY_L: return "L";
|
||||
case GLFW_KEY_M: return "M";
|
||||
case GLFW_KEY_N: return "N";
|
||||
case GLFW_KEY_O: return "O";
|
||||
case GLFW_KEY_P: return "P";
|
||||
case GLFW_KEY_Q: return "Q";
|
||||
case GLFW_KEY_R: return "R";
|
||||
case GLFW_KEY_S: return "S";
|
||||
case GLFW_KEY_T: return "T";
|
||||
case GLFW_KEY_U: return "U";
|
||||
case GLFW_KEY_V: return "V";
|
||||
case GLFW_KEY_W: return "W";
|
||||
case GLFW_KEY_X: return "X";
|
||||
case GLFW_KEY_Y: return "Y";
|
||||
case GLFW_KEY_Z: return "Z";
|
||||
case GLFW_KEY_LEFT_BRACKET: return "LEFT_BRACKET";
|
||||
case GLFW_KEY_BACKSLASH: return "BACKSLASH";
|
||||
case GLFW_KEY_RIGHT_BRACKET: return "RIGHT_BRACKET";
|
||||
case GLFW_KEY_UNDERSCORE: return "UNDERSCORE";
|
||||
case GLFW_KEY_GRAVE_ACCENT: return "GRAVE_ACCENT";
|
||||
case GLFW_KEY_WORLD_1: return "WORLD_1";
|
||||
case GLFW_KEY_WORLD_2: return "WORLD_2";
|
||||
case GLFW_KEY_PARAGRAPH: return "PARAGRAPH";
|
||||
case GLFW_KEY_MASCULINE: return "MASCULINE";
|
||||
case GLFW_KEY_A_GRAVE: return "A_GRAVE";
|
||||
case GLFW_KEY_A_DIAERESIS: return "A_DIAERESIS";
|
||||
case GLFW_KEY_A_RING: return "A_RING";
|
||||
case GLFW_KEY_AE: return "AE";
|
||||
case GLFW_KEY_C_CEDILLA: return "C_CEDILLA";
|
||||
case GLFW_KEY_E_GRAVE: return "E_GRAVE";
|
||||
case GLFW_KEY_E_ACUTE: return "E_ACUTE";
|
||||
case GLFW_KEY_I_GRAVE: return "I_GRAVE";
|
||||
case GLFW_KEY_N_TILDE: return "N_TILDE";
|
||||
case GLFW_KEY_O_GRAVE: return "O_GRAVE";
|
||||
case GLFW_KEY_O_DIAERESIS: return "O_DIAERESIS";
|
||||
case GLFW_KEY_O_SLASH: return "O_SLASH";
|
||||
case GLFW_KEY_U_GRAVE: return "U_GRAVE";
|
||||
case GLFW_KEY_U_DIAERESIS: return "U_DIAERESIS";
|
||||
case GLFW_KEY_S_SHARP: return "S_SHARP";
|
||||
case GLFW_KEY_CYRILLIC_A: return "CYRILLIC_A";
|
||||
case GLFW_KEY_CYRILLIC_BE: return "CYRILLIC_BE";
|
||||
case GLFW_KEY_CYRILLIC_VE: return "CYRILLIC_VE";
|
||||
case GLFW_KEY_CYRILLIC_GHE: return "CYRILLIC_GHE";
|
||||
case GLFW_KEY_CYRILLIC_DE: return "CYRILLIC_DE";
|
||||
case GLFW_KEY_CYRILLIC_IE: return "CYRILLIC_IE";
|
||||
case GLFW_KEY_CYRILLIC_ZHE: return "CYRILLIC_ZHE";
|
||||
case GLFW_KEY_CYRILLIC_ZE: return "CYRILLIC_ZE";
|
||||
case GLFW_KEY_CYRILLIC_I: return "CYRILLIC_I";
|
||||
case GLFW_KEY_CYRILLIC_SHORT_I: return "CYRILLIC_SHORT_I";
|
||||
case GLFW_KEY_CYRILLIC_KA: return "CYRILLIC_KA";
|
||||
case GLFW_KEY_CYRILLIC_EL: return "CYRILLIC_EL";
|
||||
case GLFW_KEY_CYRILLIC_EM: return "CYRILLIC_EM";
|
||||
case GLFW_KEY_CYRILLIC_EN: return "CYRILLIC_EN";
|
||||
case GLFW_KEY_CYRILLIC_O: return "CYRILLIC_O";
|
||||
case GLFW_KEY_CYRILLIC_PE: return "CYRILLIC_PE";
|
||||
case GLFW_KEY_CYRILLIC_ER: return "CYRILLIC_ER";
|
||||
case GLFW_KEY_CYRILLIC_ES: return "CYRILLIC_ES";
|
||||
case GLFW_KEY_CYRILLIC_TE: return "CYRILLIC_TE";
|
||||
case GLFW_KEY_CYRILLIC_U: return "CYRILLIC_U";
|
||||
case GLFW_KEY_CYRILLIC_EF: return "CYRILLIC_EF";
|
||||
case GLFW_KEY_CYRILLIC_HA: return "CYRILLIC_HA";
|
||||
case GLFW_KEY_CYRILLIC_TSE: return "CYRILLIC_TSE";
|
||||
case GLFW_KEY_CYRILLIC_CHE: return "CYRILLIC_CHE";
|
||||
case GLFW_KEY_CYRILLIC_SHA: return "CYRILLIC_SHA";
|
||||
case GLFW_KEY_CYRILLIC_SHCHA: return "CYRILLIC_SHCHA";
|
||||
case GLFW_KEY_CYRILLIC_HARD_SIGN: return "CYRILLIC_HARD_SIGN";
|
||||
case GLFW_KEY_CYRILLIC_YERU: return "CYRILLIC_YERU";
|
||||
case GLFW_KEY_CYRILLIC_SOFT_SIGN: return "CYRILLIC_SOFT_SIGN";
|
||||
case GLFW_KEY_CYRILLIC_E: return "CYRILLIC_E";
|
||||
case GLFW_KEY_CYRILLIC_YU: return "CYRILLIC_YU";
|
||||
case GLFW_KEY_CYRILLIC_YA: return "CYRILLIC_YA";
|
||||
case GLFW_KEY_CYRILLIC_IO: return "CYRILLIC_IO";
|
||||
|
||||
// Function keys
|
||||
case GLFW_KEY_ESCAPE: return "ESCAPE";
|
||||
case GLFW_KEY_F1: return "F1";
|
||||
case GLFW_KEY_F2: return "F2";
|
||||
case GLFW_KEY_F3: return "F3";
|
||||
case GLFW_KEY_F4: return "F4";
|
||||
case GLFW_KEY_F5: return "F5";
|
||||
case GLFW_KEY_F6: return "F6";
|
||||
case GLFW_KEY_F7: return "F7";
|
||||
case GLFW_KEY_F8: return "F8";
|
||||
case GLFW_KEY_F9: return "F9";
|
||||
case GLFW_KEY_F10: return "F10";
|
||||
case GLFW_KEY_F11: return "F11";
|
||||
case GLFW_KEY_F12: return "F12";
|
||||
case GLFW_KEY_F13: return "F13";
|
||||
case GLFW_KEY_F14: return "F14";
|
||||
case GLFW_KEY_F15: return "F15";
|
||||
case GLFW_KEY_F16: return "F16";
|
||||
case GLFW_KEY_F17: return "F17";
|
||||
case GLFW_KEY_F18: return "F18";
|
||||
case GLFW_KEY_F19: return "F19";
|
||||
case GLFW_KEY_F20: return "F20";
|
||||
case GLFW_KEY_F21: return "F21";
|
||||
case GLFW_KEY_F22: return "F22";
|
||||
case GLFW_KEY_F23: return "F23";
|
||||
case GLFW_KEY_F24: return "F24";
|
||||
case GLFW_KEY_F25: return "F25";
|
||||
case GLFW_KEY_UP: return "UP";
|
||||
case GLFW_KEY_DOWN: return "DOWN";
|
||||
case GLFW_KEY_LEFT: return "LEFT";
|
||||
case GLFW_KEY_RIGHT: return "RIGHT";
|
||||
case GLFW_KEY_LEFT_SHIFT: return "LEFT SHIFT";
|
||||
case GLFW_KEY_RIGHT_SHIFT: return "RIGHT SHIFT";
|
||||
case GLFW_KEY_LEFT_CONTROL: return "LEFT CONTROL";
|
||||
case GLFW_KEY_RIGHT_CONTROL: return "RIGHT CONTROL";
|
||||
case GLFW_KEY_LEFT_ALT: return "LEFT ALT";
|
||||
case GLFW_KEY_RIGHT_ALT: return "RIGHT ALT";
|
||||
case GLFW_KEY_TAB: return "TAB";
|
||||
case GLFW_KEY_ENTER: return "ENTER";
|
||||
case GLFW_KEY_BACKSPACE: return "BACKSPACE";
|
||||
case GLFW_KEY_INSERT: return "INSERT";
|
||||
case GLFW_KEY_DELETE: return "DELETE";
|
||||
case GLFW_KEY_PAGE_UP: return "PAGE UP";
|
||||
case GLFW_KEY_PAGE_DOWN: return "PAGE DOWN";
|
||||
case GLFW_KEY_HOME: return "HOME";
|
||||
case GLFW_KEY_END: return "END";
|
||||
case GLFW_KEY_KP_0: return "KEYPAD 0";
|
||||
case GLFW_KEY_KP_1: return "KEYPAD 1";
|
||||
case GLFW_KEY_KP_2: return "KEYPAD 2";
|
||||
case GLFW_KEY_KP_3: return "KEYPAD 3";
|
||||
case GLFW_KEY_KP_4: return "KEYPAD 4";
|
||||
case GLFW_KEY_KP_5: return "KEYPAD 5";
|
||||
case GLFW_KEY_KP_6: return "KEYPAD 6";
|
||||
case GLFW_KEY_KP_7: return "KEYPAD 7";
|
||||
case GLFW_KEY_KP_8: return "KEYPAD 8";
|
||||
case GLFW_KEY_KP_9: return "KEYPAD 9";
|
||||
case GLFW_KEY_KP_DIVIDE: return "KEYPAD DIVIDE";
|
||||
case GLFW_KEY_KP_MULTIPLY: return "KEYPAD MULTPLY";
|
||||
case GLFW_KEY_KP_SUBTRACT: return "KEYPAD SUBTRACT";
|
||||
case GLFW_KEY_KP_ADD: return "KEYPAD ADD";
|
||||
case GLFW_KEY_KP_DECIMAL: return "KEYPAD DECIMAL";
|
||||
case GLFW_KEY_KP_EQUAL: return "KEYPAD EQUAL";
|
||||
case GLFW_KEY_KP_ENTER: return "KEYPAD ENTER";
|
||||
case GLFW_KEY_PRINT_SCREEN: return "PRINT SCREEN";
|
||||
case GLFW_KEY_NUM_LOCK: return "NUM LOCK";
|
||||
case GLFW_KEY_CAPS_LOCK: return "CAPS LOCK";
|
||||
case GLFW_KEY_SCROLL_LOCK: return "SCROLL LOCK";
|
||||
case GLFW_KEY_PAUSE: return "PAUSE";
|
||||
case GLFW_KEY_LEFT_SUPER: return "LEFT SUPER";
|
||||
case GLFW_KEY_RIGHT_SUPER: return "RIGHT SUPER";
|
||||
case GLFW_KEY_MENU: return "MENU";
|
||||
case GLFW_KEY_ESCAPE: return "ESCAPE";
|
||||
case GLFW_KEY_F1: return "F1";
|
||||
case GLFW_KEY_F2: return "F2";
|
||||
case GLFW_KEY_F3: return "F3";
|
||||
case GLFW_KEY_F4: return "F4";
|
||||
case GLFW_KEY_F5: return "F5";
|
||||
case GLFW_KEY_F6: return "F6";
|
||||
case GLFW_KEY_F7: return "F7";
|
||||
case GLFW_KEY_F8: return "F8";
|
||||
case GLFW_KEY_F9: return "F9";
|
||||
case GLFW_KEY_F10: return "F10";
|
||||
case GLFW_KEY_F11: return "F11";
|
||||
case GLFW_KEY_F12: return "F12";
|
||||
case GLFW_KEY_F13: return "F13";
|
||||
case GLFW_KEY_F14: return "F14";
|
||||
case GLFW_KEY_F15: return "F15";
|
||||
case GLFW_KEY_F16: return "F16";
|
||||
case GLFW_KEY_F17: return "F17";
|
||||
case GLFW_KEY_F18: return "F18";
|
||||
case GLFW_KEY_F19: return "F19";
|
||||
case GLFW_KEY_F20: return "F20";
|
||||
case GLFW_KEY_F21: return "F21";
|
||||
case GLFW_KEY_F22: return "F22";
|
||||
case GLFW_KEY_F23: return "F23";
|
||||
case GLFW_KEY_F24: return "F24";
|
||||
case GLFW_KEY_F25: return "F25";
|
||||
case GLFW_KEY_UP: return "UP";
|
||||
case GLFW_KEY_DOWN: return "DOWN";
|
||||
case GLFW_KEY_LEFT: return "LEFT";
|
||||
case GLFW_KEY_RIGHT: return "RIGHT";
|
||||
case GLFW_KEY_LEFT_SHIFT: return "LEFT SHIFT";
|
||||
case GLFW_KEY_RIGHT_SHIFT: return "RIGHT SHIFT";
|
||||
case GLFW_KEY_LEFT_CONTROL: return "LEFT CONTROL";
|
||||
case GLFW_KEY_RIGHT_CONTROL: return "RIGHT CONTROL";
|
||||
case GLFW_KEY_LEFT_ALT: return "LEFT ALT";
|
||||
case GLFW_KEY_RIGHT_ALT: return "RIGHT ALT";
|
||||
case GLFW_KEY_TAB: return "TAB";
|
||||
case GLFW_KEY_ENTER: return "ENTER";
|
||||
case GLFW_KEY_BACKSPACE: return "BACKSPACE";
|
||||
case GLFW_KEY_INSERT: return "INSERT";
|
||||
case GLFW_KEY_DELETE: return "DELETE";
|
||||
case GLFW_KEY_PAGE_UP: return "PAGE UP";
|
||||
case GLFW_KEY_PAGE_DOWN: return "PAGE DOWN";
|
||||
case GLFW_KEY_HOME: return "HOME";
|
||||
case GLFW_KEY_END: return "END";
|
||||
case GLFW_KEY_KP_0: return "KEYPAD 0";
|
||||
case GLFW_KEY_KP_1: return "KEYPAD 1";
|
||||
case GLFW_KEY_KP_2: return "KEYPAD 2";
|
||||
case GLFW_KEY_KP_3: return "KEYPAD 3";
|
||||
case GLFW_KEY_KP_4: return "KEYPAD 4";
|
||||
case GLFW_KEY_KP_5: return "KEYPAD 5";
|
||||
case GLFW_KEY_KP_6: return "KEYPAD 6";
|
||||
case GLFW_KEY_KP_7: return "KEYPAD 7";
|
||||
case GLFW_KEY_KP_8: return "KEYPAD 8";
|
||||
case GLFW_KEY_KP_9: return "KEYPAD 9";
|
||||
case GLFW_KEY_KP_DIVIDE: return "KEYPAD DIVIDE";
|
||||
case GLFW_KEY_KP_MULTIPLY: return "KEYPAD MULTIPLY";
|
||||
case GLFW_KEY_KP_SUBTRACT: return "KEYPAD SUBTRACT";
|
||||
case GLFW_KEY_KP_ADD: return "KEYPAD ADD";
|
||||
case GLFW_KEY_KP_DECIMAL: return "KEYPAD DECIMAL";
|
||||
case GLFW_KEY_KP_EQUAL: return "KEYPAD EQUAL";
|
||||
case GLFW_KEY_KP_ENTER: return "KEYPAD ENTER";
|
||||
case GLFW_KEY_PRINT_SCREEN: return "PRINT SCREEN";
|
||||
case GLFW_KEY_NUM_LOCK: return "NUM LOCK";
|
||||
case GLFW_KEY_CAPS_LOCK: return "CAPS LOCK";
|
||||
case GLFW_KEY_SCROLL_LOCK: return "SCROLL LOCK";
|
||||
case GLFW_KEY_PAUSE: return "PAUSE";
|
||||
case GLFW_KEY_LEFT_SUPER: return "LEFT SUPER";
|
||||
case GLFW_KEY_RIGHT_SUPER: return "RIGHT SUPER";
|
||||
case GLFW_KEY_MENU: return "MENU";
|
||||
|
||||
default: return "UNKNOWN";
|
||||
default: return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -691,7 +752,7 @@ GLFWAPI const char* glfwGetKeyName(int key, int scancode)
|
||||
{
|
||||
if (key != GLFW_KEY_KP_EQUAL &&
|
||||
(key < GLFW_KEY_KP_0 || key > GLFW_KEY_KP_ADD) &&
|
||||
(key < GLFW_KEY_APOSTROPHE || key > GLFW_KEY_WORLD_2))
|
||||
(key < GLFW_KEY_APOSTROPHE || key > GLFW_KEY_LAST_PRINTABLE))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
2
glfw/internal.h
vendored
2
glfw/internal.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 - www.glfw.org
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
12
glfw/linux_joystick.c
vendored
12
glfw/linux_joystick.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 Linux - www.glfw.org
|
||||
// GLFW 3.4 Linux - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
@@ -144,10 +144,10 @@ static bool openJoystickDevice(const char* path)
|
||||
char absBits[(ABS_CNT + 7) / 8] = {0};
|
||||
struct input_id id;
|
||||
|
||||
if (ioctl(linjs.fd, EVIOCGBIT(0, sizeof(evBits)), evBits) < 0 ||
|
||||
ioctl(linjs.fd, EVIOCGBIT(EV_KEY, sizeof(keyBits)), keyBits) < 0 ||
|
||||
ioctl(linjs.fd, EVIOCGBIT(EV_ABS, sizeof(absBits)), absBits) < 0 ||
|
||||
ioctl(linjs.fd, EVIOCGID, &id) < 0)
|
||||
if (ioctl(linjs.fd, (int32_t)EVIOCGBIT(0, sizeof(evBits)), evBits) < 0 ||
|
||||
ioctl(linjs.fd, (int32_t)EVIOCGBIT(EV_KEY, sizeof(keyBits)), keyBits) < 0 ||
|
||||
ioctl(linjs.fd, (int32_t)EVIOCGBIT(EV_ABS, sizeof(absBits)), absBits) < 0 ||
|
||||
ioctl(linjs.fd, (int32_t)EVIOCGID, &id) < 0)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Linux: Failed to query input device: %s",
|
||||
@@ -165,7 +165,7 @@ static bool openJoystickDevice(const char* path)
|
||||
|
||||
char name[256] = "";
|
||||
|
||||
if (ioctl(linjs.fd, EVIOCGNAME(sizeof(name)), name) < 0)
|
||||
if (ioctl(linjs.fd, (int32_t)EVIOCGNAME(sizeof(name)), name) < 0)
|
||||
strncpy(name, "Unknown", sizeof(name));
|
||||
|
||||
char guid[33] = "";
|
||||
|
||||
4
glfw/linux_joystick.h
vendored
4
glfw/linux_joystick.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 Linux - www.glfw.org
|
||||
// GLFW 3.4 Linux - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
|
||||
//
|
||||
@@ -52,7 +52,7 @@ typedef struct _GLFWlibraryLinux
|
||||
int inotify;
|
||||
int watch;
|
||||
regex_t regex;
|
||||
bool dropped;
|
||||
bool dropped;
|
||||
} _GLFWlibraryLinux;
|
||||
|
||||
|
||||
|
||||
2
glfw/mappings.h
vendored
2
glfw/mappings.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 - www.glfw.org
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
|
||||
6
glfw/monitor.c
vendored
6
glfw/monitor.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 - www.glfw.org
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
@@ -56,6 +56,10 @@ static int compareVideoModes(const void* fp, const void* sp)
|
||||
if (farea != sarea)
|
||||
return farea - sarea;
|
||||
|
||||
// Then sort on width
|
||||
if (fm->width != sm->width)
|
||||
return fm->width - sm->width;
|
||||
|
||||
// Lastly sort on refresh rate
|
||||
return fm->refreshRate - sm->refreshRate;
|
||||
}
|
||||
|
||||
2
glfw/nsgl_context.h
vendored
2
glfw/nsgl_context.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 macOS - www.glfw.org
|
||||
// GLFW 3.4 macOS - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 macOS - www.glfw.org
|
||||
// GLFW 3.4 macOS - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
|
||||
2
glfw/null_init.c
vendored
2
glfw/null_init.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 - www.glfw.org
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2016 Google Inc.
|
||||
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
6
glfw/null_joystick.c
vendored
6
glfw/null_joystick.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 - www.glfw.org
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
@@ -33,12 +33,12 @@
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
|
||||
int _glfwPlatformPollJoystick(_GLFWjoystick* js UNUSED, int mode UNUSED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void _glfwPlatformUpdateGamepadGUID(char* guid)
|
||||
void _glfwPlatformUpdateGamepadGUID(char* guid UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
2
glfw/null_joystick.h
vendored
2
glfw/null_joystick.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 - www.glfw.org
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
|
||||
22
glfw/null_monitor.c
vendored
22
glfw/null_monitor.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 - www.glfw.org
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2016 Google Inc.
|
||||
// Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
@@ -34,15 +34,15 @@
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
|
||||
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
|
||||
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor UNUSED, int* xpos UNUSED, int* ypos UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
||||
void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor UNUSED,
|
||||
float* xscale, float* yscale)
|
||||
{
|
||||
if (xscale)
|
||||
@@ -51,27 +51,27 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
|
||||
*yscale = 1.f;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
|
||||
int* xpos, int* ypos,
|
||||
int* width, int* height)
|
||||
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor UNUSED,
|
||||
int* xpos UNUSED, int* ypos UNUSED,
|
||||
int* width UNUSED, int* height UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
||||
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor UNUSED, int* found UNUSED)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
|
||||
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor UNUSED, GLFWvidmode* mode UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
bool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
|
||||
bool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor UNUSED, GLFWgammaramp* ramp UNUSED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor UNUSED, const GLFWgammaramp* ramp UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
2
glfw/null_platform.h
vendored
2
glfw/null_platform.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 - www.glfw.org
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2016 Google Inc.
|
||||
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
124
glfw/null_window.c
vendored
124
glfw/null_window.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 - www.glfw.org
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2016 Google Inc.
|
||||
// Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
@@ -78,28 +78,28 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||
window->context.destroy(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window UNUSED, const char* title UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count,
|
||||
const GLFWimage* images)
|
||||
void _glfwPlatformSetWindowIcon(_GLFWwindow* window UNUSED, int count UNUSED,
|
||||
const GLFWimage* images UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
||||
_GLFWmonitor* monitor,
|
||||
int xpos, int ypos,
|
||||
int width, int height,
|
||||
int refreshRate)
|
||||
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window UNUSED,
|
||||
_GLFWmonitor* monitor UNUSED,
|
||||
int xpos UNUSED, int ypos UNUSED,
|
||||
int width UNUSED, int height UNUSED,
|
||||
int refreshRate UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
|
||||
void _glfwPlatformGetWindowPos(_GLFWwindow* window UNUSED, int* xpos UNUSED, int* ypos UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
|
||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window UNUSED, int xpos UNUSED, int ypos UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -117,13 +117,13 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
||||
window->null.height = height;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
|
||||
int minwidth, int minheight,
|
||||
int maxwidth, int maxheight)
|
||||
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window UNUSED,
|
||||
int minwidth UNUSED, int minheight UNUSED,
|
||||
int maxwidth UNUSED, int maxheight UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int n, int d)
|
||||
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window UNUSED, int n UNUSED, int d UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -135,13 +135,13 @@ void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* heigh
|
||||
*height = window->null.height;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
||||
int* left, int* top,
|
||||
int* right, int* bottom)
|
||||
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window UNUSED,
|
||||
int* left UNUSED, int* top UNUSED,
|
||||
int* right UNUSED, int* bottom UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
||||
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window UNUSED,
|
||||
float* xscale, float* yscale)
|
||||
{
|
||||
if (xscale)
|
||||
@@ -150,101 +150,101 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
|
||||
*yscale = 1.f;
|
||||
}
|
||||
|
||||
double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window)
|
||||
double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
||||
void _glfwPlatformMaximizeWindow(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
||||
int _glfwPlatformWindowHovered(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, bool enabled)
|
||||
void _glfwPlatformSetWindowResizable(_GLFWwindow* window UNUSED, bool enabled UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, bool enabled)
|
||||
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window UNUSED, bool enabled UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, bool enabled)
|
||||
void _glfwPlatformSetWindowFloating(_GLFWwindow* window UNUSED, bool enabled UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
|
||||
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
return 1.f;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
|
||||
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window UNUSED, float opacity UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
||||
void _glfwPlatformShowWindow(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
|
||||
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowBell(_GLFWwindow* window)
|
||||
int _glfwPlatformWindowBell(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void _glfwPlatformUnhideWindow(_GLFWwindow* window)
|
||||
void _glfwPlatformUnhideWindow(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformHideWindow(_GLFWwindow* window)
|
||||
void _glfwPlatformHideWindow(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformFocusWindow(_GLFWwindow* window)
|
||||
void _glfwPlatformFocusWindow(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowFocused(_GLFWwindow* window)
|
||||
int _glfwPlatformWindowFocused(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowOccluded(_GLFWwindow* window)
|
||||
int _glfwPlatformWindowOccluded(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowIconified(_GLFWwindow* window)
|
||||
int _glfwPlatformWindowIconified(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int _glfwPlatformWindowVisible(_GLFWwindow* window)
|
||||
int _glfwPlatformWindowVisible(_GLFWwindow* window UNUSED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -257,7 +257,7 @@ void _glfwPlatformWaitEvents(void)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformWaitEventsTimeout(double timeout)
|
||||
void _glfwPlatformWaitEventsTimeout(double timeout UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -265,39 +265,39 @@ void _glfwPlatformPostEmptyEvent(void)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
|
||||
void _glfwPlatformGetCursorPos(_GLFWwindow* window UNUSED, double* xpos UNUSED, double* ypos UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
|
||||
void _glfwPlatformSetCursorPos(_GLFWwindow* window UNUSED, double x UNUSED, double y UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
|
||||
void _glfwPlatformSetCursorMode(_GLFWwindow* window UNUSED, int mode UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
||||
const GLFWimage* image,
|
||||
int xhot, int yhot, int count)
|
||||
int _glfwPlatformCreateCursor(_GLFWcursor* cursor UNUSED,
|
||||
const GLFWimage* image UNUSED,
|
||||
int xhot UNUSED, int yhot UNUSED, int count UNUSED)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
|
||||
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor UNUSED, int shape UNUSED)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
|
||||
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
|
||||
void _glfwPlatformSetCursor(_GLFWwindow* window UNUSED, _GLFWcursor* cursor UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformSetClipboardString(const char* string)
|
||||
void _glfwPlatformSetClipboardString(const char* string UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -306,31 +306,31 @@ const char* _glfwPlatformGetClipboardString(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetScancodeName(int scancode)
|
||||
const char* _glfwPlatformGetScancodeName(int scancode UNUSED)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
int _glfwPlatformGetKeyScancode(int key)
|
||||
int _glfwPlatformGetKeyScancode(int key UNUSED)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
|
||||
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
|
||||
VkPhysicalDevice device,
|
||||
uint32_t queuefamily)
|
||||
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance UNUSED,
|
||||
VkPhysicalDevice device UNUSED,
|
||||
uint32_t queuefamily UNUSED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
||||
_GLFWwindow* window,
|
||||
const VkAllocationCallbacks* allocator,
|
||||
VkSurfaceKHR* surface)
|
||||
VkResult _glfwPlatformCreateWindowSurface(VkInstance instance UNUSED,
|
||||
_GLFWwindow* window UNUSED,
|
||||
const VkAllocationCallbacks* allocator UNUSED,
|
||||
VkSurfaceKHR* surface UNUSED)
|
||||
{
|
||||
// This seems like the most appropriate error to return here
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
|
||||
2
glfw/osmesa_context.c
vendored
2
glfw/osmesa_context.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 OSMesa - www.glfw.org
|
||||
// GLFW 3.4 OSMesa - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2016 Google Inc.
|
||||
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
2
glfw/osmesa_context.h
vendored
2
glfw/osmesa_context.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 OSMesa - www.glfw.org
|
||||
// GLFW 3.4 OSMesa - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2016 Google Inc.
|
||||
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
2
glfw/posix_thread.c
vendored
2
glfw/posix_thread.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 POSIX - www.glfw.org
|
||||
// GLFW 3.4 POSIX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
6
glfw/posix_thread.h
vendored
6
glfw/posix_thread.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 POSIX - www.glfw.org
|
||||
// GLFW 3.4 POSIX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
@@ -35,7 +35,7 @@
|
||||
//
|
||||
typedef struct _GLFWtlsPOSIX
|
||||
{
|
||||
bool allocated;
|
||||
bool allocated;
|
||||
pthread_key_t key;
|
||||
|
||||
} _GLFWtlsPOSIX;
|
||||
@@ -44,7 +44,7 @@ typedef struct _GLFWtlsPOSIX
|
||||
//
|
||||
typedef struct _GLFWmutexPOSIX
|
||||
{
|
||||
bool allocated;
|
||||
bool allocated;
|
||||
pthread_mutex_t handle;
|
||||
|
||||
} _GLFWmutexPOSIX;
|
||||
|
||||
2
glfw/posix_time.c
vendored
2
glfw/posix_time.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 POSIX - www.glfw.org
|
||||
// GLFW 3.4 POSIX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
4
glfw/posix_time.h
vendored
4
glfw/posix_time.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 POSIX - www.glfw.org
|
||||
// GLFW 3.4 POSIX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
@@ -34,7 +34,7 @@
|
||||
//
|
||||
typedef struct _GLFWtimerPOSIX
|
||||
{
|
||||
bool monotonic;
|
||||
bool monotonic;
|
||||
uint64_t frequency;
|
||||
|
||||
} _GLFWtimerPOSIX;
|
||||
|
||||
2
glfw/vulkan.c
vendored
2
glfw/vulkan.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 - www.glfw.org
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
2
glfw/window.c
vendored
2
glfw/window.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 - www.glfw.org
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
2
glfw/wl_init.c
vendored
2
glfw/wl_init.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 Wayland - www.glfw.org
|
||||
// GLFW 3.4 Wayland - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
|
||||
//
|
||||
|
||||
2
glfw/wl_monitor.c
vendored
2
glfw/wl_monitor.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 Wayland - www.glfw.org
|
||||
// GLFW 3.4 Wayland - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
|
||||
//
|
||||
|
||||
2
glfw/wl_platform.h
vendored
2
glfw/wl_platform.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 Wayland - www.glfw.org
|
||||
// GLFW 3.4 Wayland - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
|
||||
//
|
||||
|
||||
6
glfw/wl_window.c
vendored
6
glfw/wl_window.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 Wayland - www.glfw.org
|
||||
// GLFW 3.4 Wayland - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
|
||||
//
|
||||
@@ -173,7 +173,7 @@ static void dispatchChangesAfterConfigure(_GLFWwindow *window, int32_t width, in
|
||||
* SCM_RIGHTS methods.
|
||||
*
|
||||
* posix_fallocate() is used to guarantee that disk space is available
|
||||
* for the file at the given size. If disk space is insufficent, errno
|
||||
* for the file at the given size. If disk space is insufficient, errno
|
||||
* is set to ENOSPC. If posix_fallocate() is not supported, program may
|
||||
* receive SIGBUS on accessing mmap()'ed file contents instead.
|
||||
*/
|
||||
@@ -1836,7 +1836,7 @@ static inline bool _glfwEnsureDataDevice(void) {
|
||||
if (!_glfw.wl.dataDevice)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Wayland: Cannot use clipboard, failed to create data device");
|
||||
"Wayland: Cannot use clipboard, failed to create data device");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
2
glfw/x11_init.c
vendored
2
glfw/x11_init.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 X11 - www.glfw.org
|
||||
// GLFW 3.4 X11 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
2
glfw/x11_monitor.c
vendored
2
glfw/x11_monitor.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 X11 - www.glfw.org
|
||||
// GLFW 3.4 X11 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
2
glfw/x11_platform.h
vendored
2
glfw/x11_platform.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 X11 - www.glfw.org
|
||||
// GLFW 3.4 X11 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
6
glfw/x11_window.c
vendored
6
glfw/x11_window.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 X11 - www.glfw.org
|
||||
// GLFW 3.4 X11 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
@@ -78,7 +78,7 @@ handleEvents(double timeout) {
|
||||
|
||||
static bool
|
||||
waitForX11Event(double timeout) {
|
||||
// returns true iff there is X11 data waiting to be read, does not run watches and timers
|
||||
// returns true if there is X11 data waiting to be read, does not run watches and timers
|
||||
double end_time = glfwGetTime() + timeout;
|
||||
while(true) {
|
||||
if (timeout >= 0) {
|
||||
@@ -2512,7 +2512,7 @@ _glfwDispatchX11Events(void) {
|
||||
}
|
||||
|
||||
XFlush(_glfw.x11.display);
|
||||
// XFlush can cause events to be queued, we dont use QueuedAfterFlush here
|
||||
// XFlush can cause events to be queued, we don't use QueuedAfterFlush here
|
||||
// as something might have inserted events into the queue, but we want to guarantee
|
||||
// a flush.
|
||||
dispatched += dispatch_x11_queued_events(XEventsQueued(_glfw.x11.display, QueuedAlready));
|
||||
|
||||
120
glfw/xkb_glfw.c
vendored
120
glfw/xkb_glfw.c
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 XKB - www.glfw.org
|
||||
// GLFW 3.4 XKB - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2018 Kovid Goyal <kovid@kovidgoyal.net>
|
||||
//
|
||||
@@ -37,19 +37,130 @@ START_ALLOW_CASE_RANGE
|
||||
#define map_key(key) \
|
||||
switch(key) { \
|
||||
S(space, SPACE); \
|
||||
S(exclam, EXCLAM); \
|
||||
S(quotedbl, DOUBLE_QUOTE); \
|
||||
S(numbersign, NUMBER_SIGN); \
|
||||
S(dollar, DOLLAR); \
|
||||
S(ampersand, AMPERSAND); \
|
||||
S(apostrophe, APOSTROPHE); \
|
||||
S(parenleft, PARENTHESIS_LEFT); \
|
||||
S(parenright, PARENTHESIS_RIGHT); \
|
||||
S(plus, PLUS); \
|
||||
S(comma, COMMA); \
|
||||
S(minus, MINUS); \
|
||||
S(period, PERIOD); \
|
||||
S(slash, SLASH); \
|
||||
R(0, 9, 0, 9); \
|
||||
S(colon, COLON); \
|
||||
S(semicolon, SEMICOLON); \
|
||||
S(less, LESS); \
|
||||
S(equal, EQUAL); \
|
||||
S(greater, GREATER); \
|
||||
S(at, AT); \
|
||||
D(A, Z, A, Z); \
|
||||
S(bracketleft, LEFT_BRACKET); \
|
||||
S(backslash, BACKSLASH); \
|
||||
S(bracketright, RIGHT_BRACKET); \
|
||||
S(plus, PLUS); \
|
||||
S(underscore, UNDERSCORE); \
|
||||
S(grave, GRAVE_ACCENT); \
|
||||
R(a, z, A, Z); \
|
||||
S(paragraph, PARAGRAPH); \
|
||||
S(masculine, MASCULINE); \
|
||||
S(agrave, A_GRAVE); \
|
||||
F(Agrave, A_GRAVE); \
|
||||
S(adiaeresis, A_DIAERESIS); \
|
||||
F(Adiaeresis, A_DIAERESIS); \
|
||||
S(aring, A_RING); \
|
||||
F(Aring, A_RING); \
|
||||
S(ae, AE); \
|
||||
F(AE, AE); \
|
||||
S(ccedilla, C_CEDILLA); \
|
||||
F(Ccedilla, C_CEDILLA); \
|
||||
S(egrave, E_GRAVE); \
|
||||
F(Egrave, E_GRAVE); \
|
||||
S(aacute, E_ACUTE); \
|
||||
F(Eacute, E_ACUTE); \
|
||||
S(igrave, I_GRAVE); \
|
||||
F(Igrave, I_GRAVE); \
|
||||
S(ntilde, N_TILDE); \
|
||||
F(Ntilde, N_TILDE); \
|
||||
S(ograve, O_GRAVE); \
|
||||
F(Ograve, O_GRAVE); \
|
||||
S(odiaeresis, O_DIAERESIS); \
|
||||
F(Odiaeresis, O_DIAERESIS); \
|
||||
S(oslash, O_SLASH); \
|
||||
F(Oslash, O_SLASH); \
|
||||
S(ugrave, U_GRAVE); \
|
||||
F(Ugrave, U_GRAVE); \
|
||||
S(udiaeresis, U_DIAERESIS); \
|
||||
F(Udiaeresis, U_DIAERESIS); \
|
||||
S(ssharp, S_SHARP); \
|
||||
S(Cyrillic_a, CYRILLIC_A); \
|
||||
F(Cyrillic_A, CYRILLIC_A); \
|
||||
S(Cyrillic_be, CYRILLIC_BE); \
|
||||
F(Cyrillic_BE, CYRILLIC_BE); \
|
||||
S(Cyrillic_ve, CYRILLIC_VE); \
|
||||
F(Cyrillic_VE, CYRILLIC_VE); \
|
||||
S(Cyrillic_ghe, CYRILLIC_GHE); \
|
||||
F(Cyrillic_GHE, CYRILLIC_GHE); \
|
||||
S(Cyrillic_de, CYRILLIC_DE); \
|
||||
F(Cyrillic_DE, CYRILLIC_DE); \
|
||||
S(Cyrillic_ie, CYRILLIC_IE); \
|
||||
F(Cyrillic_IE, CYRILLIC_IE); \
|
||||
S(Cyrillic_zhe, CYRILLIC_ZHE); \
|
||||
F(Cyrillic_ZHE, CYRILLIC_ZHE); \
|
||||
S(Cyrillic_ze, CYRILLIC_ZE); \
|
||||
F(Cyrillic_ZE, CYRILLIC_ZE); \
|
||||
S(Cyrillic_i, CYRILLIC_I); \
|
||||
F(Cyrillic_I, CYRILLIC_I); \
|
||||
S(Cyrillic_shorti, CYRILLIC_SHORT_I); \
|
||||
F(Cyrillic_SHORTI, CYRILLIC_SHORT_I); \
|
||||
S(Cyrillic_ka, CYRILLIC_KA); \
|
||||
F(Cyrillic_KA, CYRILLIC_KA); \
|
||||
S(Cyrillic_el, CYRILLIC_EL); \
|
||||
F(Cyrillic_EL, CYRILLIC_EL); \
|
||||
S(Cyrillic_em, CYRILLIC_EM); \
|
||||
F(Cyrillic_EM, CYRILLIC_EM); \
|
||||
S(Cyrillic_en, CYRILLIC_EN); \
|
||||
F(Cyrillic_EN, CYRILLIC_EN); \
|
||||
S(Cyrillic_o, CYRILLIC_O); \
|
||||
F(Cyrillic_O, CYRILLIC_O); \
|
||||
S(Cyrillic_pe, CYRILLIC_PE); \
|
||||
F(Cyrillic_PE, CYRILLIC_PE); \
|
||||
S(Cyrillic_er, CYRILLIC_ER); \
|
||||
F(Cyrillic_ER, CYRILLIC_ER); \
|
||||
S(Cyrillic_es, CYRILLIC_ES); \
|
||||
F(Cyrillic_ES, CYRILLIC_ES); \
|
||||
S(Cyrillic_te, CYRILLIC_TE); \
|
||||
F(Cyrillic_TE, CYRILLIC_TE); \
|
||||
S(Cyrillic_u, CYRILLIC_U); \
|
||||
F(Cyrillic_U, CYRILLIC_U); \
|
||||
S(Cyrillic_ef, CYRILLIC_EF); \
|
||||
F(Cyrillic_EF, CYRILLIC_EF); \
|
||||
S(Cyrillic_ha, CYRILLIC_HA); \
|
||||
F(Cyrillic_HA, CYRILLIC_HA); \
|
||||
S(Cyrillic_tse, CYRILLIC_TSE); \
|
||||
F(Cyrillic_TSE, CYRILLIC_TSE); \
|
||||
S(Cyrillic_che, CYRILLIC_CHE); \
|
||||
F(Cyrillic_CHE, CYRILLIC_CHE); \
|
||||
S(Cyrillic_sha, CYRILLIC_SHA); \
|
||||
F(Cyrillic_SHA, CYRILLIC_SHA); \
|
||||
S(Cyrillic_shcha, CYRILLIC_SHCHA); \
|
||||
F(Cyrillic_SHCHA, CYRILLIC_SHCHA); \
|
||||
S(Cyrillic_hardsign, CYRILLIC_HARD_SIGN); \
|
||||
F(Cyrillic_HARDSIGN, CYRILLIC_HARD_SIGN); \
|
||||
S(Cyrillic_yeru, CYRILLIC_YERU); \
|
||||
F(Cyrillic_YERU, CYRILLIC_YERU); \
|
||||
S(Cyrillic_softsign, CYRILLIC_SOFT_SIGN); \
|
||||
F(Cyrillic_SOFTSIGN, CYRILLIC_SOFT_SIGN); \
|
||||
S(Cyrillic_e, CYRILLIC_E); \
|
||||
F(Cyrillic_E, CYRILLIC_E); \
|
||||
S(Cyrillic_yu, CYRILLIC_YU); \
|
||||
F(Cyrillic_YU, CYRILLIC_YU); \
|
||||
S(Cyrillic_ya, CYRILLIC_YA); \
|
||||
F(Cyrillic_YA, CYRILLIC_YA); \
|
||||
S(Cyrillic_io, CYRILLIC_IO); \
|
||||
F(Cyrillic_IO, CYRILLIC_IO); \
|
||||
S(Escape, ESCAPE); \
|
||||
S(Return, ENTER); \
|
||||
S(Tab, TAB); \
|
||||
@@ -91,9 +202,6 @@ START_ALLOW_CASE_RANGE
|
||||
S(Alt_R, RIGHT_ALT); \
|
||||
S(Super_R, RIGHT_SUPER); \
|
||||
S(Menu, MENU); \
|
||||
R(0, 9, 0, 9); \
|
||||
R(a, z, A, Z); \
|
||||
D(A, Z, A, Z); \
|
||||
R(F1, F25, F1, F25); \
|
||||
R(KP_0, KP_9, KP_0, KP_9); \
|
||||
|
||||
@@ -434,7 +542,7 @@ glfw_xkb_key_from_ime(KeyEvent *ev, bool handled_by_ime, bool failed) {
|
||||
}
|
||||
static xkb_keycode_t last_handled_press_keycode = 0;
|
||||
// We filter out release events that correspond to the last press event
|
||||
// handled by the IME system. This wont fix the case of multiple key
|
||||
// handled by the IME system. This won't fix the case of multiple key
|
||||
// presses before a release, but is better than nothing. For that case
|
||||
// you'd need to implement a ring buffer to store pending key presses.
|
||||
xkb_keycode_t prev_handled_press = last_handled_press_keycode;
|
||||
|
||||
6
glfw/xkb_glfw.h
vendored
6
glfw/xkb_glfw.h
vendored
@@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.3 XKB - www.glfw.org
|
||||
// GLFW 3.4 XKB - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2018 Kovid Goyal <kovid@kovidgoyal.net>
|
||||
//
|
||||
@@ -67,8 +67,8 @@ typedef struct {
|
||||
|
||||
#ifdef _GLFW_X11
|
||||
int32_t keyboard_device_id;
|
||||
bool available;
|
||||
bool detectable;
|
||||
bool available;
|
||||
bool detectable;
|
||||
int majorOpcode;
|
||||
int eventBase;
|
||||
int errorBase;
|
||||
|
||||
@@ -20,7 +20,7 @@ from ..tui.loop import Loop
|
||||
from ..tui.operations import faint, styled
|
||||
|
||||
URL_PREFIXES = 'http https file ftp'.split()
|
||||
HINT_ALPHABET = string.digits + string.ascii_lowercase
|
||||
DEFAULT_HINT_ALPHABET = string.digits + string.ascii_lowercase
|
||||
screen_size = screen_size_function()
|
||||
|
||||
|
||||
@@ -34,21 +34,26 @@ class Mark:
|
||||
|
||||
|
||||
@lru_cache(maxsize=2048)
|
||||
def encode_hint(num):
|
||||
def encode_hint(num, alphabet):
|
||||
res = ''
|
||||
d = len(HINT_ALPHABET)
|
||||
d = len(alphabet)
|
||||
while not res or num > 0:
|
||||
num, i = divmod(num, d)
|
||||
res = HINT_ALPHABET[i] + res
|
||||
res = alphabet[i] + res
|
||||
return res
|
||||
|
||||
|
||||
def decode_hint(x):
|
||||
return int(x, 36)
|
||||
def decode_hint(x, alphabet=DEFAULT_HINT_ALPHABET):
|
||||
base = len(alphabet)
|
||||
index_map = {c: i for i, c in enumerate(alphabet)}
|
||||
i = 0
|
||||
for char in x:
|
||||
i = i * base + index_map[char]
|
||||
return i
|
||||
|
||||
|
||||
def highlight_mark(m, text, current_input):
|
||||
hint = encode_hint(m.index)
|
||||
def highlight_mark(m, text, current_input, alphabet):
|
||||
hint = encode_hint(m.index, alphabet)
|
||||
if current_input and not hint.startswith(current_input):
|
||||
return faint(text)
|
||||
hint = hint[len(current_input):] or ' '
|
||||
@@ -63,11 +68,11 @@ def highlight_mark(m, text, current_input):
|
||||
)
|
||||
|
||||
|
||||
def render(text, current_input, all_marks, ignore_mark_indices):
|
||||
def render(text, current_input, all_marks, ignore_mark_indices, alphabet):
|
||||
for mark in reversed(all_marks):
|
||||
if mark.index in ignore_mark_indices:
|
||||
continue
|
||||
mtext = highlight_mark(mark, text[mark.start:mark.end], current_input)
|
||||
mtext = highlight_mark(mark, text[mark.start:mark.end], current_input, alphabet)
|
||||
text = text[:mark.start] + mtext + text[mark.end:]
|
||||
|
||||
text = text.replace('\0', '')
|
||||
@@ -79,6 +84,7 @@ class Hints(Handler):
|
||||
|
||||
def __init__(self, text, all_marks, index_map, args):
|
||||
self.text, self.index_map = text, index_map
|
||||
self.alphabet = args.alphabet or DEFAULT_HINT_ALPHABET
|
||||
self.all_marks = all_marks
|
||||
self.ignore_mark_indices = set()
|
||||
self.args = args
|
||||
@@ -111,13 +117,13 @@ class Hints(Handler):
|
||||
def on_text(self, text, in_bracketed_paste):
|
||||
changed = False
|
||||
for c in text:
|
||||
if c in HINT_ALPHABET:
|
||||
if c in self.alphabet:
|
||||
self.current_input += c
|
||||
changed = True
|
||||
if changed:
|
||||
matches = [
|
||||
m for idx, m in self.index_map.items()
|
||||
if encode_hint(idx).startswith(self.current_input)
|
||||
if encode_hint(idx, self.alphabet).startswith(self.current_input)
|
||||
]
|
||||
if len(matches) == 1:
|
||||
self.chosen.append(matches[0].text + self.match_suffix)
|
||||
@@ -137,7 +143,7 @@ class Hints(Handler):
|
||||
self.draw_screen()
|
||||
elif key_event is enter_key and self.current_input:
|
||||
try:
|
||||
idx = decode_hint(self.current_input)
|
||||
idx = decode_hint(self.current_input, self.alphabet)
|
||||
self.chosen.append(self.index_map[idx].text + self.match_suffix)
|
||||
self.ignore_mark_indices.add(idx)
|
||||
except Exception:
|
||||
@@ -164,7 +170,7 @@ class Hints(Handler):
|
||||
|
||||
def draw_screen(self):
|
||||
if self.current_text is None:
|
||||
self.current_text = render(self.text, self.current_input, self.all_marks, self.ignore_mark_indices)
|
||||
self.current_text = render(self.text, self.current_input, self.all_marks, self.ignore_mark_indices, self.alphabet)
|
||||
self.cmd.clear_screen()
|
||||
self.write(self.current_text)
|
||||
|
||||
@@ -246,7 +252,7 @@ def run_loop(args, text, all_marks, index_map):
|
||||
handler = Hints(text, all_marks, index_map, args)
|
||||
loop.loop(handler)
|
||||
if handler.chosen and loop.return_code == 0:
|
||||
return {'match': handler.chosen, 'program': args.program,
|
||||
return {'match': handler.chosen, 'programs': args.program,
|
||||
'multiple_joiner': args.multiple_joiner,
|
||||
'type': args.type}
|
||||
raise SystemExit(loop.return_code)
|
||||
@@ -333,10 +339,12 @@ def run(args, text):
|
||||
# CLI {{{
|
||||
OPTIONS = r'''
|
||||
--program
|
||||
default=default
|
||||
type=list
|
||||
What program to use to open matched text. Defaults to the default open program
|
||||
for the operating system. Use a value of :file:`-` to paste the match into the
|
||||
for the operating system. Use a value of :file:`-` to paste the match into the
|
||||
terminal window instead. A value of :file:`@` will copy the match to the clipboard.
|
||||
A value of :file:`default` will run the default open program. Can be specified
|
||||
multiple times to run multiple programs.
|
||||
|
||||
|
||||
--type
|
||||
@@ -348,11 +356,11 @@ The type of text to search for.
|
||||
--regex
|
||||
default=(?m)^\s*(.+)\s*$
|
||||
The regular expression to use when :option:`kitty +kitten hints --type`=regex.
|
||||
If you specify a group in the regular expression only the group
|
||||
will be matched. This allow you to match text ignoring a prefix/suffix, as
|
||||
needed. The default expression matches lines. To match text over
|
||||
multiple lines you should prefix the regular expression with :code:`(?ms)`,
|
||||
which turns on MULTILINE and DOTALL modes for the regex engine.
|
||||
The regular expression is in python syntax. If you specify a group in
|
||||
the regular expression only the group will be matched. This allow you to match
|
||||
text ignoring a prefix/suffix, as needed. The default expression matches lines.
|
||||
To match text over multiple lines you should prefix the regular expression with
|
||||
:code:`(?ms)`, which turns on MULTILINE and DOTALL modes for the regex engine.
|
||||
|
||||
|
||||
--url-prefixes
|
||||
@@ -362,7 +370,7 @@ Comma separated list of recognized URL prefixes.
|
||||
|
||||
--word-characters
|
||||
Characters to consider as part of a word. In addition, all characters marked as
|
||||
alpha-numeric in the unicode database will be considered as word characters.
|
||||
alphanumeric in the unicode database will be considered as word characters.
|
||||
Defaults to the select_by_word_characters setting from kitty.conf.
|
||||
|
||||
|
||||
@@ -401,6 +409,15 @@ default=1
|
||||
type=int
|
||||
The offset (from zero) at which to start hint numbering. Note that only numbers
|
||||
greater than or equal to zero are respected.
|
||||
|
||||
|
||||
--alphabet
|
||||
The list of characters to use for hints. The default is to use numbers and lowercase
|
||||
English alphabets. Specify your preference as a string of characters. Note that
|
||||
unless you specify the hints offset as zero the first match will be highlighted with
|
||||
the second character you specify.
|
||||
|
||||
|
||||
'''.format(','.join(sorted(URL_PREFIXES))).format
|
||||
help_text = 'Select text from the screen using the keyboard. Defaults to searching for URLs.'
|
||||
usage = ''
|
||||
@@ -430,12 +447,11 @@ def main(args):
|
||||
if items:
|
||||
print('Extra command line arguments present: {}'.format(' '.join(items)), file=sys.stderr)
|
||||
input(_('Press Enter to quit'))
|
||||
return
|
||||
return run(args, text)
|
||||
|
||||
|
||||
def handle_result(args, data, target_window_id, boss):
|
||||
program = data['program']
|
||||
programs = data['programs'] or ('default',)
|
||||
matches = tuple(filter(None, data['match']))
|
||||
joiner = data['multiple_joiner']
|
||||
try:
|
||||
@@ -444,6 +460,7 @@ def handle_result(args, data, target_window_id, boss):
|
||||
is_int = None
|
||||
text_type = data['type']
|
||||
|
||||
@lru_cache()
|
||||
def joined_text():
|
||||
if is_int is not None:
|
||||
try:
|
||||
@@ -459,20 +476,21 @@ def handle_result(args, data, target_window_id, boss):
|
||||
q = {'newline': '\n\r', 'space': ' '}.get(joiner, '')
|
||||
return q.join(matches)
|
||||
|
||||
if program == '-':
|
||||
w = boss.window_id_map.get(target_window_id)
|
||||
if w is not None:
|
||||
w.paste(joined_text())
|
||||
elif program == '@':
|
||||
set_clipboard_string(joined_text())
|
||||
else:
|
||||
cwd = None
|
||||
w = boss.window_id_map.get(target_window_id)
|
||||
if w is not None:
|
||||
cwd = w.cwd_of_child
|
||||
program = None if program == 'default' else program
|
||||
for m in matches:
|
||||
boss.open_url(m, program, cwd=cwd)
|
||||
for program in programs:
|
||||
if program == '-':
|
||||
w = boss.window_id_map.get(target_window_id)
|
||||
if w is not None:
|
||||
w.paste(joined_text())
|
||||
elif program == '@':
|
||||
set_clipboard_string(joined_text())
|
||||
else:
|
||||
cwd = None
|
||||
w = boss.window_id_map.get(target_window_id)
|
||||
if w is not None:
|
||||
cwd = w.cwd_of_child
|
||||
program = None if program == 'default' else program
|
||||
for m in matches:
|
||||
boss.open_url(m, program, cwd=cwd)
|
||||
|
||||
|
||||
handle_result.type_of_input = 'screen'
|
||||
|
||||
@@ -194,11 +194,13 @@ def process(path, args, is_tempfile):
|
||||
available_height = args.place.height * (ss.height / ss.rows) if args.place else 10 * m.height
|
||||
needs_scaling = m.width > available_width or m.height > available_height
|
||||
needs_scaling = needs_scaling or args.scale_up
|
||||
file_removed = False
|
||||
if m.fmt == 'png' and not needs_scaling:
|
||||
outfile = path
|
||||
transmit_mode = 't' if is_tempfile else 'f'
|
||||
fmt = 100
|
||||
width, height = m.width, m.height
|
||||
file_removed = transmit_mode == 't'
|
||||
else:
|
||||
fmt = 24 if m.mode == 'rgb' else 32
|
||||
transmit_mode = 't'
|
||||
@@ -206,6 +208,7 @@ def process(path, args, is_tempfile):
|
||||
show(outfile, width, height, fmt, transmit_mode, align=args.align, place=args.place)
|
||||
if not args.place:
|
||||
print() # ensure cursor is on a new line
|
||||
return file_removed
|
||||
|
||||
|
||||
def scan(d):
|
||||
@@ -272,6 +275,7 @@ usage = 'image-file-or-url-or-directory ...'
|
||||
|
||||
def process_single_item(item, args, url_pat=None, maybe_dir=True):
|
||||
is_tempfile = False
|
||||
file_removed = False
|
||||
try:
|
||||
if isinstance(item, bytes):
|
||||
tf = NamedTemporaryFile(prefix='stdin-image-data-', delete=False)
|
||||
@@ -287,7 +291,7 @@ def process_single_item(item, args, url_pat=None, maybe_dir=True):
|
||||
raise SystemExit('Failed to download image at URL: {} with error: {}'.format(item, e))
|
||||
item = tf.name
|
||||
is_tempfile = True
|
||||
process(item, args, is_tempfile)
|
||||
file_removed = process(item, args, is_tempfile)
|
||||
elif item.lower().startswith('file://'):
|
||||
from urllib.parse import urlparse
|
||||
from urllib.request import url2pathname
|
||||
@@ -297,15 +301,15 @@ def process_single_item(item, args, url_pat=None, maybe_dir=True):
|
||||
else:
|
||||
item = item.path
|
||||
item = url2pathname(item)
|
||||
process(item, args, is_tempfile)
|
||||
file_removed = process(item, args, is_tempfile)
|
||||
else:
|
||||
if maybe_dir and os.path.isdir(item):
|
||||
for (x, mt) in scan(item):
|
||||
process_single_item(x, args, url_pat=None, maybe_dir=False)
|
||||
else:
|
||||
process(item, args, is_tempfile)
|
||||
file_removed = process(item, args, is_tempfile)
|
||||
finally:
|
||||
if is_tempfile:
|
||||
if is_tempfile and not file_removed:
|
||||
os.remove(item)
|
||||
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ def parse_ssh_args(args):
|
||||
|
||||
|
||||
def quote(x):
|
||||
# we have to escape unbalanced quotes and other unparseable
|
||||
# we have to escape unbalanced quotes and other unparsable
|
||||
# args as they will break the shell script
|
||||
# But we do not want to quote things like * or 'echo hello'
|
||||
# See https://github.com/kovidgoyal/kitty/issues/1787
|
||||
|
||||
@@ -249,7 +249,8 @@ class ImageManager:
|
||||
cmd, standard_b64encode(rgba_path.encode(fsenc)))
|
||||
else:
|
||||
import zlib
|
||||
data = open(rgba_path, 'rb').read()
|
||||
with open(rgba_path, 'rb') as f:
|
||||
data = f.read()
|
||||
cmd['S'] = len(data)
|
||||
data = zlib.compress(data)
|
||||
cmd['o'] = 'z'
|
||||
|
||||
41478
kittens/unicode_input/names.h
generated
41478
kittens/unicode_input/names.h
generated
File diff suppressed because one or more lines are too long
@@ -619,12 +619,12 @@ class Boss:
|
||||
if tm is not None:
|
||||
tm.update_tab_bar_data()
|
||||
|
||||
def on_drop(self, os_window_id, paths):
|
||||
def on_drop(self, os_window_id, strings):
|
||||
tm = self.os_window_map.get(os_window_id)
|
||||
if tm is not None:
|
||||
w = tm.active_window
|
||||
if w is not None:
|
||||
w.paste('\n'.join(paths))
|
||||
w.paste('\n'.join(strings))
|
||||
|
||||
def on_os_window_closed(self, os_window_id, viewport_width, viewport_height):
|
||||
self.cached_values['window-size'] = viewport_width, viewport_height
|
||||
@@ -716,7 +716,9 @@ class Boss:
|
||||
},
|
||||
cwd=w.cwd_of_child,
|
||||
overlay_for=w.id
|
||||
))
|
||||
),
|
||||
copy_colors_from=w
|
||||
)
|
||||
overlay_window.action_on_close = partial(self.on_kitten_finish, w.id, end_kitten)
|
||||
return overlay_window
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ vec3 choose_color(float q, vec3 a, vec3 b) {
|
||||
return mix(b, a, q);
|
||||
}
|
||||
|
||||
float are_integers_equal(float a, float b) { // return 1 iff equal otherwise 0
|
||||
float are_integers_equal(float a, float b) { // return 1 if equal otherwise 0
|
||||
float delta = abs(a - b); // delta can be 0, 1 or larger
|
||||
return step(delta, 0.5); // 0 if 0.5 < delta else 1
|
||||
}
|
||||
@@ -172,13 +172,15 @@ void main() {
|
||||
foreground = color_to_vec(resolved_fg);
|
||||
float has_dim = float((text_attrs >> DIM_SHIFT) & ONE);
|
||||
effective_text_alpha = inactive_text_alpha * mix(1.0, dim_opacity, has_dim);
|
||||
#ifdef USE_SELECTION_FG
|
||||
// Selection
|
||||
foreground = choose_color(float(is_selected & ONE), color_to_vec(highlight_fg), foreground);
|
||||
#endif
|
||||
// Underline and strike through (rendered via sprites)
|
||||
float in_url = float((is_selected & TWO) >> 1);
|
||||
decoration_fg = choose_color(in_url, color_to_vec(url_color), to_color(colors[2], resolved_fg));
|
||||
#ifdef USE_SELECTION_FG
|
||||
// Selection
|
||||
vec3 selection_color = color_to_vec(highlight_fg);
|
||||
foreground = choose_color(float(is_selected & ONE), selection_color, foreground);
|
||||
decoration_fg = choose_color(float(is_selected & ONE), selection_color, decoration_fg);
|
||||
#endif
|
||||
// Underline and strike through (rendered via sprites)
|
||||
underline_pos = choose_color(in_url, to_sprite_pos(pos, url_style, ZERO, ZERO), to_sprite_pos(pos, (text_attrs >> DECORATION_SHIFT) & THREE, ZERO, ZERO));
|
||||
strike_pos = to_sprite_pos(pos, ((text_attrs >> STRIKE_SHIFT) & ONE) * FOUR, ZERO, ZERO);
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ dealloc(ChildMonitor* self) {
|
||||
|
||||
static void
|
||||
wakeup_io_loop(ChildMonitor *self, bool in_signal_handler) {
|
||||
wakeup_loop(&self->io_loop_data, in_signal_handler);
|
||||
wakeup_loop(&self->io_loop_data, in_signal_handler, "io_loop");
|
||||
}
|
||||
|
||||
static void* io_loop(void *data);
|
||||
@@ -518,7 +518,7 @@ update_window_title(Window *w, OSWindow *os_window) {
|
||||
Py_INCREF(os_window->window_title);
|
||||
set_os_window_title(os_window, PyUnicode_AsUTF8(w->title));
|
||||
#ifdef __APPLE__
|
||||
if (os_window->is_focused && OPT(macos_show_window_title_in_menubar)) cocoa_update_menu_bar_title(w->title);
|
||||
if (os_window->is_focused && (OPT(macos_show_window_title_in) & MENUBAR)) cocoa_update_menu_bar_title(w->title);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
@@ -526,7 +526,7 @@ update_window_title(Window *w, OSWindow *os_window) {
|
||||
}
|
||||
|
||||
static inline bool
|
||||
prepare_to_render_os_window(OSWindow *os_window, double now, unsigned int *active_window_id, color_type *active_window_bg, unsigned int *num_visible_windows) {
|
||||
prepare_to_render_os_window(OSWindow *os_window, double now, unsigned int *active_window_id, color_type *active_window_bg, unsigned int *num_visible_windows, bool *all_windows_have_same_bg) {
|
||||
#define TD os_window->tab_bar_render_data
|
||||
bool needs_render = os_window->needs_render;
|
||||
os_window->needs_render = false;
|
||||
@@ -543,11 +543,17 @@ prepare_to_render_os_window(OSWindow *os_window, double now, unsigned int *activ
|
||||
}
|
||||
Tab *tab = os_window->tabs + os_window->active_tab;
|
||||
*active_window_bg = OPT(background);
|
||||
*all_windows_have_same_bg = true;
|
||||
*num_visible_windows = 0;
|
||||
color_type first_window_bg = 0;
|
||||
for (unsigned int i = 0; i < tab->num_windows; i++) {
|
||||
Window *w = tab->windows + i;
|
||||
#define WD w->render_data
|
||||
if (w->visible && WD.screen) {
|
||||
*num_visible_windows += 1;
|
||||
color_type window_bg = colorprofile_to_color(WD.screen->color_profile, WD.screen->color_profile->overridden.default_bg, WD.screen->color_profile->configured.default_bg);
|
||||
if (*num_visible_windows == 1) first_window_bg = window_bg;
|
||||
if (first_window_bg != window_bg) all_windows_have_same_bg = false;
|
||||
if (w->last_drag_scroll_at > 0) {
|
||||
if (now - w->last_drag_scroll_at >= 0.02) {
|
||||
if (drag_scroll(w, os_window)) {
|
||||
@@ -563,7 +569,7 @@ prepare_to_render_os_window(OSWindow *os_window, double now, unsigned int *activ
|
||||
collect_cursor_info(&WD.screen->cursor_render_info, w, now, os_window);
|
||||
if (w->cursor_visible_at_last_render != WD.screen->cursor_render_info.is_visible || w->last_cursor_x != WD.screen->cursor_render_info.x || w->last_cursor_y != WD.screen->cursor_render_info.y || w->last_cursor_shape != WD.screen->cursor_render_info.shape) needs_render = true;
|
||||
update_window_title(w, os_window);
|
||||
*active_window_bg = colorprofile_to_color(WD.screen->color_profile, WD.screen->color_profile->overridden.default_bg, WD.screen->color_profile->configured.default_bg);
|
||||
*active_window_bg = window_bg;
|
||||
} else WD.screen->cursor_render_info.is_visible = false;
|
||||
if (send_cell_data_to_gpu(WD.vao_idx, WD.gvao_idx, WD.xstart, WD.ystart, WD.dx, WD.dy, WD.screen, os_window)) needs_render = true;
|
||||
if (WD.screen->start_visual_bell_at != 0) needs_render = true;
|
||||
@@ -573,7 +579,7 @@ prepare_to_render_os_window(OSWindow *os_window, double now, unsigned int *activ
|
||||
}
|
||||
|
||||
static inline void
|
||||
render_os_window(OSWindow *os_window, double now, unsigned int active_window_id, color_type active_window_bg, unsigned int num_visible_windows) {
|
||||
render_os_window(OSWindow *os_window, double now, unsigned int active_window_id, color_type active_window_bg, unsigned int num_visible_windows, bool all_windows_have_same_bg) {
|
||||
// ensure all pixels are cleared to background color at least once in every buffer
|
||||
if (os_window->clear_count++ < 3) blank_os_window(os_window);
|
||||
Tab *tab = os_window->tabs + os_window->active_tab;
|
||||
@@ -585,7 +591,7 @@ render_os_window(OSWindow *os_window, double now, unsigned int active_window_id,
|
||||
y_ratio = os_window->viewport_height / (double) os_window->live_resize.height;
|
||||
}
|
||||
if (!static_live_resize_in_progress) {
|
||||
draw_borders(br->vao_idx, br->num_border_rects, br->rect_buf, br->is_dirty, os_window->viewport_width, os_window->viewport_height, active_window_bg, num_visible_windows, os_window);
|
||||
draw_borders(br->vao_idx, br->num_border_rects, br->rect_buf, br->is_dirty, os_window->viewport_width, os_window->viewport_height, active_window_bg, num_visible_windows, all_windows_have_same_bg, os_window);
|
||||
br->is_dirty = false;
|
||||
}
|
||||
if (TD.screen && os_window->num_tabs >= OPT(tab_bar_min_tabs)) draw_cells(TD.vao_idx, 0, TD.xstart, TD.ystart, TD.dx * x_ratio, TD.dy * y_ratio, TD.screen, os_window, true, false);
|
||||
@@ -595,7 +601,7 @@ render_os_window(OSWindow *os_window, double now, unsigned int active_window_id,
|
||||
bool is_active_window = i == tab->active_window;
|
||||
draw_cells(WD.vao_idx, WD.gvao_idx, WD.xstart, WD.ystart, WD.dx * x_ratio, WD.dy * y_ratio, WD.screen, os_window, is_active_window, true);
|
||||
if (WD.screen->start_visual_bell_at != 0) {
|
||||
double bell_left = global_state.opts.visual_bell_duration - (now - WD.screen->start_visual_bell_at);
|
||||
double bell_left = OPT(visual_bell_duration) - (now - WD.screen->start_visual_bell_at);
|
||||
set_maximum_wait(bell_left);
|
||||
}
|
||||
w->cursor_visible_at_last_render = WD.screen->cursor_render_info.is_visible; w->last_cursor_x = WD.screen->cursor_render_info.x; w->last_cursor_y = WD.screen->cursor_render_info.y; w->last_cursor_shape = WD.screen->cursor_render_info.shape;
|
||||
@@ -676,11 +682,12 @@ render(double now, bool input_read) {
|
||||
needs_render = true;
|
||||
}
|
||||
unsigned int active_window_id = 0, num_visible_windows = 0;
|
||||
bool all_windows_have_same_bg;
|
||||
color_type active_window_bg = 0;
|
||||
if (!w->fonts_data) { log_error("No fonts data found for window id: %llu", w->id); continue; }
|
||||
if (prepare_to_render_os_window(w, now, &active_window_id, &active_window_bg, &num_visible_windows)) needs_render = true;
|
||||
if (prepare_to_render_os_window(w, now, &active_window_id, &active_window_bg, &num_visible_windows, &all_windows_have_same_bg)) needs_render = true;
|
||||
if (w->last_active_window_id != active_window_id || w->last_active_tab != w->active_tab || w->focused_at_last_render != w->is_focused) needs_render = true;
|
||||
if (needs_render) render_os_window(w, now, active_window_id, active_window_bg, num_visible_windows);
|
||||
if (needs_render) render_os_window(w, now, active_window_id, active_window_bg, num_visible_windows, all_windows_have_same_bg);
|
||||
}
|
||||
last_render_at = now;
|
||||
#undef TD
|
||||
@@ -1414,7 +1421,7 @@ prune_finished_writes(void) {
|
||||
|
||||
static void
|
||||
wakeup_talk_loop(bool in_signal_handler) {
|
||||
wakeup_loop(&talk_data.loop_data, in_signal_handler);
|
||||
if (talk_thread_started) wakeup_loop(&talk_data.loop_data, in_signal_handler, "talk_loop");
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
||||
@@ -30,14 +30,16 @@ if is_macos:
|
||||
else:
|
||||
|
||||
def cmdline_of_process(pid):
|
||||
return list(filter(None, open('/proc/{}/cmdline'.format(pid), 'rb').read().decode('utf-8').split('\0')))
|
||||
with open('/proc/{}/cmdline'.format(pid), 'rb') as f:
|
||||
return list(filter(None, f.read().decode('utf-8').split('\0')))
|
||||
|
||||
def cwd_of_process(pid):
|
||||
ans = '/proc/{}/cwd'.format(pid)
|
||||
return os.path.realpath(ans)
|
||||
|
||||
def _environ_of_process(pid):
|
||||
return open('/proc/{}/environ'.format(pid), 'rb').read().decode('utf-8')
|
||||
with open('/proc/{}/environ'.format(pid), 'rb') as f:
|
||||
return f.read().decode('utf-8')
|
||||
|
||||
def process_group_map():
|
||||
ans = defaultdict(list)
|
||||
@@ -47,7 +49,8 @@ else:
|
||||
except Exception:
|
||||
continue
|
||||
try:
|
||||
raw = open('/proc/' + x + '/stat', 'rb').read().decode('utf-8')
|
||||
with open('/proc/' + x + '/stat', 'rb') as f:
|
||||
raw = f.read().decode('utf-8')
|
||||
except EnvironmentError:
|
||||
continue
|
||||
try:
|
||||
@@ -118,6 +121,10 @@ def remove_cloexec(fd):
|
||||
fcntl.fcntl(fd, fcntl.F_SETFD, fcntl.fcntl(fd, fcntl.F_GETFD) & ~fcntl.FD_CLOEXEC)
|
||||
|
||||
|
||||
def remove_blocking(fd):
|
||||
os.set_blocking(fd, False)
|
||||
|
||||
|
||||
def default_env():
|
||||
try:
|
||||
return default_env.env
|
||||
@@ -132,6 +139,13 @@ def set_default_env(val=None):
|
||||
default_env.env = env
|
||||
|
||||
|
||||
def openpty():
|
||||
master, slave = os.openpty() # Note that master and slave are in blocking mode
|
||||
remove_cloexec(slave)
|
||||
fast_data_types.set_iutf8_fd(master, True)
|
||||
return master, slave
|
||||
|
||||
|
||||
class Child:
|
||||
|
||||
child_fd = pid = None
|
||||
@@ -166,7 +180,7 @@ class Child:
|
||||
env['TERM'] = self.opts.term
|
||||
env['COLORTERM'] = 'truecolor'
|
||||
if self.cwd:
|
||||
# needed incase cwd is a symlink, in which case shells
|
||||
# needed in case cwd is a symlink, in which case shells
|
||||
# can use it to display the current directory name rather
|
||||
# than the resolved path
|
||||
env['PWD'] = self.cwd
|
||||
@@ -178,9 +192,7 @@ class Child:
|
||||
if self.forked:
|
||||
return
|
||||
self.forked = True
|
||||
master, slave = os.openpty() # Note that master and slave are in blocking mode
|
||||
remove_cloexec(slave)
|
||||
fast_data_types.set_iutf8_fd(master, True)
|
||||
master, slave = openpty()
|
||||
stdin, self.stdin = self.stdin, None
|
||||
ready_read_fd, ready_write_fd = os.pipe()
|
||||
remove_cloexec(ready_read_fd)
|
||||
@@ -194,8 +206,20 @@ class Child:
|
||||
argv = list(self.argv)
|
||||
exe = argv[0]
|
||||
if is_macos and exe == shell_path:
|
||||
# Some macOS machines need the shell to have argv[0] prefixed by
|
||||
# hyphen, see https://github.com/kovidgoyal/kitty/issues/247
|
||||
# bash will only source ~/.bash_profile if it detects it is a login
|
||||
# shell (see the invocation section of the bash man page), which it
|
||||
# does if argv[0] is prefixed by a hyphen see
|
||||
# https://github.com/kovidgoyal/kitty/issues/247
|
||||
# it is apparently common to use ~/.bash_profile instead of the
|
||||
# more correct ~/.bashrc on macOS to setup env vars, so if
|
||||
# the default shell is used prefix argv[0] by '-'
|
||||
#
|
||||
# it is arguable whether graphical terminals should start shells
|
||||
# in login mode in general, there are at least a few Linux users
|
||||
# that also make this incorrect assumption, see for example
|
||||
# https://github.com/kovidgoyal/kitty/issues/1870
|
||||
# xterm, urxvt, konsole and gnome-terminal do not do it in my
|
||||
# testing.
|
||||
argv[0] = ('-' + exe.split('/')[-1])
|
||||
pid = fast_data_types.spawn(exe, self.cwd, tuple(argv), env, master, slave, stdin_read_fd, stdin_write_fd, ready_read_fd, ready_write_fd)
|
||||
os.close(slave)
|
||||
@@ -206,7 +230,7 @@ class Child:
|
||||
fast_data_types.thread_write(stdin_write_fd, stdin)
|
||||
os.close(ready_read_fd)
|
||||
self.terminal_ready_fd = ready_write_fd
|
||||
fcntl.fcntl(self.child_fd, fcntl.F_SETFL, fcntl.fcntl(self.child_fd, fcntl.F_GETFL) | os.O_NONBLOCK)
|
||||
remove_blocking(self.child_fd)
|
||||
return pid
|
||||
|
||||
def mark_terminal_ready(self):
|
||||
|
||||
@@ -514,7 +514,7 @@ Detach from the controlling terminal, if any
|
||||
|
||||
--session
|
||||
Path to a file containing the startup :italic:`session` (tabs, windows, layout, programs).
|
||||
See the README file for details and an example.
|
||||
Use - to read from STDIN. See the README file for details and an example.
|
||||
|
||||
|
||||
--hold
|
||||
@@ -728,9 +728,11 @@ def create_opts(args, debug_config=False, accumulate_bad_lines=None):
|
||||
import subprocess
|
||||
print(' '.join(subprocess.check_output(['sw_vers']).decode('utf-8').splitlines()).strip())
|
||||
if os.path.exists('/etc/issue'):
|
||||
print(open('/etc/issue', encoding='utf-8', errors='replace').read().strip())
|
||||
with open('/etc/issue', encoding='utf-8', errors='replace') as f:
|
||||
print(f.read().strip())
|
||||
if os.path.exists('/etc/lsb-release'):
|
||||
print(open('/etc/lsb-release', encoding='utf-8', errors='replace').read().strip())
|
||||
with open('/etc/lsb-release', encoding='utf-8', errors='replace') as f:
|
||||
print(f.read().strip())
|
||||
config = tuple(x for x in config if os.path.exists(x))
|
||||
if config:
|
||||
print(green('Loaded config files:'), ', '.join(config))
|
||||
|
||||
@@ -157,7 +157,8 @@ def replay(raw):
|
||||
|
||||
|
||||
def main(path):
|
||||
raw = open(path).read()
|
||||
with open(path) as f:
|
||||
raw = f.read()
|
||||
replay(raw)
|
||||
with suppress(EOFError, KeyboardInterrupt):
|
||||
input()
|
||||
|
||||
@@ -999,7 +999,7 @@ def cmd_set_background_opacity(global_opts, opts, args):
|
||||
def set_background_opacity(boss, window, payload):
|
||||
if not boss.opts.dynamic_background_opacity:
|
||||
raise OpacityError('You must turn on the dynamic_background_opacity option in kitty.conf to be able to set background opacity')
|
||||
windows = windows_for_payload(payload)
|
||||
windows = windows_for_payload(boss, window, payload)
|
||||
for os_window_id in {w.os_window_id for w in windows}:
|
||||
boss._set_os_window_background_opacity(os_window_id, payload['opacity'])
|
||||
# }}}
|
||||
|
||||
@@ -477,6 +477,17 @@ cleanup() {
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void
|
||||
cocoa_hide_window_title(void *w)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
NSWindow *window = (NSWindow*)w;
|
||||
[window setTitleVisibility:NSWindowTitleHidden];
|
||||
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
static PyMethodDef module_methods[] = {
|
||||
{"cocoa_get_lang", (PyCFunction)cocoa_get_lang, METH_NOARGS, ""},
|
||||
{"cocoa_set_new_window_trigger", (PyCFunction)cocoa_set_new_window_trigger, METH_VARARGS, ""},
|
||||
|
||||
@@ -36,12 +36,12 @@ init_FG_BG_table(void) {
|
||||
// colors 16..232: the 6x6x6 color cube
|
||||
const uint8_t valuerange[6] = {0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff};
|
||||
uint8_t i, j=16;
|
||||
for(i = 0; i < 217; i++, j++) {
|
||||
for(i = 0; i < 216; i++, j++) {
|
||||
uint8_t r = valuerange[(i / 36) % 6], g = valuerange[(i / 6) % 6], b = valuerange[i % 6];
|
||||
FG_BG_256[j] = (r << 16) | (g << 8) | b;
|
||||
}
|
||||
// colors 233..255: grayscale
|
||||
for(i = 1; i < 24; i++, j++) {
|
||||
// colors 232..255: grayscale
|
||||
for(i = 0; i < 24; i++, j++) {
|
||||
uint8_t v = 8 + i * 10;
|
||||
FG_BG_256[j] = (v << 16) | (v << 8) | v;
|
||||
}
|
||||
@@ -98,6 +98,15 @@ update_ansi_color_table(ColorProfile *self, PyObject *val) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
void
|
||||
copy_color_profile(ColorProfile *dest, ColorProfile *src) {
|
||||
memcpy(dest->color_table, src->color_table, sizeof(dest->color_table));
|
||||
memcpy(dest->orig_color_table, src->orig_color_table, sizeof(dest->color_table));
|
||||
memcpy(&dest->configured, &src->configured, sizeof(dest->configured));
|
||||
memcpy(&dest->overridden, &src->overridden, sizeof(dest->overridden));
|
||||
dest->dirty = true;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
patch_color_profiles(PyObject *module UNUSED, PyObject *args) {
|
||||
PyObject *spec, *profiles, *v; ColorProfile *self; int change_configured; PyObject *cursor_text_color;
|
||||
|
||||
@@ -185,11 +185,37 @@ def kitty_cli_opts(ans, prefix=None):
|
||||
|
||||
def complete_kitty_cli_arg(ans, opt, prefix):
|
||||
prefix = prefix or ''
|
||||
if opt and opt['dest'] == 'override':
|
||||
if not opt:
|
||||
return
|
||||
dest = opt['dest']
|
||||
if dest == 'override':
|
||||
from kitty.config import option_names_for_completion
|
||||
k = 'Config directives'
|
||||
ans.match_groups[k] = {k+'=': None for k in option_names_for_completion() if k.startswith(prefix)}
|
||||
ans.no_space_groups.add(k)
|
||||
elif dest == 'config':
|
||||
|
||||
def is_conf_file(x):
|
||||
if os.path.isdir(x):
|
||||
return True
|
||||
return x.lower().endswith('.conf')
|
||||
|
||||
complete_files_and_dirs(ans, prefix, files_group_name='Config files', predicate=is_conf_file)
|
||||
elif dest == 'session':
|
||||
complete_files_and_dirs(ans, prefix, files_group_name='Session files')
|
||||
elif dest == 'directory':
|
||||
complete_files_and_dirs(ans, prefix, files_group_name='Directories', predicate=os.path.isdir)
|
||||
elif dest == 'start_as':
|
||||
k = 'Start as'
|
||||
ans.match_groups[k] = {x: x for x in 'normal,fullscreen,maximized,minimized'.split(',') if x.startswith(prefix)}
|
||||
ans.no_space_groups.add(k)
|
||||
elif dest == 'listen_on':
|
||||
if ':' not in prefix:
|
||||
k = 'Address type'
|
||||
ans.match_groups[k] = {x: x for x in ('unix:', 'tcp:') if x.startswith(prefix)}
|
||||
ans.no_space_groups.add(k)
|
||||
elif prefix.startswith('unix:') and not prefix.startswith('@'):
|
||||
complete_files_and_dirs(ans, prefix[len('unix:'):], files_group_name='UNIX sockets', add_prefix='unix:')
|
||||
|
||||
|
||||
def complete_alias_map(ans, words, new_word, option_map, complete_args=None):
|
||||
@@ -273,9 +299,12 @@ def path_completion(prefix=''):
|
||||
return dirs, files
|
||||
|
||||
|
||||
def complete_files_and_dirs(ans, prefix, files_group_name='Files', predicate=None):
|
||||
def complete_files_and_dirs(ans, prefix, files_group_name='Files', predicate=None, add_prefix=None):
|
||||
dirs, files = path_completion(prefix or '')
|
||||
files = filter(predicate, files)
|
||||
if add_prefix:
|
||||
dirs = (add_prefix + x for x in dirs)
|
||||
files = (add_prefix + x for x in files)
|
||||
|
||||
if dirs:
|
||||
ans.match_groups['Directories'] = dict.fromkeys(dirs)
|
||||
|
||||
@@ -177,12 +177,11 @@ def load_config(Options, defaults, parse_config, merge_configs, *paths, override
|
||||
if not path:
|
||||
continue
|
||||
try:
|
||||
f = open(path, encoding='utf-8', errors='replace')
|
||||
with open(path, encoding='utf-8', errors='replace') as f:
|
||||
vals = parse_config(f)
|
||||
except FileNotFoundError:
|
||||
continue
|
||||
with f:
|
||||
vals = parse_config(f)
|
||||
ans = merge_configs(ans, vals)
|
||||
ans = merge_configs(ans, vals)
|
||||
if overrides is not None:
|
||||
vals = parse_config(overrides)
|
||||
ans = merge_configs(ans, vals)
|
||||
|
||||
@@ -20,21 +20,7 @@ from .conf.utils import (
|
||||
from .config_data import all_options, parse_mods, type_map
|
||||
from .constants import cache_dir, defconf, is_macos
|
||||
from .utils import log_error
|
||||
from .key_names import get_key_name_lookup
|
||||
|
||||
named_keys = {
|
||||
"'": 'APOSTROPHE',
|
||||
',': 'COMMA',
|
||||
'-': 'MINUS',
|
||||
'_': 'UNDERSCORE',
|
||||
'.': 'PERIOD',
|
||||
'/': 'SLASH',
|
||||
';': 'SEMICOLON',
|
||||
'=': 'EQUAL',
|
||||
'[': 'LEFT_BRACKET',
|
||||
']': 'RIGHT_BRACKET',
|
||||
'`': 'GRAVE_ACCENT'
|
||||
}
|
||||
from .key_names import get_key_name_lookup, key_name_aliases
|
||||
|
||||
|
||||
def parse_shortcut(sc):
|
||||
@@ -45,7 +31,7 @@ def parse_shortcut(sc):
|
||||
if mods is None:
|
||||
return None, None, None
|
||||
key = parts[-1].upper()
|
||||
key = getattr(defines, 'GLFW_KEY_' + named_keys.get(key, key), None)
|
||||
key = getattr(defines, 'GLFW_KEY_' + key_name_aliases.get(key, key), None)
|
||||
is_native = False
|
||||
if key is None:
|
||||
q = parts[-1]
|
||||
@@ -263,6 +249,21 @@ class KeyDefinition:
|
||||
self.trigger = defines.resolve_key_mods(kitty_mod, self.trigger[0]), self.trigger[1], self.trigger[2]
|
||||
self.rest = tuple((defines.resolve_key_mods(kitty_mod, mods), is_native, key) for mods, is_native, key in self.rest)
|
||||
|
||||
def resolve_kitten_aliases(self, aliases):
|
||||
if not self.action.args:
|
||||
return
|
||||
kitten = self.action.args[0]
|
||||
rest = self.action.args[1] if len(self.action.args) > 1 else ''
|
||||
changed = False
|
||||
for key, expanded in aliases.items():
|
||||
if key == kitten:
|
||||
changed = True
|
||||
kitten = expanded[0]
|
||||
if len(expanded) > 1:
|
||||
rest = expanded[1] + ' ' + rest
|
||||
if changed:
|
||||
self.action = self.action._replace(args=[kitten + (' ' + rest).rstrip()])
|
||||
|
||||
|
||||
def parse_key(val, key_definitions):
|
||||
parts = val.split(maxsplit=1)
|
||||
@@ -385,6 +386,13 @@ def handle_symbol_map(key, val, ans):
|
||||
ans['symbol_map'].update(parse_symbol_map(val))
|
||||
|
||||
|
||||
@special_handler
|
||||
def handle_kitten_alias(key, val, ans):
|
||||
parts = val.split(maxsplit=2)
|
||||
if len(parts) >= 2:
|
||||
ans['kitten_aliases'][parts[0]] = parts[1:]
|
||||
|
||||
|
||||
@special_handler
|
||||
def handle_send_text(key, val, ans):
|
||||
# For legacy compatibility
|
||||
@@ -407,6 +415,25 @@ def handle_deprecated_hide_window_decorations_aliases(key, val, ans):
|
||||
ans['hide_window_decorations'] = True
|
||||
|
||||
|
||||
@deprecated_handler('macos_show_window_title_in_menubar')
|
||||
def handle_deprecated_macos_show_window_title_in_menubar_alias(key, val, ans):
|
||||
if not hasattr(handle_deprecated_macos_show_window_title_in_menubar_alias, key):
|
||||
handle_deprecated_macos_show_window_title_in_menubar_alias.key = True
|
||||
log_error('The option {} is deprecated. Use macos_show_window_title_in menubar instead.'.format(key))
|
||||
macos_show_window_title_in = ans.get('macos_show_window_title_in', 'all')
|
||||
if to_bool(val):
|
||||
if macos_show_window_title_in == 'none':
|
||||
macos_show_window_title_in = 'menubar'
|
||||
elif macos_show_window_title_in == 'window':
|
||||
macos_show_window_title_in = 'all'
|
||||
else:
|
||||
if macos_show_window_title_in == 'all':
|
||||
macos_show_window_title_in = 'window'
|
||||
elif macos_show_window_title_in == 'menubar':
|
||||
macos_show_window_title_in = 'none'
|
||||
ans['macos_show_window_title_in'] = macos_show_window_title_in
|
||||
|
||||
|
||||
def expandvars(val, env):
|
||||
|
||||
def sub(m):
|
||||
@@ -444,7 +471,7 @@ def option_names_for_completion():
|
||||
|
||||
|
||||
def parse_config(lines, check_keys=True, accumulate_bad_lines=None):
|
||||
ans = {'symbol_map': {}, 'keymap': {}, 'sequence_map': {}, 'key_definitions': [], 'env': {}}
|
||||
ans = {'symbol_map': {}, 'keymap': {}, 'sequence_map': {}, 'key_definitions': [], 'env': {}, 'kitten_aliases': {}}
|
||||
parse_config_base(
|
||||
lines,
|
||||
defaults,
|
||||
@@ -594,8 +621,11 @@ def finalize_keys(opts):
|
||||
defns = []
|
||||
else:
|
||||
defns.append(d)
|
||||
kitten_aliases = opts.kitten_aliases
|
||||
for d in defns:
|
||||
d.resolve(opts.kitty_mod)
|
||||
if kitten_aliases and d.action.func == 'kitten':
|
||||
d.resolve_kitten_aliases(kitten_aliases)
|
||||
keymap = {}
|
||||
sequence_map = {}
|
||||
|
||||
|
||||
@@ -112,7 +112,9 @@ Here, the key name for the :kbd:`A` key is :kbd:`0x61` and you can use it with::
|
||||
to map :kbd:`ctrl+a` to something.
|
||||
|
||||
You can use the special action :code:`no_op` to unmap a keyboard shortcut that is
|
||||
assigned in the default configuration.
|
||||
assigned in the default configuration::
|
||||
|
||||
map kitty_mod+space no_op
|
||||
|
||||
You can combine multiple actions to be triggered by a single shortcut, using the
|
||||
syntax below::
|
||||
@@ -461,7 +463,7 @@ The modifiers to override mouse selection even when a terminal application has g
|
||||
|
||||
o('select_by_word_characters', ':@-./_~?&=%+#', long_text=_('''
|
||||
Characters considered part of a word when double clicking. In addition to these characters
|
||||
any character that is marked as an alpha-numeric character in the unicode
|
||||
any character that is marked as an alphanumeric character in the unicode
|
||||
database will be matched.'''))
|
||||
|
||||
o('click_interval', -1.0, option_type=float, long_text=_('''
|
||||
@@ -964,9 +966,15 @@ o('macos_traditional_fullscreen', False, long_text=_('''
|
||||
Use the traditional full-screen transition, that is faster, but less pretty.
|
||||
'''))
|
||||
|
||||
o('macos_show_window_title_in_menubar', True, long_text=_('''
|
||||
Show the title of the currently active window in the macOS
|
||||
menu-bar, making use of otherwise wasted space.'''))
|
||||
o('macos_show_window_title_in', 'all', option_type=choices('all', 'window', 'menubar', 'none'), long_text=_('''
|
||||
Show or hide the window title in the macOS window or menu-bar.
|
||||
A value of :code:`window` will show the title of the currently
|
||||
active window at the top of the macOS window. A value of
|
||||
:code:`menubar` will show the title of the currently active window
|
||||
in the macOS menu-bar, making use of otherwise wasted space.
|
||||
:code:`all` will show the title everywhere and :code:`none`
|
||||
hides the title in the window and the menu-bar.
|
||||
'''))
|
||||
|
||||
# Disabled by default because of https://github.com/kovidgoyal/kitty/issues/794
|
||||
o('macos_custom_beam_cursor', False, long_text=_('''
|
||||
@@ -992,6 +1000,14 @@ o('clear_all_shortcuts', False, long_text=_('''
|
||||
You can have kitty remove all shortcut definition seen up to this point. Useful, for
|
||||
instance, to remove the default shortcuts.'''))
|
||||
|
||||
o('kitten_alias', 'hints hints --hints-offset=0', add_to_default=False, long_text=_('''
|
||||
You can create aliases for kitten names, this allows overriding the defaults
|
||||
for kitten options and can also be used to shorten repeated mappings of the same
|
||||
kitten with a specific group of options. For example, the above alias
|
||||
changes the default value of :option:`kitty +kitten hints --hints-offset`
|
||||
to zero for all mappings, including the builtin ones.
|
||||
'''))
|
||||
|
||||
g('shortcuts.clipboard') # {{{
|
||||
k('copy_to_clipboard', 'kitty_mod+c', 'copy_to_clipboard', _('Copy to clipboard'), long_text=_('''
|
||||
There is also a :code:`copy_or_interrupt` action that can be optionally mapped to :kbd:`Ctrl+c`.
|
||||
@@ -1084,7 +1100,9 @@ with::
|
||||
'''))
|
||||
if is_macos:
|
||||
k('new_window', 'cmd+enter', 'new_window', _('New window'), add_to_docs=False)
|
||||
k('new_os_window', 'kitty_mod+n', 'new_os_window', _('New OS window'))
|
||||
k('new_os_window', 'kitty_mod+n', 'new_os_window', _('New OS window'), _(
|
||||
'Works like new_window above, except that it opens a top level OS kitty window.'
|
||||
' In particular you can use new_os_window_with_cwd to open a window with the current working directory.'))
|
||||
if is_macos:
|
||||
k('new_os_window', 'cmd+n', 'new_os_window', _('New OS window'), add_to_docs=False)
|
||||
k('close_window', 'kitty_mod+w', 'close_window', _('Close window'))
|
||||
|
||||
@@ -9,7 +9,7 @@ from collections import namedtuple
|
||||
from contextlib import suppress
|
||||
|
||||
appname = 'kitty'
|
||||
version = (0, 14, 3)
|
||||
version = (0, 14, 6)
|
||||
str_version = '.'.join(map(str, version))
|
||||
_plat = sys.platform.lower()
|
||||
is_macos = 'darwin' in _plat
|
||||
|
||||
@@ -437,7 +437,7 @@ render_glyphs(CTFontRef font, unsigned int width, unsigned int height, unsigned
|
||||
CGContextSetShouldSmoothFonts(render_ctx, true);
|
||||
CGContextSetGrayFillColor(render_ctx, 1, 1); // white glyphs
|
||||
CGContextSetGrayStrokeColor(render_ctx, 1, 1);
|
||||
CGContextSetLineWidth(render_ctx, global_state.opts.macos_thicken_font);
|
||||
CGContextSetLineWidth(render_ctx, OPT(macos_thicken_font));
|
||||
CGContextSetTextDrawingMode(render_ctx, kCGTextFillStroke);
|
||||
CGContextSetTextMatrix(render_ctx, CGAffineTransformIdentity);
|
||||
CGContextSetTextPosition(render_ctx, 0, height - baseline);
|
||||
@@ -530,6 +530,14 @@ static PyMethodDef methods[] = {
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
const char*
|
||||
postscript_name_for_face(const PyObject *face_) {
|
||||
const CTFace *self = (const CTFace*)face_;
|
||||
if (self->postscript_name) return PyUnicode_AsUTF8(self->postscript_name);
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
repr(CTFace *self) {
|
||||
char buf[1024] = {0};
|
||||
|
||||
@@ -53,6 +53,7 @@ typedef enum { DISABLE_LIGATURES_NEVER, DISABLE_LIGATURES_CURSOR, DISABLE_LIGATU
|
||||
typedef enum MouseTrackingModes { NO_TRACKING, BUTTON_MODE, MOTION_MODE, ANY_MODE } MouseTrackingMode;
|
||||
typedef enum MouseTrackingProtocols { NORMAL_PROTOCOL, UTF8_PROTOCOL, SGR_PROTOCOL, URXVT_PROTOCOL} MouseTrackingProtocol;
|
||||
typedef enum MouseShapes { BEAM, HAND, ARROW } MouseShape;
|
||||
typedef enum { NONE, MENUBAR, WINDOW, ALL } WindowTitleIn;
|
||||
|
||||
#define MAX_CHILDREN 512
|
||||
#define BLANK_CHAR 0
|
||||
@@ -277,6 +278,7 @@ Cursor* alloc_cursor(void);
|
||||
LineBuf* alloc_linebuf(unsigned int, unsigned int);
|
||||
HistoryBuf* alloc_historybuf(unsigned int, unsigned int, unsigned int);
|
||||
ColorProfile* alloc_color_profile(void);
|
||||
void copy_color_profile(ColorProfile*, ColorProfile*);
|
||||
PyObject* create_256_color_table(void);
|
||||
PyObject* parse_bytes_dump(PyObject UNUSED *, PyObject *);
|
||||
PyObject* parse_bytes(PyObject UNUSED *, PyObject *);
|
||||
@@ -286,7 +288,7 @@ void cursor_copy_to(Cursor *src, Cursor *dest);
|
||||
void cursor_reset_display_attrs(Cursor*);
|
||||
void cursor_from_sgr(Cursor *self, unsigned int *params, unsigned int count);
|
||||
void apply_sgr_to_cells(GPUCell *first_cell, unsigned int cell_count, unsigned int *params, unsigned int count);
|
||||
const char* cell_as_sgr(GPUCell *, GPUCell *);
|
||||
const char* cell_as_sgr(const GPUCell *, const GPUCell *);
|
||||
const char* cursor_as_sgr(const Cursor *);
|
||||
|
||||
double monotonic(void);
|
||||
|
||||
2
kitty/emoji.h
generated
2
kitty/emoji.h
generated
@@ -1,4 +1,4 @@
|
||||
// unicode data, built from the unicode standard on: 2019-03-06
|
||||
// unicode data, built from the unicode standard on: 2019-08-02
|
||||
// see gen-wcwidth.py
|
||||
#pragma once
|
||||
#include "data-types.h"
|
||||
|
||||
@@ -83,19 +83,19 @@ font_set(FcFontSet *fs) {
|
||||
|
||||
static PyObject*
|
||||
fc_list(PyObject UNUSED *self, PyObject *args) {
|
||||
int allow_bitmapped_fonts = 0, only_monospaced_fonts = 1;
|
||||
int allow_bitmapped_fonts = 0, spacing = -1;
|
||||
PyObject *ans = NULL;
|
||||
FcObjectSet *os = NULL;
|
||||
FcPattern *pat = NULL;
|
||||
FcFontSet *fs = NULL;
|
||||
if (!PyArg_ParseTuple(args, "|pp", &only_monospaced_fonts, &allow_bitmapped_fonts)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "|ip", &spacing, &allow_bitmapped_fonts)) return NULL;
|
||||
pat = FcPatternCreate();
|
||||
if (pat == NULL) return PyErr_NoMemory();
|
||||
if (!allow_bitmapped_fonts) {
|
||||
AP(FcPatternAddBool, FC_OUTLINE, true, "outline");
|
||||
AP(FcPatternAddBool, FC_SCALABLE, true, "scalable");
|
||||
}
|
||||
if (only_monospaced_fonts) AP(FcPatternAddInteger, FC_SPACING, FC_MONO, "spacing");
|
||||
if (spacing > -1) AP(FcPatternAddInteger, FC_SPACING, spacing, "spacing");
|
||||
os = FcObjectSetBuild(FC_FILE, FC_POSTSCRIPT_NAME, FC_FAMILY, FC_STYLE, FC_FULLNAME, FC_WEIGHT, FC_WIDTH, FC_SLANT, FC_HINT_STYLE, FC_INDEX, FC_HINTING, FC_SCALABLE, FC_OUTLINE, FC_COLOR, FC_SPACING, NULL);
|
||||
if (!os) { PyErr_SetString(PyExc_ValueError, "Failed to create fontconfig object set"); goto end; }
|
||||
fs = FcFontList(NULL, pat, os);
|
||||
@@ -147,21 +147,21 @@ end:
|
||||
static PyObject*
|
||||
fc_match(PyObject UNUSED *self, PyObject *args) {
|
||||
char *family = NULL;
|
||||
int bold = 0, italic = 0, allow_bitmapped_fonts = 0, monospaced = 0;
|
||||
int bold = 0, italic = 0, allow_bitmapped_fonts = 0, spacing = FC_MONO;
|
||||
double size_in_pts = 0, dpi = 0;
|
||||
FcPattern *pat = NULL;
|
||||
PyObject *ans = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|zppppdd", &family, &bold, &italic, &monospaced, &allow_bitmapped_fonts, &size_in_pts, &dpi)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "|zppppdd", &family, &bold, &italic, &spacing, &allow_bitmapped_fonts, &size_in_pts, &dpi)) return NULL;
|
||||
pat = FcPatternCreate();
|
||||
if (pat == NULL) return PyErr_NoMemory();
|
||||
|
||||
if (family && strlen(family) > 0) AP(FcPatternAddString, FC_FAMILY, (const FcChar8*)family, "family");
|
||||
if (monospaced) {
|
||||
if (spacing >= FC_DUAL) {
|
||||
// pass the family,monospace as the family parameter to fc-match,
|
||||
// which will fallback to using monospace if the family does not match.
|
||||
AP(FcPatternAddString, FC_FAMILY, (const FcChar8*)"monospace", "family");
|
||||
AP(FcPatternAddInteger, FC_SPACING, FC_MONO, "spacing");
|
||||
AP(FcPatternAddInteger, FC_SPACING, spacing, "spacing");
|
||||
}
|
||||
if (!allow_bitmapped_fonts) {
|
||||
AP(FcPatternAddBool, FC_OUTLINE, true, "outline");
|
||||
@@ -243,5 +243,9 @@ init_fontconfig_library(PyObject *module) {
|
||||
PyModule_AddIntMacro(module, FC_WEIGHT_BOLD);
|
||||
PyModule_AddIntMacro(module, FC_SLANT_ITALIC);
|
||||
PyModule_AddIntMacro(module, FC_SLANT_ROMAN);
|
||||
PyModule_AddIntMacro(module, FC_PROPORTIONAL);
|
||||
PyModule_AddIntMacro(module, FC_DUAL);
|
||||
PyModule_AddIntMacro(module, FC_MONO);
|
||||
PyModule_AddIntMacro(module, FC_CHARCELL);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -58,9 +58,10 @@ typedef struct {
|
||||
|
||||
|
||||
static hb_buffer_t *harfbuzz_buffer = NULL;
|
||||
static hb_feature_t no_calt_feature = {0};
|
||||
static hb_feature_t hb_features[3] = {{0}};
|
||||
static char_type shape_buffer[4096] = {0};
|
||||
static size_t max_texture_size = 1024, max_array_len = 1024;
|
||||
typedef enum { LIGA_FEATURE, DLIG_FEATURE, CALT_FEATURE } HBFeature;
|
||||
|
||||
typedef struct {
|
||||
char_type left, right;
|
||||
@@ -76,6 +77,8 @@ typedef struct {
|
||||
PyObject *face;
|
||||
// Map glyphs to sprite map co-ords
|
||||
SpritePosition sprite_map[1024];
|
||||
hb_feature_t hb_features[8];
|
||||
size_t num_hb_features;
|
||||
SpecialGlyphCache special_glyph_cache[SPECIAL_GLYPH_CACHE_SIZE];
|
||||
bool bold, italic, emoji_presentation;
|
||||
} Font;
|
||||
@@ -345,11 +348,21 @@ desc_to_face(PyObject *desc, FONTS_DATA_HANDLE fg) {
|
||||
return ans;
|
||||
}
|
||||
|
||||
static inline void
|
||||
copy_hb_feature(Font *f, HBFeature which) {
|
||||
memcpy(f->hb_features + f->num_hb_features++, hb_features + which, sizeof(hb_features[0]));
|
||||
}
|
||||
|
||||
static inline bool
|
||||
init_font(Font *f, PyObject *face, bool bold, bool italic, bool emoji_presentation) {
|
||||
f->face = face; Py_INCREF(f->face);
|
||||
f->bold = bold; f->italic = italic; f->emoji_presentation = emoji_presentation;
|
||||
f->num_hb_features = 0;
|
||||
const char *psname = postscript_name_for_face(face);
|
||||
if (strstr(psname, "NimbusMonoPS-") == psname) {
|
||||
copy_hb_feature(f, LIGA_FEATURE); copy_hb_feature(f, DLIG_FEATURE);
|
||||
}
|
||||
copy_hb_feature(f, CALT_FEATURE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -484,6 +497,20 @@ load_fallback_font(FontGroup *fg, CPUCell *cell, bool bold, bool italic, bool em
|
||||
Font *af = &fg->fonts[ans];
|
||||
if (!init_font(af, face, bold, italic, emoji_presentation)) fatal("Out of memory");
|
||||
Py_DECREF(face);
|
||||
if (!has_cell_text(af, cell)) {
|
||||
if (global_state.debug_font_fallback) {
|
||||
printf("The font chosen by the OS for the text: ");
|
||||
printf("U+%x ", cell->ch);
|
||||
for (unsigned i = 0; i < arraysz(cell->cc_idx) && cell->cc_idx[i]; i++) {
|
||||
printf("U+%x ", codepoint_for_mark(cell->cc_idx[i]));
|
||||
}
|
||||
printf("is ");
|
||||
PyObject_Print(af->face, stdout, 0);
|
||||
printf(" but it does not actually contain glyphs for that text\n");
|
||||
}
|
||||
del_font(af);
|
||||
return MISSING_FONT;
|
||||
}
|
||||
fg->fallback_fonts_count++;
|
||||
fg->fonts_count++;
|
||||
return ans;
|
||||
@@ -523,6 +550,7 @@ START_ALLOW_CASE_RANGE
|
||||
switch(cpu_cell->ch) {
|
||||
case 0:
|
||||
case ' ':
|
||||
case '\t':
|
||||
return BLANK_FONT;
|
||||
case 0x2500 ... 0x2570:
|
||||
case 0x2574 ... 0x259f:
|
||||
@@ -714,7 +742,7 @@ num_codepoints_in_cell(CPUCell *cell) {
|
||||
}
|
||||
|
||||
static inline void
|
||||
shape(CPUCell *first_cpu_cell, GPUCell *first_gpu_cell, index_type num_cells, hb_font_t *font, bool disable_ligature) {
|
||||
shape(CPUCell *first_cpu_cell, GPUCell *first_gpu_cell, index_type num_cells, hb_font_t *font, Font *fobj, bool disable_ligature) {
|
||||
if (group_state.groups_capacity <= 2 * num_cells) {
|
||||
group_state.groups_capacity = MAX(128u, 2 * num_cells); // avoid unnecessary reallocs
|
||||
group_state.groups = realloc(group_state.groups, sizeof(Group) * group_state.groups_capacity);
|
||||
@@ -739,11 +767,7 @@ shape(CPUCell *first_cpu_cell, GPUCell *first_gpu_cell, index_type num_cells, hb
|
||||
group_state.last_gpu_cell = first_gpu_cell + (num_cells ? num_cells - 1 : 0);
|
||||
load_hb_buffer(first_cpu_cell, first_gpu_cell, num_cells);
|
||||
|
||||
if (disable_ligature) {
|
||||
hb_shape(font, harfbuzz_buffer, &no_calt_feature, 1);
|
||||
} else {
|
||||
hb_shape(font, harfbuzz_buffer, NULL, 0);
|
||||
}
|
||||
hb_shape(font, harfbuzz_buffer, fobj->hb_features, fobj->num_hb_features - (disable_ligature ? 0 : 1));
|
||||
|
||||
unsigned int info_length, positions_length;
|
||||
group_state.info = hb_buffer_get_glyph_infos(harfbuzz_buffer, &info_length);
|
||||
@@ -814,7 +838,7 @@ check_cell_consumed(CellData *cell_data, CPUCell *last_cpu_cell) {
|
||||
|
||||
static inline void
|
||||
shape_run(CPUCell *first_cpu_cell, GPUCell *first_gpu_cell, index_type num_cells, Font *font, bool disable_ligature) {
|
||||
shape(first_cpu_cell, first_gpu_cell, num_cells, harfbuzz_font_for_face(font->face), disable_ligature);
|
||||
shape(first_cpu_cell, first_gpu_cell, num_cells, harfbuzz_font_for_face(font->face), font, disable_ligature);
|
||||
#if 0
|
||||
static char dbuf[1024];
|
||||
// You can also generate this easily using hb-shape --show-extents --cluster-level=1 --shapers=ot /path/to/font/file text
|
||||
@@ -931,8 +955,11 @@ merge_groups_for_pua_space_ligature(void) {
|
||||
while (G(group_idx) > 0) {
|
||||
Group *g = G(groups), *g1 = G(groups) + 1;
|
||||
g->num_cells += g1->num_cells;
|
||||
g->num_glyphs += g1->num_glyphs;
|
||||
g->num_glyphs = MIN(g->num_glyphs, MAX_NUM_EXTRA_GLYPHS + 1);
|
||||
// We dont want the space glyphs rendered because some stupid
|
||||
// fonts like PowerLine dont have a space glyph
|
||||
// https://github.com/kovidgoyal/kitty/issues/1225
|
||||
/* g->num_glyphs += g1->num_glyphs; */
|
||||
/* g->num_glyphs = MIN(g->num_glyphs, MAX_NUM_EXTRA_GLYPHS + 1); */
|
||||
G(group_idx)--;
|
||||
}
|
||||
}
|
||||
@@ -989,6 +1016,8 @@ test_shape(PyObject UNUSED *self, PyObject *args) {
|
||||
if (face == NULL) return NULL;
|
||||
font = calloc(1, sizeof(Font));
|
||||
font->face = face;
|
||||
font->hb_features[0] = hb_features[CALT_FEATURE];
|
||||
font->num_hb_features = 1;
|
||||
} else {
|
||||
FontGroup *fg = font_groups;
|
||||
font = fg->fonts + fg->medium_font_idx;
|
||||
@@ -1231,7 +1260,6 @@ send_prerendered_sprites_for_window(OSWindow *w) {
|
||||
FontGroup *fg = (FontGroup*)w->fonts_data;
|
||||
if (!fg->sprite_map) {
|
||||
fg->sprite_map = alloc_sprite_map(fg->cell_width, fg->cell_height);
|
||||
if (!fg->sprite_map) fatal("Out of memory allocating a sprite map");
|
||||
send_prerendered_sprites(fg);
|
||||
}
|
||||
}
|
||||
@@ -1414,12 +1442,15 @@ init_fonts(PyObject *module) {
|
||||
harfbuzz_buffer = hb_buffer_create();
|
||||
if (harfbuzz_buffer == NULL || !hb_buffer_allocation_successful(harfbuzz_buffer) || !hb_buffer_pre_allocate(harfbuzz_buffer, 2048)) { PyErr_NoMemory(); return false; }
|
||||
hb_buffer_set_cluster_level(harfbuzz_buffer, HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
|
||||
#define feature_str "-calt"
|
||||
if (!hb_feature_from_string(feature_str, sizeof(feature_str) - 1, &no_calt_feature)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Failed to create -calt harfbuzz feature");
|
||||
return false;
|
||||
}
|
||||
#undef feature_str
|
||||
#define create_feature(feature, where) {\
|
||||
if (!hb_feature_from_string(feature, sizeof(feature) - 1, &hb_features[where])) { \
|
||||
PyErr_SetString(PyExc_RuntimeError, "Failed to create " feature " harfbuzz feature"); \
|
||||
return false; \
|
||||
}}
|
||||
create_feature("-liga", LIGA_FEATURE);
|
||||
create_feature("-dlig", DLIG_FEATURE);
|
||||
create_feature("-calt", CALT_FEATURE);
|
||||
#undef create_feature
|
||||
if (PyModule_AddFunctions(module, module_methods) != 0) return false;
|
||||
current_send_sprite_to_gpu = send_sprite_to_gpu;
|
||||
return true;
|
||||
|
||||
@@ -31,6 +31,7 @@ PyObject* create_fallback_face(PyObject *base_face, CPUCell* cell, bool bold, bo
|
||||
PyObject* specialize_font_descriptor(PyObject *base_descriptor, FONTS_DATA_HANDLE);
|
||||
PyObject* face_from_path(const char *path, int index, FONTS_DATA_HANDLE);
|
||||
PyObject* face_from_descriptor(PyObject*, FONTS_DATA_HANDLE);
|
||||
const char* postscript_name_for_face(const PyObject*);
|
||||
|
||||
void sprite_tracker_current_layout(FONTS_DATA_HANDLE data, unsigned int *x, unsigned int *y, unsigned int *z);
|
||||
void render_alpha_mask(uint8_t *alpha_mask, pixel* dest, Region *src_rect, Region *dest_rect, size_t src_stride, size_t dest_stride);
|
||||
|
||||
@@ -7,7 +7,7 @@ from functools import lru_cache
|
||||
|
||||
from kitty.fast_data_types import (
|
||||
FC_SLANT_ITALIC, FC_SLANT_ROMAN, FC_WEIGHT_BOLD, FC_WEIGHT_REGULAR,
|
||||
fc_list, fc_match as fc_match_impl,
|
||||
fc_list, fc_match as fc_match_impl, FC_DUAL, FC_MONO
|
||||
)
|
||||
|
||||
attr_map = {(False, False): 'font_family',
|
||||
@@ -32,15 +32,19 @@ def create_font_map(all_fonts):
|
||||
|
||||
@lru_cache()
|
||||
def all_fonts_map(monospaced=True):
|
||||
return create_font_map(fc_list(monospaced))
|
||||
if monospaced:
|
||||
ans = fc_list(FC_DUAL) + fc_list(FC_MONO)
|
||||
else:
|
||||
ans = fc_list()
|
||||
return create_font_map(ans)
|
||||
|
||||
|
||||
def list_fonts():
|
||||
for fd in fc_list(False):
|
||||
for fd in fc_list():
|
||||
f = fd.get('family')
|
||||
if f:
|
||||
fn = fd.get('full_name') or (f + ' ' + fd.get('style', '')).strip()
|
||||
is_mono = fd.get('spacing') == 'MONO'
|
||||
is_mono = fd.get('spacing') in ('MONO', 'DUAL')
|
||||
yield {'family': f, 'full_name': fn, 'is_monospace': is_mono}
|
||||
|
||||
|
||||
@@ -49,8 +53,8 @@ def family_name_to_key(family):
|
||||
|
||||
|
||||
@lru_cache()
|
||||
def fc_match(family, bold, italic):
|
||||
return fc_match_impl(family, bold, italic)
|
||||
def fc_match(family, bold, italic, spacing=FC_MONO):
|
||||
return fc_match_impl(family, bold, italic, spacing)
|
||||
|
||||
|
||||
def find_best_match(family, bold=False, italic=False, monospaced=True):
|
||||
@@ -71,20 +75,21 @@ def find_best_match(family, bold=False, italic=False, monospaced=True):
|
||||
return candidates[0]
|
||||
|
||||
# Use fc-match to see if we can find a monospaced font that matches family
|
||||
possibility = fc_match(family, False, False)
|
||||
for key, map_key in (('postscript_name', 'ps_map'), ('full_name', 'full_map'), ('family', 'family_map')):
|
||||
val = possibility.get(key)
|
||||
if val:
|
||||
candidates = font_map[map_key].get(family_name_to_key(val))
|
||||
if candidates:
|
||||
if len(candidates) == 1:
|
||||
# happens if the family name is an alias, so we search with
|
||||
# the actual family name to see if we can find all the
|
||||
# fonts in the family.
|
||||
family_name_candidates = font_map['family_map'].get(family_name_to_key(candidates[0]['family']))
|
||||
if family_name_candidates and len(family_name_candidates) > 1:
|
||||
candidates = family_name_candidates
|
||||
return sorted(candidates, key=score)[0]
|
||||
for spacing in (FC_MONO, FC_DUAL):
|
||||
possibility = fc_match(family, False, False, spacing)
|
||||
for key, map_key in (('postscript_name', 'ps_map'), ('full_name', 'full_map'), ('family', 'family_map')):
|
||||
val = possibility.get(key)
|
||||
if val:
|
||||
candidates = font_map[map_key].get(family_name_to_key(val))
|
||||
if candidates:
|
||||
if len(candidates) == 1:
|
||||
# happens if the family name is an alias, so we search with
|
||||
# the actual family name to see if we can find all the
|
||||
# fonts in the family.
|
||||
family_name_candidates = font_map['family_map'].get(family_name_to_key(candidates[0]['family']))
|
||||
if family_name_candidates and len(family_name_candidates) > 1:
|
||||
candidates = family_name_candidates
|
||||
return sorted(candidates, key=score)[0]
|
||||
|
||||
# Use fc-match with a generic family
|
||||
family = 'monospace' if monospaced else 'sans-serif'
|
||||
|
||||
@@ -272,6 +272,13 @@ repr(Face *self) {
|
||||
}
|
||||
|
||||
|
||||
const char*
|
||||
postscript_name_for_face(const PyObject *face_) {
|
||||
const Face *self = (const Face*)face_;
|
||||
const char *ps_name = FT_Get_Postscript_Name(self->face);
|
||||
return ps_name ? ps_name : "";
|
||||
}
|
||||
|
||||
static inline unsigned int
|
||||
calc_cell_width(Face *self) {
|
||||
unsigned int ans = 0;
|
||||
|
||||
69
kitty/glfw-wrapper.h
generated
69
kitty/glfw-wrapper.h
generated
@@ -81,7 +81,7 @@
|
||||
*
|
||||
* The naming of the key codes follow these rules:
|
||||
* - The US keyboard layout is used
|
||||
* - Names of printable alpha-numeric characters are used (e.g. "A", "R",
|
||||
* - Names of printable alphanumeric characters are used (e.g. "A", "R",
|
||||
* "3", etc.)
|
||||
* - For non-alphanumeric characters, Unicode:ish names are used (e.g.
|
||||
* "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
|
||||
@@ -99,7 +99,15 @@
|
||||
|
||||
/* Printable keys */
|
||||
#define GLFW_KEY_SPACE 32
|
||||
#define GLFW_KEY_EXCLAM 33 /* ! */
|
||||
#define GLFW_KEY_DOUBLE_QUOTE 34 /* " */
|
||||
#define GLFW_KEY_NUMBER_SIGN 35 /* # */
|
||||
#define GLFW_KEY_DOLLAR 36 /* $ */
|
||||
#define GLFW_KEY_AMPERSAND 38 /* & */
|
||||
#define GLFW_KEY_APOSTROPHE 39 /* ' */
|
||||
#define GLFW_KEY_PARENTHESIS_LEFT 40 /* ( */
|
||||
#define GLFW_KEY_PARENTHESIS_RIGHT 41 /* ) */
|
||||
#define GLFW_KEY_PLUS 43 /* + */
|
||||
#define GLFW_KEY_COMMA 44 /* , */
|
||||
#define GLFW_KEY_MINUS 45 /* - */
|
||||
#define GLFW_KEY_PERIOD 46 /* . */
|
||||
@@ -114,8 +122,12 @@
|
||||
#define GLFW_KEY_7 55
|
||||
#define GLFW_KEY_8 56
|
||||
#define GLFW_KEY_9 57
|
||||
#define GLFW_KEY_COLON 58 /* : */
|
||||
#define GLFW_KEY_SEMICOLON 59 /* ; */
|
||||
#define GLFW_KEY_LESS 60 /* < */
|
||||
#define GLFW_KEY_EQUAL 61 /* = */
|
||||
#define GLFW_KEY_GREATER 62 /* > */
|
||||
#define GLFW_KEY_AT 64 /* @ */
|
||||
#define GLFW_KEY_A 65
|
||||
#define GLFW_KEY_B 66
|
||||
#define GLFW_KEY_C 67
|
||||
@@ -145,11 +157,62 @@
|
||||
#define GLFW_KEY_LEFT_BRACKET 91 /* [ */
|
||||
#define GLFW_KEY_BACKSLASH 92 /* \ */
|
||||
#define GLFW_KEY_RIGHT_BRACKET 93 /* ] */
|
||||
#define GLFW_KEY_UNDERSCORE 95 /* _ */
|
||||
#define GLFW_KEY_GRAVE_ACCENT 96 /* ` */
|
||||
#define GLFW_KEY_WORLD_1 161 /* non-US #1 */
|
||||
#define GLFW_KEY_WORLD_2 162 /* non-US #2 */
|
||||
#define GLFW_KEY_PLUS 163
|
||||
#define GLFW_KEY_UNDERSCORE 164
|
||||
#define GLFW_KEY_PARAGRAPH 167 /* § */
|
||||
#define GLFW_KEY_MASCULINE 186 /* º */
|
||||
#define GLFW_KEY_A_GRAVE 192 /* À */
|
||||
#define GLFW_KEY_A_DIAERESIS 196 /* Ä */
|
||||
#define GLFW_KEY_A_RING 197 /* Å */
|
||||
#define GLFW_KEY_AE 198 /* Æ */
|
||||
#define GLFW_KEY_C_CEDILLA 199 /* Ç */
|
||||
#define GLFW_KEY_E_GRAVE 200 /* È */
|
||||
#define GLFW_KEY_E_ACUTE 201 /* É */
|
||||
#define GLFW_KEY_I_GRAVE 204 /* Ì */
|
||||
#define GLFW_KEY_N_TILDE 209 /* Ñ */
|
||||
#define GLFW_KEY_O_GRAVE 210 /* Ò */
|
||||
#define GLFW_KEY_O_DIAERESIS 214 /* Ö */
|
||||
#define GLFW_KEY_O_SLASH 216 /* Ø */
|
||||
#define GLFW_KEY_U_GRAVE 217 /* Ù */
|
||||
#define GLFW_KEY_U_DIAERESIS 220 /* Ü */
|
||||
#define GLFW_KEY_S_SHARP 222 /* ß */
|
||||
#define GLFW_KEY_CYRILLIC_A 223 /* А */
|
||||
#define GLFW_KEY_CYRILLIC_BE 224 /* Б */
|
||||
#define GLFW_KEY_CYRILLIC_VE 225 /* В */
|
||||
#define GLFW_KEY_CYRILLIC_GHE 226 /* Г */
|
||||
#define GLFW_KEY_CYRILLIC_DE 227 /* Д */
|
||||
#define GLFW_KEY_CYRILLIC_IE 228 /* Е */
|
||||
#define GLFW_KEY_CYRILLIC_ZHE 229 /* Ж */
|
||||
#define GLFW_KEY_CYRILLIC_ZE 230 /* З */
|
||||
#define GLFW_KEY_CYRILLIC_I 231 /* И */
|
||||
#define GLFW_KEY_CYRILLIC_SHORT_I 232 /* Й */
|
||||
#define GLFW_KEY_CYRILLIC_KA 233 /* К */
|
||||
#define GLFW_KEY_CYRILLIC_EL 234 /* Л */
|
||||
#define GLFW_KEY_CYRILLIC_EM 235 /* М */
|
||||
#define GLFW_KEY_CYRILLIC_EN 236 /* Н */
|
||||
#define GLFW_KEY_CYRILLIC_O 237 /* О */
|
||||
#define GLFW_KEY_CYRILLIC_PE 238 /* П */
|
||||
#define GLFW_KEY_CYRILLIC_ER 239 /* Р */
|
||||
#define GLFW_KEY_CYRILLIC_ES 240 /* С */
|
||||
#define GLFW_KEY_CYRILLIC_TE 241 /* Т */
|
||||
#define GLFW_KEY_CYRILLIC_U 242 /* У */
|
||||
#define GLFW_KEY_CYRILLIC_EF 243 /* Ф */
|
||||
#define GLFW_KEY_CYRILLIC_HA 244 /* Х */
|
||||
#define GLFW_KEY_CYRILLIC_TSE 245 /* Ц */
|
||||
#define GLFW_KEY_CYRILLIC_CHE 246 /* Ч */
|
||||
#define GLFW_KEY_CYRILLIC_SHA 247 /* Ш */
|
||||
#define GLFW_KEY_CYRILLIC_SHCHA 248 /* Щ */
|
||||
#define GLFW_KEY_CYRILLIC_HARD_SIGN 249 /* Ъ */
|
||||
#define GLFW_KEY_CYRILLIC_YERU 250 /* Ы */
|
||||
#define GLFW_KEY_CYRILLIC_SOFT_SIGN 251 /* Ь */
|
||||
#define GLFW_KEY_CYRILLIC_E 252 /* Э */
|
||||
#define GLFW_KEY_CYRILLIC_YU 253 /* Ю */
|
||||
#define GLFW_KEY_CYRILLIC_YA 254 /* Я */
|
||||
#define GLFW_KEY_CYRILLIC_IO 255 /* Ё */
|
||||
|
||||
#define GLFW_KEY_LAST_PRINTABLE GLFW_KEY_CYRILLIC_IO
|
||||
|
||||
/* Function keys */
|
||||
#define GLFW_KEY_ESCAPE 256
|
||||
|
||||
112
kitty/glfw.c
112
kitty/glfw.c
@@ -12,6 +12,7 @@
|
||||
extern bool cocoa_make_window_resizable(void *w, bool);
|
||||
extern void cocoa_focus_window(void *w);
|
||||
extern void cocoa_create_global_menu(void);
|
||||
extern void cocoa_hide_window_title(void *w);
|
||||
extern void cocoa_set_activation_policy(bool);
|
||||
extern void cocoa_set_titlebar_color(void *w, color_type color);
|
||||
extern bool cocoa_alt_option_key_pressed(unsigned long);
|
||||
@@ -40,26 +41,37 @@ update_os_window_viewport(OSWindow *window, bool notify_boss) {
|
||||
int w, h, fw, fh;
|
||||
glfwGetFramebufferSize(window->handle, &fw, &fh);
|
||||
glfwGetWindowSize(window->handle, &w, &h);
|
||||
if (fw == window->viewport_width && fh == window->viewport_height && w == window->window_width && h == window->window_height) {
|
||||
double xdpi = window->logical_dpi_x, ydpi = window->logical_dpi_y;
|
||||
set_os_window_dpi(window);
|
||||
|
||||
if (fw == window->viewport_width && fh == window->viewport_height && w == window->window_width && h == window->window_height && xdpi == window->logical_dpi_x && ydpi == window->logical_dpi_y) {
|
||||
return; // no change, ignore
|
||||
}
|
||||
if (fw / w > 5 || fh / h > 5 || fw < min_width || fh < min_height || fw < w || fh < h) {
|
||||
if (w <= 0 || h <= 0 || fw / w > 5 || fh / h > 5 || fw < min_width || fh < min_height || fw < w || fh < h) {
|
||||
log_error("Invalid geometry ignored: framebuffer: %dx%d window: %dx%d\n", fw, fh, w, h);
|
||||
if (!window->viewport_updated_at_least_once) {
|
||||
window->viewport_width = min_width; window->viewport_height = min_height;
|
||||
window->window_width = min_width; window->window_height = min_height;
|
||||
window->viewport_x_ratio = 1; window->viewport_y_ratio = 1;
|
||||
window->viewport_size_dirty = true;
|
||||
if (notify_boss) {
|
||||
call_boss(on_window_resize, "KiiO", window->id, window->viewport_width, window->viewport_height, Py_False);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
window->viewport_updated_at_least_once = true;
|
||||
window->viewport_width = fw; window->viewport_height = fh;
|
||||
double xr = window->viewport_x_ratio, yr = window->viewport_y_ratio;
|
||||
window->viewport_x_ratio = w > 0 ? (double)window->viewport_width / (double)w : xr;
|
||||
window->viewport_y_ratio = h > 0 ? (double)window->viewport_height / (double)h : yr;
|
||||
double xdpi = window->logical_dpi_x, ydpi = window->logical_dpi_y;
|
||||
set_os_window_dpi(window);
|
||||
bool dpi_changed = (xr != 0.0 && xr != window->viewport_x_ratio) || (yr != 0.0 && yr != window->viewport_y_ratio) || (xdpi != window->logical_dpi_x) || (ydpi != window->logical_dpi_y);
|
||||
|
||||
window->viewport_size_dirty = true;
|
||||
window->viewport_width = MAX(window->viewport_width, min_width);
|
||||
window->viewport_height = MAX(window->viewport_height, min_height);
|
||||
window->window_width = MAX(w, 100);
|
||||
window->window_height = MAX(h, 100);
|
||||
window->window_width = MAX(w, min_width);
|
||||
window->window_height = MAX(h, min_height);
|
||||
if (notify_boss) {
|
||||
call_boss(on_window_resize, "KiiO", window->id, window->viewport_width, window->viewport_height, dpi_changed ? Py_True : Py_False);
|
||||
}
|
||||
@@ -308,13 +320,13 @@ window_focus_callback(GLFWwindow *w, int focused) {
|
||||
}
|
||||
|
||||
static void
|
||||
drop_callback(GLFWwindow *w, int count, const char **paths) {
|
||||
drop_callback(GLFWwindow *w, int count, const char **strings) {
|
||||
if (!set_callback_window(w)) return;
|
||||
PyObject *p = PyTuple_New(count);
|
||||
if (p) {
|
||||
for (int i = 0; i < count; i++) PyTuple_SET_ITEM(p, i, PyUnicode_FromString(paths[i]));
|
||||
WINDOW_CALLBACK(on_drop, "O", p);
|
||||
Py_CLEAR(p);
|
||||
PyObject *s = PyTuple_New(count);
|
||||
if (s) {
|
||||
for (int i = 0; i < count; i++) PyTuple_SET_ITEM(s, i, PyUnicode_FromString(strings[i]));
|
||||
WINDOW_CALLBACK(on_drop, "O", s);
|
||||
Py_CLEAR(s);
|
||||
request_tick_callback();
|
||||
}
|
||||
global_state.callback_os_window = NULL;
|
||||
@@ -636,8 +648,12 @@ create_os_window(PyObject UNUSED *self, PyObject *args) {
|
||||
glfwSetKeyboardCallback(glfw_window, key_callback);
|
||||
glfwSetDropCallback(glfw_window, drop_callback);
|
||||
#ifdef __APPLE__
|
||||
if (glfwGetCocoaWindow) cocoa_make_window_resizable(glfwGetCocoaWindow(glfw_window), OPT(macos_window_resizable));
|
||||
else log_error("Failed to load glfwGetCocoaWindow");
|
||||
if (glfwGetCocoaWindow) {
|
||||
if (!(OPT(macos_show_window_title_in) & WINDOW)) {
|
||||
cocoa_hide_window_title(glfwGetCocoaWindow(glfw_window));
|
||||
}
|
||||
cocoa_make_window_resizable(glfwGetCocoaWindow(glfw_window), OPT(macos_window_resizable));
|
||||
} else log_error("Failed to load glfwGetCocoaWindow");
|
||||
#endif
|
||||
double now = monotonic();
|
||||
w->is_focused = true;
|
||||
@@ -766,7 +782,7 @@ glfw_init(PyObject UNUSED *self, PyObject *args) {
|
||||
// Joysticks cause slow startup on some linux systems, see
|
||||
// https://github.com/kovidgoyal/kitty/issues/830
|
||||
glfwInitHint(GLFW_ENABLE_JOYSTICKS, 0);
|
||||
global_state.opts.debug_keyboard = debug_keyboard != 0;
|
||||
OPT(debug_keyboard) = debug_keyboard != 0;
|
||||
#ifdef __APPLE__
|
||||
glfwInitHint(GLFW_COCOA_CHDIR_RESOURCES, 0);
|
||||
glfwInitHint(GLFW_COCOA_MENUBAR, 0);
|
||||
@@ -1219,7 +1235,15 @@ init_glfw(PyObject *m) {
|
||||
|
||||
// --- Printable keys ----------------------------------------------------------
|
||||
ADDC(GLFW_KEY_SPACE);
|
||||
ADDC(GLFW_KEY_EXCLAM);
|
||||
ADDC(GLFW_KEY_DOUBLE_QUOTE);
|
||||
ADDC(GLFW_KEY_NUMBER_SIGN);
|
||||
ADDC(GLFW_KEY_DOLLAR);
|
||||
ADDC(GLFW_KEY_AMPERSAND);
|
||||
ADDC(GLFW_KEY_APOSTROPHE);
|
||||
ADDC(GLFW_KEY_PARENTHESIS_LEFT);
|
||||
ADDC(GLFW_KEY_PARENTHESIS_RIGHT);
|
||||
ADDC(GLFW_KEY_PLUS);
|
||||
ADDC(GLFW_KEY_COMMA);
|
||||
ADDC(GLFW_KEY_MINUS);
|
||||
ADDC(GLFW_KEY_PERIOD);
|
||||
@@ -1234,8 +1258,12 @@ init_glfw(PyObject *m) {
|
||||
ADDC(GLFW_KEY_7);
|
||||
ADDC(GLFW_KEY_8);
|
||||
ADDC(GLFW_KEY_9);
|
||||
ADDC(GLFW_KEY_COLON);
|
||||
ADDC(GLFW_KEY_SEMICOLON);
|
||||
ADDC(GLFW_KEY_LESS);
|
||||
ADDC(GLFW_KEY_EQUAL);
|
||||
ADDC(GLFW_KEY_GREATER);
|
||||
ADDC(GLFW_KEY_AT);
|
||||
ADDC(GLFW_KEY_A);
|
||||
ADDC(GLFW_KEY_B);
|
||||
ADDC(GLFW_KEY_C);
|
||||
@@ -1265,11 +1293,61 @@ init_glfw(PyObject *m) {
|
||||
ADDC(GLFW_KEY_LEFT_BRACKET);
|
||||
ADDC(GLFW_KEY_BACKSLASH);
|
||||
ADDC(GLFW_KEY_RIGHT_BRACKET);
|
||||
ADDC(GLFW_KEY_UNDERSCORE);
|
||||
ADDC(GLFW_KEY_GRAVE_ACCENT);
|
||||
ADDC(GLFW_KEY_WORLD_1);
|
||||
ADDC(GLFW_KEY_WORLD_2);
|
||||
ADDC(GLFW_KEY_PLUS);
|
||||
ADDC(GLFW_KEY_UNDERSCORE);
|
||||
ADDC(GLFW_KEY_PARAGRAPH);
|
||||
ADDC(GLFW_KEY_MASCULINE);
|
||||
ADDC(GLFW_KEY_A_GRAVE);
|
||||
ADDC(GLFW_KEY_A_DIAERESIS);
|
||||
ADDC(GLFW_KEY_A_RING);
|
||||
ADDC(GLFW_KEY_AE);
|
||||
ADDC(GLFW_KEY_C_CEDILLA);
|
||||
ADDC(GLFW_KEY_E_GRAVE);
|
||||
ADDC(GLFW_KEY_E_ACUTE);
|
||||
ADDC(GLFW_KEY_I_GRAVE);
|
||||
ADDC(GLFW_KEY_N_TILDE);
|
||||
ADDC(GLFW_KEY_O_GRAVE);
|
||||
ADDC(GLFW_KEY_O_DIAERESIS);
|
||||
ADDC(GLFW_KEY_O_SLASH);
|
||||
ADDC(GLFW_KEY_U_GRAVE);
|
||||
ADDC(GLFW_KEY_U_DIAERESIS);
|
||||
ADDC(GLFW_KEY_S_SHARP);
|
||||
ADDC(GLFW_KEY_CYRILLIC_A);
|
||||
ADDC(GLFW_KEY_CYRILLIC_BE);
|
||||
ADDC(GLFW_KEY_CYRILLIC_VE);
|
||||
ADDC(GLFW_KEY_CYRILLIC_GHE);
|
||||
ADDC(GLFW_KEY_CYRILLIC_DE);
|
||||
ADDC(GLFW_KEY_CYRILLIC_IE);
|
||||
ADDC(GLFW_KEY_CYRILLIC_ZHE);
|
||||
ADDC(GLFW_KEY_CYRILLIC_ZE);
|
||||
ADDC(GLFW_KEY_CYRILLIC_I);
|
||||
ADDC(GLFW_KEY_CYRILLIC_SHORT_I);
|
||||
ADDC(GLFW_KEY_CYRILLIC_KA);
|
||||
ADDC(GLFW_KEY_CYRILLIC_EL);
|
||||
ADDC(GLFW_KEY_CYRILLIC_EM);
|
||||
ADDC(GLFW_KEY_CYRILLIC_EN);
|
||||
ADDC(GLFW_KEY_CYRILLIC_O);
|
||||
ADDC(GLFW_KEY_CYRILLIC_PE);
|
||||
ADDC(GLFW_KEY_CYRILLIC_ER);
|
||||
ADDC(GLFW_KEY_CYRILLIC_ES);
|
||||
ADDC(GLFW_KEY_CYRILLIC_TE);
|
||||
ADDC(GLFW_KEY_CYRILLIC_U);
|
||||
ADDC(GLFW_KEY_CYRILLIC_EF);
|
||||
ADDC(GLFW_KEY_CYRILLIC_HA);
|
||||
ADDC(GLFW_KEY_CYRILLIC_TSE);
|
||||
ADDC(GLFW_KEY_CYRILLIC_CHE);
|
||||
ADDC(GLFW_KEY_CYRILLIC_SHA);
|
||||
ADDC(GLFW_KEY_CYRILLIC_SHCHA);
|
||||
ADDC(GLFW_KEY_CYRILLIC_HARD_SIGN);
|
||||
ADDC(GLFW_KEY_CYRILLIC_YERU);
|
||||
ADDC(GLFW_KEY_CYRILLIC_SOFT_SIGN);
|
||||
ADDC(GLFW_KEY_CYRILLIC_E);
|
||||
ADDC(GLFW_KEY_CYRILLIC_YU);
|
||||
ADDC(GLFW_KEY_CYRILLIC_YA);
|
||||
ADDC(GLFW_KEY_CYRILLIC_IO);
|
||||
ADDC(GLFW_KEY_LAST_PRINTABLE);
|
||||
|
||||
// --- Function keys -----------------------------------------------------------
|
||||
ADDC(GLFW_KEY_ESCAPE);
|
||||
|
||||
@@ -179,6 +179,7 @@ pagerhist_push(HistoryBuf *self) {
|
||||
PagerHistoryBuf *ph = self->pagerhist;
|
||||
if (!ph) return;
|
||||
bool truncated;
|
||||
const GPUCell *prev_cell = NULL;
|
||||
Line l = {.xnum=self->xnum};
|
||||
init_line(self, self->start_of_data, &l);
|
||||
#define EXPAND_IF_FULL(sz) { \
|
||||
@@ -193,7 +194,7 @@ pagerhist_push(HistoryBuf *self) {
|
||||
ph->buffer[ph->end++] = '\n';
|
||||
}
|
||||
while(sz < ph->maxsz - 2) {
|
||||
size_t num = line_as_ansi(&l, ph->buffer + ph->end, ph->bufsize - ph->end - 2, &truncated);
|
||||
size_t num = line_as_ansi(&l, ph->buffer + ph->end, ph->bufsize - ph->end - 2, &truncated, &prev_cell);
|
||||
if (!truncated) {
|
||||
ph->end += num;
|
||||
ph->buffer[ph->end++] = '\r';
|
||||
@@ -270,12 +271,13 @@ as_ansi(HistoryBuf *self, PyObject *callback) {
|
||||
static Py_UCS4 t[5120];
|
||||
Line l = {.xnum=self->xnum};
|
||||
bool truncated;
|
||||
const GPUCell *prev_cell = NULL;
|
||||
for(unsigned int i = 0; i < self->count; i++) {
|
||||
init_line(self, i, &l);
|
||||
if (i < self->count - 1) {
|
||||
l.continued = *attrptr(self, index_of(self, i + 1)) & CONTINUED_MASK;
|
||||
} else l.continued = false;
|
||||
index_type num = line_as_ansi(&l, t, 5120, &truncated);
|
||||
index_type num = line_as_ansi(&l, t, 5120, &truncated, &prev_cell);
|
||||
if (!(l.continued) && num < 5119) t[num++] = 10; // 10 = \n
|
||||
PyObject *ans = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, t, num);
|
||||
if (ans == NULL) return PyErr_NoMemory();
|
||||
|
||||
159
kitty/key_encoding.py
generated
159
kitty/key_encoding.py
generated
@@ -6,6 +6,7 @@ import string
|
||||
from collections import namedtuple
|
||||
|
||||
from . import fast_data_types as defines
|
||||
from .key_names import key_name_aliases
|
||||
|
||||
# ENCODING {{{
|
||||
ENCODING = {
|
||||
@@ -129,11 +130,81 @@ ENCODING = {
|
||||
'Y': 'q',
|
||||
'Z': 'r',
|
||||
'PLUS': 'Bi',
|
||||
'UNDERSCORE': 'Bj'
|
||||
'UNDERSCORE': 'Bj',
|
||||
'MENU': 'Bk',
|
||||
'EXCLAM': 'Bl',
|
||||
'DOUBLE QUOTE': 'Bm',
|
||||
'NUMBER SIGN': 'Bn',
|
||||
'DOLLAR': 'Bo',
|
||||
'AMPERSAND': 'Bp',
|
||||
'PARENTHESIS LEFT': 'Bq',
|
||||
'PARENTHESIS RIGHT': 'Br',
|
||||
'COLON': 'Bs',
|
||||
'LESS': 'Bt',
|
||||
'GREATER': 'Bu',
|
||||
'AT': 'Bv',
|
||||
'PARAGRAPH': 'Bw',
|
||||
'MASCULINE': 'Bx',
|
||||
'A GRAVE': 'By',
|
||||
'A DIAERESIS': 'Bz',
|
||||
'A RING': 'B0',
|
||||
'AE': 'B1',
|
||||
'C CEDILLA': 'B2',
|
||||
'E GRAVE': 'B3',
|
||||
'E ACUTE': 'B4',
|
||||
'I GRAVE': 'B5',
|
||||
'N TILDE': 'B6',
|
||||
'O GRAVE': 'B7',
|
||||
'O DIAERESIS': 'B8',
|
||||
'O SLASH': 'B9',
|
||||
'U GRAVE': 'B.',
|
||||
'U DIAERESIS': 'B-',
|
||||
'S SHARP': 'B:',
|
||||
'CYRILLIC A': 'B+',
|
||||
'CYRILLIC BE': 'B=',
|
||||
'CYRILLIC VE': 'B^',
|
||||
'CYRILLIC GHE': 'B!',
|
||||
'CYRILLIC DE': 'B/',
|
||||
'CYRILLIC IE': 'B*',
|
||||
'CYRILLIC ZHE': 'B?',
|
||||
'CYRILLIC ZE': 'B&',
|
||||
'CYRILLIC I': 'B<',
|
||||
'CYRILLIC SHORT I': 'B>',
|
||||
'CYRILLIC KA': 'B(',
|
||||
'CYRILLIC EL': 'B)',
|
||||
'CYRILLIC EM': 'B[',
|
||||
'CYRILLIC EN': 'B]',
|
||||
'CYRILLIC O': 'B{',
|
||||
'CYRILLIC PE': 'B}',
|
||||
'CYRILLIC ER': 'B@',
|
||||
'CYRILLIC ES': 'B%',
|
||||
'CYRILLIC TE': 'B$',
|
||||
'CYRILLIC U': 'B#',
|
||||
'CYRILLIC EF': 'CA',
|
||||
'CYRILLIC HA': 'CB',
|
||||
'CYRILLIC TSE': 'CC',
|
||||
'CYRILLIC CHE': 'CD',
|
||||
'CYRILLIC SHA': 'CE',
|
||||
'CYRILLIC SHCHA': 'CF',
|
||||
'CYRILLIC HARD SIGN': 'CG',
|
||||
'CYRILLIC YERU': 'CH',
|
||||
'CYRILLIC SOFT SIGN': 'CI',
|
||||
'CYRILLIC E': 'CJ',
|
||||
'CYRILLIC YU': 'CK',
|
||||
'CYRILLIC YA': 'CL',
|
||||
'CYRILLIC IO': 'CM'
|
||||
}
|
||||
KEY_MAP = {
|
||||
32: 'A',
|
||||
33: 'Bl',
|
||||
34: 'Bm',
|
||||
35: 'Bn',
|
||||
36: 'Bo',
|
||||
38: 'Bp',
|
||||
39: 'B',
|
||||
40: 'Bq',
|
||||
41: 'Br',
|
||||
43: 'Bi',
|
||||
44: 'C',
|
||||
45: 'D',
|
||||
46: 'E',
|
||||
@@ -148,8 +219,12 @@ KEY_MAP = {
|
||||
55: 'N',
|
||||
56: 'O',
|
||||
57: 'P',
|
||||
58: 'Bs',
|
||||
59: 'Q',
|
||||
60: 'Bt',
|
||||
61: 'R',
|
||||
62: 'Bu',
|
||||
64: 'Bv',
|
||||
65: 'S',
|
||||
66: 'T',
|
||||
67: 'U',
|
||||
@@ -179,11 +254,60 @@ KEY_MAP = {
|
||||
91: 's',
|
||||
92: 't',
|
||||
93: 'u',
|
||||
95: 'Bj',
|
||||
96: 'v',
|
||||
161: 'w',
|
||||
162: 'x',
|
||||
163: 'Bi',
|
||||
164: 'Bj',
|
||||
167: 'Bw',
|
||||
186: 'Bx',
|
||||
192: 'By',
|
||||
196: 'Bz',
|
||||
197: 'B0',
|
||||
198: 'B1',
|
||||
199: 'B2',
|
||||
200: 'B3',
|
||||
201: 'B4',
|
||||
204: 'B5',
|
||||
209: 'B6',
|
||||
210: 'B7',
|
||||
214: 'B8',
|
||||
216: 'B9',
|
||||
217: 'B.',
|
||||
220: 'B-',
|
||||
222: 'B:',
|
||||
223: 'B+',
|
||||
224: 'B=',
|
||||
225: 'B^',
|
||||
226: 'B!',
|
||||
227: 'B/',
|
||||
228: 'B*',
|
||||
229: 'B?',
|
||||
230: 'B&',
|
||||
231: 'B<',
|
||||
232: 'B>',
|
||||
233: 'B(',
|
||||
234: 'B)',
|
||||
235: 'B[',
|
||||
236: 'B]',
|
||||
237: 'B{',
|
||||
238: 'B}',
|
||||
239: 'B@',
|
||||
240: 'B%',
|
||||
241: 'B$',
|
||||
242: 'B#',
|
||||
243: 'CA',
|
||||
244: 'CB',
|
||||
245: 'CC',
|
||||
246: 'CD',
|
||||
247: 'CE',
|
||||
248: 'CF',
|
||||
249: 'CG',
|
||||
250: 'CH',
|
||||
251: 'CI',
|
||||
252: 'CJ',
|
||||
253: 'CK',
|
||||
254: 'CL',
|
||||
255: 'CM',
|
||||
256: 'y',
|
||||
257: 'z',
|
||||
258: '0',
|
||||
@@ -252,11 +376,16 @@ KEY_MAP = {
|
||||
344: 'Be',
|
||||
345: 'Bf',
|
||||
346: 'Bg',
|
||||
347: 'Bh'
|
||||
347: 'Bh',
|
||||
348: 'Bk'
|
||||
}
|
||||
# END_ENCODING }}}
|
||||
|
||||
text_keys = string.ascii_uppercase + string.ascii_lowercase + string.digits + '`~!@#$%^&*()_-+=[{]}\\|<,>./?;:\'" '
|
||||
text_keys = (
|
||||
string.ascii_uppercase + string.ascii_lowercase + string.digits +
|
||||
'`~!@#$%^&*()_-+=[{]}\\|<,>./?;:\'" '
|
||||
'ÄäÖöÜüß§ºàåæçèéìñòøùабвгдежзийклмнопрстуфхцчшщъыьэюяё'
|
||||
)
|
||||
|
||||
|
||||
def text_match(key):
|
||||
@@ -294,9 +423,11 @@ def update_encoding():
|
||||
key_map = {}
|
||||
i = len(ans)
|
||||
for k in sorted(keys, key=lambda k: getattr(defines, k)):
|
||||
if k in ('GLFW_KEY_LAST', 'GLFW_KEY_LAST_PRINTABLE'):
|
||||
continue
|
||||
val = getattr(defines, k)
|
||||
name = symbolic_name(k)
|
||||
if val < defines.GLFW_KEY_LAST and val != defines.GLFW_KEY_UNKNOWN:
|
||||
if val <= defines.GLFW_KEY_LAST and val != defines.GLFW_KEY_UNKNOWN:
|
||||
if name not in ans:
|
||||
ans[name] = encode(i)
|
||||
i += 1
|
||||
@@ -343,21 +474,7 @@ for key_name, enc in ENCODING.items():
|
||||
key_name = key_name.replace(' ', '_')
|
||||
g[key_name] = config_key_map[key_name] = key_name
|
||||
key_rmap[enc] = key_name
|
||||
config_key_map.update({
|
||||
'`': g['GRAVE_ACCENT'],
|
||||
'-': g['MINUS'],
|
||||
'=': g['EQUAL'],
|
||||
'[': g['LEFT_BRACKET'],
|
||||
']': g['RIGHT_BRACKET'],
|
||||
'\\': g['BACKSLASH'],
|
||||
';': g['SEMICOLON'],
|
||||
"'": g['APOSTROPHE'],
|
||||
',': g['COMMA'],
|
||||
'.': g['PERIOD'],
|
||||
'/': g['SLASH'],
|
||||
'ESC': g['ESCAPE'],
|
||||
'+': g['PLUS'],
|
||||
})
|
||||
config_key_map.update({k: g[v] for k, v in key_name_aliases.items() if v in g})
|
||||
|
||||
enter_key = KeyEvent(PRESS, 0, g['ENTER'])
|
||||
backspace_key = KeyEvent(PRESS, 0, g['BACKSPACE'])
|
||||
|
||||
@@ -8,6 +8,94 @@ from contextlib import suppress
|
||||
from .constants import is_macos
|
||||
|
||||
|
||||
key_name_aliases = {
|
||||
'!': 'EXCLAM',
|
||||
'"': 'DOUBLE_QUOTE',
|
||||
'#': 'NUMBER_SIGN',
|
||||
'$': 'DOLLAR',
|
||||
'&': 'AMPERSAND',
|
||||
"'": 'APOSTROPHE',
|
||||
'(': 'PARENTHESIS_LEFT',
|
||||
')': 'PARENTHESIS_RIGHT',
|
||||
',': 'COMMA',
|
||||
'-': 'MINUS',
|
||||
'.': 'PERIOD',
|
||||
'/': 'SLASH',
|
||||
':': 'COLON',
|
||||
';': 'SEMICOLON',
|
||||
'<': 'LESS',
|
||||
'=': 'EQUAL',
|
||||
'>': 'GREATER',
|
||||
'@': 'AT',
|
||||
'[': 'LEFT_BRACKET',
|
||||
'\\': 'BACKSLASH',
|
||||
']': 'RIGHT_BRACKET',
|
||||
'_': 'UNDERSCORE',
|
||||
'`': 'GRAVE_ACCENT',
|
||||
'§': 'PARAGRAPH',
|
||||
'º': 'MASCULINE',
|
||||
'À': 'A_GRAVE',
|
||||
'Ä': 'A_DIAERESIS',
|
||||
'Å': 'A_RING',
|
||||
'Æ': 'AE',
|
||||
'Ç': 'C_CEDILLA',
|
||||
'È': 'E_GRAVE',
|
||||
'É': 'E_ACUTE',
|
||||
'Ì': 'I_GRAVE',
|
||||
'Ñ': 'N_TILDE',
|
||||
'Ò': 'O_GRAVE',
|
||||
'Ö': 'O_DIAERESIS',
|
||||
'Ø': 'O_SLASH',
|
||||
'Ù': 'U_GRAVE',
|
||||
'Ü': 'U_DIAERESIS',
|
||||
'SS': 'S_SHARP', # 'ß'.upper() == 'SS'
|
||||
'А': 'CYRILLIC_A',
|
||||
'Б': 'CYRILLIC_BE',
|
||||
'В': 'CYRILLIC_VE',
|
||||
'Г': 'CYRILLIC_GHE',
|
||||
'Д': 'CYRILLIC_DE',
|
||||
'Е': 'CYRILLIC_IE',
|
||||
'Ж': 'CYRILLIC_ZHE',
|
||||
'З': 'CYRILLIC_ZE',
|
||||
'И': 'CYRILLIC_I',
|
||||
'Й': 'CYRILLIC_SHORT_I',
|
||||
'К': 'CYRILLIC_KA',
|
||||
'Л': 'CYRILLIC_EL',
|
||||
'М': 'CYRILLIC_EM',
|
||||
'Н': 'CYRILLIC_EN',
|
||||
'О': 'CYRILLIC_O',
|
||||
'П': 'CYRILLIC_PE',
|
||||
'Р': 'CYRILLIC_ER',
|
||||
'С': 'CYRILLIC_ES',
|
||||
'Т': 'CYRILLIC_TE',
|
||||
'У': 'CYRILLIC_U',
|
||||
'Ф': 'CYRILLIC_EF',
|
||||
'Х': 'CYRILLIC_HA',
|
||||
'Ц': 'CYRILLIC_TSE',
|
||||
'Ч': 'CYRILLIC_CHE',
|
||||
'Ш': 'CYRILLIC_SHA',
|
||||
'Щ': 'CYRILLIC_SHCHA',
|
||||
'Ъ': 'CYRILLIC_HARD_SIGN',
|
||||
'Ы': 'CYRILLIC_YERU',
|
||||
'Ь': 'CYRILLIC_SOFT_SIGN',
|
||||
'Э': 'CYRILLIC_E',
|
||||
'Ю': 'CYRILLIC_YU',
|
||||
'Я': 'CYRILLIC_YA',
|
||||
'Ё': 'CYRILLIC_IO',
|
||||
|
||||
'ESC': 'ESCAPE',
|
||||
'PGUP': 'PAGE_UP',
|
||||
'PAGEUP': 'PAGE_UP',
|
||||
'PGDN': 'PAGE_DOWN',
|
||||
'PAGEDOWN': 'PAGE_DOWN',
|
||||
'RETURN': 'ENTER',
|
||||
'ARROWUP': 'UP',
|
||||
'ARROWDOWN': 'DOWN',
|
||||
'ARROWRIGHT': 'RIGHT',
|
||||
'ARROWLEFT': 'LEFT'
|
||||
}
|
||||
|
||||
|
||||
def null_lookup(name, case_sensitive=False):
|
||||
pass
|
||||
|
||||
|
||||
27017
kitty/keys.h
generated
27017
kitty/keys.h
generated
File diff suppressed because it is too large
Load Diff
@@ -161,7 +161,7 @@ action_map = {
|
||||
def extended_key_event(key, mods, action):
|
||||
if key >= defines.GLFW_KEY_LAST or key == defines.GLFW_KEY_UNKNOWN or (
|
||||
# Shifted printable key should be handled by on_text_input()
|
||||
mods <= defines.GLFW_MOD_SHIFT and 32 <= key <= 126
|
||||
mods <= defines.GLFW_MOD_SHIFT and defines.GLFW_KEY_SPACE <= key <= defines.GLFW_KEY_LAST_PRINTABLE
|
||||
):
|
||||
return b''
|
||||
if mods == 0 and key in (
|
||||
@@ -289,12 +289,7 @@ def shortcut_matches(s, mods, key, scancode):
|
||||
return s[0] & 0b1111 == mods & 0b1111 and s[2] == q
|
||||
|
||||
|
||||
def generate_key_table():
|
||||
# To run this, use: python3 . +runpy "from kitty.keys import *; generate_key_table()"
|
||||
import os
|
||||
from functools import partial
|
||||
f = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'keys.h'), 'w')
|
||||
w = partial(print, file=f)
|
||||
def generate_key_table_impl(w):
|
||||
w('// auto-generated from keys.py, do not edit!')
|
||||
w('#pragma once')
|
||||
w('#include <stddef.h>')
|
||||
@@ -309,7 +304,7 @@ def generate_key_table():
|
||||
def key_name(k):
|
||||
return k[len('GLFW_KEY_'):]
|
||||
|
||||
keys = {v: k for k, v in vars(defines).items() if k.startswith('GLFW_KEY_') and k not in {'GLFW_KEY_LAST', 'GLFW_KEY_UNKNOWN'}}
|
||||
keys = {v: k for k, v in vars(defines).items() if k.startswith('GLFW_KEY_') and k not in {'GLFW_KEY_LAST', 'GLFW_KEY_LAST_PRINTABLE', 'GLFW_KEY_UNKNOWN'}}
|
||||
key_rmap = []
|
||||
for i in range(number_of_keys):
|
||||
k = keys.get(i)
|
||||
@@ -319,7 +314,7 @@ def generate_key_table():
|
||||
w('%d, /* %s */' % (key_count, key_name(k)))
|
||||
key_rmap.append(i)
|
||||
key_count += 1
|
||||
if key_count > 128:
|
||||
if key_count > 256:
|
||||
raise OverflowError('Too many keys')
|
||||
w('};\n')
|
||||
w('static inline const char* key_name(int key) { switch(key) {')
|
||||
@@ -359,7 +354,7 @@ def generate_key_table():
|
||||
ind('case 0x{:x}:'.format(mods))
|
||||
i += 1
|
||||
if key_bytes:
|
||||
ind('switch(key & 0x7f) { default: return NULL;')
|
||||
ind('switch(key & 0xff) { default: return NULL;')
|
||||
i += 1
|
||||
for key, (data, glfw_key) in key_bytes.items():
|
||||
ind('case {}: // {}'.format(key, key_name(keys[glfw_key])))
|
||||
@@ -389,3 +384,12 @@ def generate_key_table():
|
||||
ind('return NULL;')
|
||||
i -= 1
|
||||
w('}')
|
||||
|
||||
|
||||
def generate_key_table():
|
||||
# To run this, use: python3 . +runpy "from kitty.keys import *; generate_key_table()"
|
||||
import os
|
||||
from functools import partial
|
||||
with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'keys.h'), 'w') as f:
|
||||
w = partial(print, file=f)
|
||||
generate_key_table_impl(w)
|
||||
|
||||
@@ -398,16 +398,17 @@ as_ansi(LineBuf *self, PyObject *callback) {
|
||||
// remove trailing empty lines
|
||||
index_type ylimit = self->ynum - 1;
|
||||
bool truncated;
|
||||
const GPUCell *prev_cell = NULL;
|
||||
do {
|
||||
init_line(self, (&l), self->line_map[ylimit]);
|
||||
if (line_as_ansi(&l, t, 5120, &truncated) != 0) break;
|
||||
if (line_as_ansi(&l, t, 5120, &truncated, &prev_cell) != 0) break;
|
||||
ylimit--;
|
||||
} while(ylimit > 0);
|
||||
|
||||
for(index_type i = 0; i <= ylimit; i++) {
|
||||
l.continued = ((i < self->ynum - 1) ? self->line_attrs[i+1] : self->line_attrs[i]) & CONTINUED_MASK;
|
||||
init_line(self, (&l), self->line_map[i]);
|
||||
index_type num = line_as_ansi(&l, t, 5120, &truncated);
|
||||
index_type num = line_as_ansi(&l, t, 5120, &truncated, &prev_cell);
|
||||
if (!(l.continued) && num < 5119) t[num++] = 10; // 10 = \n
|
||||
PyObject *ans = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, t, num);
|
||||
if (ans == NULL) return PyErr_NoMemory();
|
||||
|
||||
67
kitty/line.c
67
kitty/line.c
@@ -187,15 +187,19 @@ size_t
|
||||
cell_as_unicode_for_fallback(CPUCell *cell, Py_UCS4 *buf) {
|
||||
size_t n = 1;
|
||||
buf[0] = cell->ch ? cell->ch : ' ';
|
||||
for (unsigned i = 0; i < arraysz(cell->cc_idx) && cell->cc_idx[i]; i++) {
|
||||
if (cell->cc_idx[i] != VS15 && cell->cc_idx[i] != VS16) buf[n++] = codepoint_for_mark(cell->cc_idx[i]);
|
||||
}
|
||||
if (buf[0] != '\t') {
|
||||
for (unsigned i = 0; i < arraysz(cell->cc_idx) && cell->cc_idx[i]; i++) {
|
||||
if (cell->cc_idx[i] != VS15 && cell->cc_idx[i] != VS16) buf[n++] = codepoint_for_mark(cell->cc_idx[i]);
|
||||
}
|
||||
} else buf[0] = ' ';
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t
|
||||
cell_as_utf8(CPUCell *cell, bool include_cc, char *buf, char_type zero_char) {
|
||||
size_t n = encode_utf8(cell->ch ? cell->ch : zero_char, buf);
|
||||
char_type ch = cell->ch ? cell->ch : zero_char;
|
||||
if (ch == '\t') { include_cc = false; }
|
||||
size_t n = encode_utf8(ch, buf);
|
||||
if (include_cc) {
|
||||
for (unsigned i = 0; i < arraysz(cell->cc_idx) && cell->cc_idx[i]; i++) n += encode_utf8(codepoint_for_mark(cell->cc_idx[i]), buf + n);
|
||||
}
|
||||
@@ -205,10 +209,15 @@ cell_as_utf8(CPUCell *cell, bool include_cc, char *buf, char_type zero_char) {
|
||||
|
||||
size_t
|
||||
cell_as_utf8_for_fallback(CPUCell *cell, char *buf) {
|
||||
size_t n = encode_utf8(cell->ch ? cell->ch : ' ', buf);
|
||||
for (unsigned i = 0; i < arraysz(cell->cc_idx) && cell->cc_idx[i]; i++) {
|
||||
if (cell->cc_idx[i] != VS15 && cell->cc_idx[i] != VS16) {
|
||||
n += encode_utf8(codepoint_for_mark(cell->cc_idx[i]), buf + n);
|
||||
char_type ch = cell->ch ? cell->ch : ' ';
|
||||
bool include_cc = true;
|
||||
if (ch == '\t') { ch = ' '; include_cc = false; }
|
||||
size_t n = encode_utf8(ch, buf);
|
||||
if (include_cc) {
|
||||
for (unsigned i = 0; i < arraysz(cell->cc_idx) && cell->cc_idx[i]; i++) {
|
||||
if (cell->cc_idx[i] != VS15 && cell->cc_idx[i] != VS16) {
|
||||
n += encode_utf8(codepoint_for_mark(cell->cc_idx[i]), buf + n);
|
||||
}
|
||||
}
|
||||
}
|
||||
buf[n] = 0;
|
||||
@@ -228,7 +237,16 @@ unicode_in_range(Line *self, index_type start, index_type limit, bool include_cc
|
||||
if (ch == 0) {
|
||||
if (previous_width == 2) { previous_width = 0; continue; };
|
||||
}
|
||||
n += cell_as_unicode(self->cpu_cells + i, include_cc, buf + n, ' ');
|
||||
if (ch == '\t') {
|
||||
buf[n++] = '\t';
|
||||
unsigned num_cells_to_skip_for_tab = self->cpu_cells[i].cc_idx[0];
|
||||
while (num_cells_to_skip_for_tab && i + 1 < limit && self->cpu_cells[i+1].ch == ' ') {
|
||||
i++;
|
||||
num_cells_to_skip_for_tab--;
|
||||
}
|
||||
} else {
|
||||
n += cell_as_unicode(self->cpu_cells + i, include_cc, buf + n, ' ');
|
||||
}
|
||||
previous_width = self->gpu_cells[i].attrs & WIDTH_MASK;
|
||||
}
|
||||
return PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, buf, n);
|
||||
@@ -258,7 +276,7 @@ write_sgr(const char *val, Py_UCS4 *buf, index_type buflen, index_type *i) {
|
||||
}
|
||||
|
||||
index_type
|
||||
line_as_ansi(Line *self, Py_UCS4 *buf, index_type buflen, bool *truncated) {
|
||||
line_as_ansi(Line *self, Py_UCS4 *buf, index_type buflen, bool *truncated, const GPUCell** prev_cell) {
|
||||
#define WRITE_SGR(val) { if (!write_sgr(val, buf, buflen, &i)) { *truncated = true; return i; } }
|
||||
#define WRITE_CH(val) if (i > buflen - 1) { *truncated = true; return i; } buf[i++] = val;
|
||||
|
||||
@@ -267,8 +285,9 @@ line_as_ansi(Line *self, Py_UCS4 *buf, index_type buflen, bool *truncated) {
|
||||
if (limit == 0) return 0;
|
||||
char_type previous_width = 0;
|
||||
|
||||
GPUCell blank_cell = { 0 };
|
||||
GPUCell *cell, *prev_cell = &blank_cell;
|
||||
static const GPUCell blank_cell = { 0 };
|
||||
GPUCell *cell;
|
||||
if (*prev_cell == NULL) *prev_cell = &blank_cell;
|
||||
|
||||
for (index_type pos=0; pos < limit; pos++) {
|
||||
char_type ch = self->cpu_cells[pos].ch;
|
||||
@@ -279,16 +298,23 @@ line_as_ansi(Line *self, Py_UCS4 *buf, index_type buflen, bool *truncated) {
|
||||
|
||||
cell = &self->gpu_cells[pos];
|
||||
|
||||
#define CMP_ATTRS (cell->attrs & ATTRS_MASK_WITHOUT_WIDTH) != (prev_cell->attrs & ATTRS_MASK_WITHOUT_WIDTH)
|
||||
#define CMP(x) cell->x != prev_cell->x
|
||||
#define CMP_ATTRS (cell->attrs & ATTRS_MASK_WITHOUT_WIDTH) != ((*prev_cell)->attrs & ATTRS_MASK_WITHOUT_WIDTH)
|
||||
#define CMP(x) cell->x != (*prev_cell)->x
|
||||
if (CMP_ATTRS || CMP(fg) || CMP(bg) || CMP(decoration_fg)) {
|
||||
const char *sgr = cell_as_sgr(cell, prev_cell);
|
||||
const char *sgr = cell_as_sgr(cell, *prev_cell);
|
||||
if (*sgr) WRITE_SGR(sgr);
|
||||
}
|
||||
prev_cell = cell;
|
||||
*prev_cell = cell;
|
||||
WRITE_CH(ch);
|
||||
for(unsigned c = 0; c < arraysz(self->cpu_cells[pos].cc_idx) && self->cpu_cells[pos].cc_idx[c]; c++) {
|
||||
WRITE_CH(codepoint_for_mark(self->cpu_cells[pos].cc_idx[c]));
|
||||
if (ch == '\t') {
|
||||
unsigned num_cells_to_skip_for_tab = self->cpu_cells[pos].cc_idx[0];
|
||||
while (num_cells_to_skip_for_tab && pos + 1 < limit && self->cpu_cells[pos+1].ch == ' ') {
|
||||
num_cells_to_skip_for_tab--; pos++;
|
||||
}
|
||||
} else {
|
||||
for(unsigned c = 0; c < arraysz(self->cpu_cells[pos].cc_idx) && self->cpu_cells[pos].cc_idx[c]; c++) {
|
||||
WRITE_CH(codepoint_for_mark(self->cpu_cells[pos].cc_idx[c]));
|
||||
}
|
||||
}
|
||||
previous_width = cell->attrs & WIDTH_MASK;
|
||||
}
|
||||
@@ -304,7 +330,8 @@ as_ansi(Line* self, PyObject *a UNUSED) {
|
||||
#define as_ansi_doc "Return the line's contents with ANSI (SGR) escape codes for formatting"
|
||||
static Py_UCS4 t[5120] = {0};
|
||||
bool truncated;
|
||||
index_type num = line_as_ansi(self, t, 5120, &truncated);
|
||||
const GPUCell *prev_cell = NULL;
|
||||
index_type num = line_as_ansi(self, t, 5120, &truncated, &prev_cell);
|
||||
PyObject *ans = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, t, num);
|
||||
return ans;
|
||||
}
|
||||
@@ -589,7 +616,7 @@ decoration_as_sgr(uint8_t decoration) {
|
||||
|
||||
|
||||
const char*
|
||||
cell_as_sgr(GPUCell *cell, GPUCell *prev) {
|
||||
cell_as_sgr(const GPUCell *cell, const GPUCell *prev) {
|
||||
static char buf[128];
|
||||
#define SZ sizeof(buf) - (p - buf) - 2
|
||||
#define P(s) { size_t len = strlen(s); if (SZ > len) { memcpy(p, s, len); p += len; } }
|
||||
|
||||
@@ -61,7 +61,7 @@ void line_right_shift(Line *, unsigned int , unsigned int );
|
||||
void line_add_combining_char(Line *, uint32_t , unsigned int );
|
||||
index_type line_url_start_at(Line *self, index_type x);
|
||||
index_type line_url_end_at(Line *self, index_type x, bool, char_type);
|
||||
index_type line_as_ansi(Line *self, Py_UCS4 *buf, index_type buflen, bool*);
|
||||
index_type line_as_ansi(Line *self, Py_UCS4 *buf, index_type buflen, bool*, const GPUCell**) __attribute__((nonnull));
|
||||
unsigned int line_length(Line *self);
|
||||
size_t cell_as_unicode(CPUCell *cell, bool include_cc, Py_UCS4 *buf, char_type);
|
||||
size_t cell_as_unicode_for_fallback(CPUCell *cell, Py_UCS4 *buf);
|
||||
@@ -100,6 +100,7 @@ void historybuf_clear(HistoryBuf *self);
|
||||
Py_UCS4 *buf = NULL; \
|
||||
PyObject *nl = PyUnicode_FromString("\n"); \
|
||||
PyObject *cr = PyUnicode_FromString("\r"); \
|
||||
const GPUCell *prev_cell = NULL; \
|
||||
if (nl == NULL || cr == NULL) goto end; \
|
||||
if (as_ansi) { \
|
||||
buf = malloc(sizeof(Py_UCS4) * columns * 100); \
|
||||
@@ -114,7 +115,7 @@ void historybuf_clear(HistoryBuf *self);
|
||||
} \
|
||||
if (as_ansi) { \
|
||||
bool truncated; \
|
||||
index_type num = line_as_ansi(line, buf, columns * 100 - 2, &truncated); \
|
||||
index_type num = line_as_ansi(line, buf, columns * 100 - 2, &truncated, &prev_cell); \
|
||||
t = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, buf, num); \
|
||||
} else { \
|
||||
t = line_as_unicode(line); \
|
||||
|
||||
@@ -76,7 +76,7 @@ free_loop_data(LoopData *ld) {
|
||||
|
||||
|
||||
void
|
||||
wakeup_loop(LoopData *ld, bool in_signal_handler) {
|
||||
wakeup_loop(LoopData *ld, bool in_signal_handler, const char *loop_name) {
|
||||
while(true) {
|
||||
#ifdef HAS_EVENT_FD
|
||||
static const int64_t value = 1;
|
||||
@@ -86,7 +86,7 @@ wakeup_loop(LoopData *ld, bool in_signal_handler) {
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
if (errno == EINTR) continue;
|
||||
if (!in_signal_handler) log_error("Failed to write to loop wakeup fd with error: %s", strerror(errno));
|
||||
if (!in_signal_handler) log_error("Failed to write to %s wakeup fd with error: %s", loop_name, strerror(errno));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ typedef void(*handle_signal_func)(int, void *data);
|
||||
|
||||
bool init_loop_data(LoopData *ld);
|
||||
void free_loop_data(LoopData *ld);
|
||||
void wakeup_loop(LoopData *ld, bool in_signal_handler);
|
||||
void wakeup_loop(LoopData *ld, bool in_signal_handler, const char*);
|
||||
bool install_signal_handlers(LoopData *ld);
|
||||
void read_signals(int fd, handle_signal_func callback, void *data);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user