Compare commits

..

2901 Commits

Author SHA1 Message Date
Kovid Goyal
79b130ed23 version 0.21.1 2021-06-14 07:47:32 +05:30
Kovid Goyal
75e8b16ea3 Dont limit the number of possible cocoa pending actions to the number of bits in an int 2021-06-14 07:34:28 +05:30
Kovid Goyal
1b35708d89 macOS: Fix a crash when rendering ligatures larger than 128 characters
Fixes #3724
2021-06-14 07:15:52 +05:30
Kovid Goyal
ebff343a55 macOS: Add reload config to kitty global menu 2021-06-13 20:34:27 +05:30
Kovid Goyal
c7b91e5f19 Cocoa grabs control+function key presses so use dedicated cmd based shortcuts for those on macOS 2021-06-13 18:20:14 +05:30
Kovid Goyal
b9d52dfaf7 Update Changelog 2021-06-13 10:01:38 +05:30
Kovid Goyal
2c8f66586f macOS: Fix a regression in the previous release that broke rendering of strikeout
The new cell height code forgot to adjust strikeout position.
Fixes #3717
2021-06-13 09:29:30 +05:30
Kovid Goyal
219bf564f7 Fix #3719 2021-06-13 09:07:08 +05:30
Kovid Goyal
291be6f5a6 Silence incorrect compiler warning on older gcc 2021-06-12 13:15:05 +05:30
Kovid Goyal
1da2344aa3 Fix a possible crash when handling mouse clicks 2021-06-12 13:03:47 +05:30
Kovid Goyal
750cf7ad20 version 0.21.0 2021-06-12 08:41:37 +05:30
Kovid Goyal
962acd1537 ssh kitten: Fix non-standard properties in terminfo such as the ones used for true color not being copied 2021-06-12 07:27:14 +05:30
Kovid Goyal
7a44765860 Remove unused pyc files from frozen bundles 2021-06-11 12:46:12 +05:30
Kovid Goyal
007be8e52c Add a note about matching source to binary versions 2021-06-11 09:14:05 +05:30
Kovid Goyal
5e4c98eae6 Remote control: Allow matching tabs by index number in currently active OS Window
Fixes #3708
2021-06-11 09:12:08 +05:30
Kovid Goyal
858a6dc27e Document KITTY_DEVELOP_FROM 2021-06-11 08:59:55 +05:30
Kovid Goyal
ad5d14c672 Fix #3703 2021-06-10 16:53:27 +05:30
Kovid Goyal
199685a25b Graphics protocol: Add support for shared memory on Windows 2021-06-10 12:44:50 +05:30
Kovid Goyal
d99e243f57 Respect --ignore-compiler-warnings when building the launcher 2021-06-10 07:48:52 +05:30
Kovid Goyal
64f1211cf8 Fix example in FAQ
Mapping wont work in kitty keyboard mode.
2021-06-09 20:46:36 +05:30
Kovid Goyal
9432f86e43 Remove no longer needed type: ignore
Looks like the type signature for runpy.run_path has finally been fixed
2021-06-09 08:30:22 +05:30
Kovid Goyal
fc99d4d757 Specify the type of files to make mypy happy (I hope) 2021-06-09 08:24:36 +05:30
Kovid Goyal
7fb2b21a22 Also needs types for docutils 2021-06-09 08:18:04 +05:30
Kovid Goyal
260b300da9 Now mypy wants types for requests installed 2021-06-09 08:14:02 +05:30
Kovid Goyal
f26d5b02cb ... 2021-06-09 08:01:46 +05:30
Kovid Goyal
c9ff061feb Merge branch 'leiserfg-doc-patch' of https://github.com/leiserfg/kitty 2021-06-08 08:11:51 +05:30
Leiser Fernández Gallo
86ad318e6c Fix Iosevka version in the docs
Iosevka with kitty support is already out, just waiting for kitty to be released too 🎉
2021-06-07 17:36:40 +02:00
Kovid Goyal
df05339d2a Allow reloading config by sending the SIGUSR1 signal 2021-06-07 20:51:45 +05:30
Kovid Goyal
ec1303a232 Fix some more warnings 2021-06-07 17:30:13 +05:30
Kovid Goyal
c1049734e6 Simpler implementation of scroll and clear screen 2021-06-07 17:13:39 +05:30
Kovid Goyal
99fa79caaf Fix warning 2021-06-07 17:12:53 +05:30
Kovid Goyal
761062a6d7 Discard press event for ctrl+shift+release open_url mapping as it can causes issues when delivered to the terminal program 2021-06-07 17:00:09 +05:30
Kovid Goyal
11227b3ee1 Fix motivation for ctrl+shift+release mapping 2021-06-07 16:36:39 +05:30
Kovid Goyal
8d63d50aea Sort imports 2021-06-07 15:01:30 +05:30
Kovid Goyal
3360aa6c33 Fix #3695 2021-06-07 14:57:38 +05:30
Kovid Goyal
bfffd98fd4 Add a changelog entry for config reloading
Fixes #1292
2021-06-07 09:38:41 +05:30
Kovid Goyal
9a86184a45 Add a note about binding ctrl+l to scroll and clear instead of just clear 2021-06-07 09:35:08 +05:30
Kovid Goyal
00828cb804 More reloading work for various options 2021-06-07 09:30:15 +05:30
Kovid Goyal
ec31a36fd9 Fix reloading of various settings 2021-06-07 08:27:58 +05:30
Kovid Goyal
9003c76261 Add a shortcut to reload the config file 2021-06-06 18:49:58 +05:30
Kovid Goyal
7148f262c0 Reload for keys, fonts and colors now working 2021-06-06 14:31:22 +05:30
Kovid Goyal
3ab417e291 Start work on config file reloading 2021-06-05 15:29:28 +05:30
Kovid Goyal
4ced7b7657 Missed one reference to --debug-config 2021-06-05 15:12:52 +05:30
Kovid Goyal
ad69143573 Improve config debug output for is_multiple variables 2021-06-05 14:39:43 +05:30
Kovid Goyal
4a71afaf96 Get rid of --debug-config
Instead have a keybind that shows the configuration used
by the currently running kitty instance
2021-06-05 14:27:24 +05:30
Kovid Goyal
a1b87f445b Store the paths from which config data is read on the created options object 2021-06-05 12:55:00 +05:30
Kovid Goyal
33e63f000a Make mouse mapping gen-config order stable 2021-06-05 12:22:54 +05:30
Kovid Goyal
1c8b7955eb Have gen-config output action names as comments 2021-06-05 12:20:43 +05:30
Kovid Goyal
0bade29c25 Fix a gen-config bug that was causing macos shortcuts to be defined on linux as well 2021-06-05 10:14:30 +05:30
Kovid Goyal
4cff3e51cb macOS: Add a global menu entry to reset the terminal 2021-06-05 10:12:44 +05:30
Kovid Goyal
d264c3d91e typo 2021-06-05 10:10:23 +05:30
Kovid Goyal
099fed07e9 Note that set-font-size --all changes configured size 2021-06-05 09:39:10 +05:30
Kovid Goyal
091fec0867 Add tab bar margin height to changelog
Fixes #3685
Fixes #3247
2021-06-05 09:18:52 +05:30
Kovid Goyal
a670268a6b Add blank rects for tab bar padding 2021-06-05 09:16:24 +05:30
Kovid Goyal
caa44b3d4a Position tab bar as per new margin options
Also mouse clicking anywhere in the tab bar margins should be the same
as clicking in the tab bar, for ease of use.
2021-06-05 09:02:01 +05:30
Kovid Goyal
f3977da8f3 Start work on options for tab bar vertical margins
Create the option, now need to implement it.
2021-06-05 09:01:57 +05:30
Kovid Goyal
7dc3184f31 ... 2021-06-04 22:00:15 +05:30
Kovid Goyal
d09c20aa01 Store the global font_size on the opts object where it belongs 2021-06-04 21:51:02 +05:30
Kovid Goyal
81411e6b54 Fix trailing parentheses in URLs not being detected
Also fix URLs starting near the end of the line not being detected.

Fixes #3688
2021-06-04 18:13:36 +05:30
Kovid Goyal
a8d1c73fec API to get text for currently marked URL 2021-06-04 14:35:22 +05:30
Kovid Goyal
1b3742efbb Add a link to Iosevka in the changelog 2021-06-04 12:20:27 +05:30
Kovid Goyal
e01bb09e8c Fix ligatures not working with the Iosevka font
Fixes #297
2021-06-04 12:18:17 +05:30
Kovid Goyal
2c9c0751a4 Speed up import of options.types
The color table attributes are never used in a type checked
environment, only via setattr/gettattr so dont create individual
get/setters for them. Reduaces the import time for this module from 2ms
to 0.7ms

Since attribute access is implemented via __getattr__ there should be no
performance implications for normal attribute access, as __getattr__ is
only called if normal attribute access fails. setattr becomes slightly
slower but that is done very rarely.
2021-06-04 06:01:55 +05:30
Kovid Goyal
e10a7579e8 Remove unreachable code 2021-06-04 05:40:27 +05:30
Kovid Goyal
c52a04c7d3 Use a tuple for clipboard control
Avoids churn in the generated options files as python randomized set
ordering
2021-06-04 05:36:05 +05:30
Kovid Goyal
79dd98b20e Use a more efficient representation of the color table on the Options object 2021-06-03 22:17:37 +05:30
Kovid Goyal
2e71429b03 Auto generate the boilerplate code to convert python opts to c opts 2021-06-03 18:30:13 +05:30
Kovid Goyal
4ab299d0af When reflowing the screen, also reflow the saved cursor position 2021-06-03 15:35:48 +05:30
Kovid Goyal
c60a941d1b Allow rewrap_inner to track multiple positions 2021-06-03 12:29:27 +05:30
Kovid Goyal
e2197c586b Forgot a brace 2021-06-03 12:11:31 +05:30
Kovid Goyal
93e9d3cb5f Fix a crash on exit on macOS
Calling Python API functions is not allowed in atexit handlers.

Fixes #3686
2021-06-03 11:54:55 +05:30
Kovid Goyal
2e7b68bf74 Move python to C converters into their own header 2021-06-01 21:18:39 +05:30
Kovid Goyal
6ffb198e9c DRYer 2021-06-01 21:15:36 +05:30
Kovid Goyal
604458810e Start work on autogenerating opts to c conversion boilerplate 2021-06-01 13:33:19 +05:30
Kovid Goyal
af5ed093b8 Fix test failing on macOS 2021-05-31 17:54:57 +05:30
Kovid Goyal
8f491e7dbb Add newslines at end of generated files and do imports in sorted order 2021-05-31 17:45:02 +05:30
Kovid Goyal
c1324da3fc missing newline in debug print 2021-05-31 17:42:10 +05:30
Kovid Goyal
0bbc4462fd Coalesce shortcuts as well 2021-05-31 17:40:49 +05:30
Kovid Goyal
e0261e925e DRYer 2021-05-31 17:40:49 +05:30
Kovid Goyal
46b3f71b8f Start work on porting docs generation 2021-05-31 17:40:49 +05:30
Kovid Goyal
3e598a17cf Add headers to options def files 2021-05-31 17:40:49 +05:30
Kovid Goyal
c1b13f2db2 DRYer 2021-05-31 17:40:49 +05:30
Kovid Goyal
a059e49579 Restore conf file generation in the new framework 2021-05-31 17:40:49 +05:30
Kovid Goyal
6d7df1c5e8 Refactor configuration file parsing
Now the time for importing the kitty.config module has been halved, from
16ms from 32ms on my machine. Also, the new architecture will eventually
allow for auto generating a bunch of python-to-C boilerplate code.
2021-05-31 17:40:49 +05:30
Kovid Goyal
dd5715ce79 Rename parsing placeholders for actions 2021-05-31 17:40:48 +05:30
Kovid Goyal
43acf3c5b1 name parser for deprecated send text appropriately 2021-05-31 17:40:48 +05:30
Kovid Goyal
f7db9e3527 Move deprecated parsers into utils 2021-05-31 17:40:48 +05:30
Kovid Goyal
1621a67f36 unused import 2021-05-31 17:40:48 +05:30
Kovid Goyal
248631a1a8 Add tests for conf parsing 2021-05-31 17:40:48 +05:30
Kovid Goyal
b4cb6e10ca Dont resolve kitty_mod in the defaults key definitions
Needed to allow multiple load_config calls
2021-05-31 17:40:48 +05:30
Kovid Goyal
5fa73e4413 Dont use a unneccessary global variable 2021-05-31 17:40:48 +05:30
Kovid Goyal
49c4b20113 Report bad choice values when parsing config 2021-05-31 17:40:48 +05:30
Kovid Goyal
43ece23b89 the args for KeyAction are not just strings 2021-05-31 17:40:48 +05:30
Kovid Goyal
f976851442 Make the repr for KeyAction more compact 2021-05-31 17:40:48 +05:30
Kovid Goyal
5470dd74bd Move options code into its own directory 2021-05-31 17:40:48 +05:30
Kovid Goyal
ddd178fa82 Move clear_all_shortcuts to options_types 2021-05-31 17:40:48 +05:30
Kovid Goyal
8d411cac5f ... 2021-05-31 17:40:48 +05:30
Kovid Goyal
bfbb85399e Move action parsing to option_types 2021-05-31 17:40:47 +05:30
Kovid Goyal
9f8a120664 Add __repr__ for action definitions 2021-05-31 17:40:47 +05:30
Kovid Goyal
e1cd6b6037 kitten_alias is also an is_multiple option 2021-05-31 17:40:47 +05:30
Kovid Goyal
2fd4487922 Better naming of action parsers 2021-05-31 17:40:47 +05:30
Kovid Goyal
27a459b0dd Refactor action parsers as generators 2021-05-31 17:40:47 +05:30
Kovid Goyal
6c344d4ae2 Move the action parsing code into options_types 2021-05-31 17:40:47 +05:30
Kovid Goyal
d7aa9952d8 Fix a regression that caused using the `title` command in session files to stop working
Fixes #3676
2021-05-31 09:31:29 +05:30
Kovid Goyal
09093c8f3e Cleanup PR 2021-05-30 12:47:00 +05:30
Kovid Goyal
222bf09df4 Merge branch 'libstartup-notification' of https://github.com/ctrlcctrlv/kitty 2021-05-30 12:45:13 +05:30
Fredrick Brennan
3041ff8d25 Downgrade libstartup-notification-1.so non-existence to warning
I'm not sure how common this library actually is. On my system, an Arch
Linux system with 2,170 packages installed, including KDE (Plasma), I
didn't have it.

It's downgraded to a warning instead of printing a traceback.
2021-05-30 03:05:42 -04:00
Kovid Goyal
bfe1952705 Merge branch 'less-contrast-for-powerline-alt-separator' of https://github.com/chipaca/kitty 2021-05-30 07:37:41 +05:30
John R. Lenton
97181a39da Use less contrasting color for powerline alt separator
This change makes it so that when using powerline-style tab bars, and
if the `tab_bar_background`, `inactive_tab_background` and
`inactive_tab_foreground` are all different, the separator between
inactive tabs uses the less contrasting color between the inactive
foreground, and the tab bar background.

This fixes #3664.
2021-05-29 16:54:51 +01:00
Kovid Goyal
39b3d3de0f macOS: Fix the baseline for text not matching other CoreText based applications for some fonts
Finally found an API to query CoreText for the adjusted baseline
position, so the baseline should now match up with other CoreText
based applications.

Fixes #2022
2021-05-29 14:19:20 +05:30
Kovid Goyal
056d16017f Fix #3660 2021-05-28 05:33:12 +05:30
Kovid Goyal
5cef0aef92 Update changelog for last PR 2021-05-25 18:19:34 +05:30
Kovid Goyal
f794de5b9b Merge branch 'new-menu-items' of https://github.com/Luflosi/kitty 2021-05-25 18:18:32 +05:30
Luflosi
4a67af9b90 macOS: add menu items for new_window and close_window 2021-05-25 13:54:02 +02:00
Kovid Goyal
f178dff4e0 Remove the special_types kludge for is_multiple options 2021-05-25 11:25:39 +05:30
Kovid Goyal
ba821cb02f DOnt be lazy about typing font features 2021-05-25 09:29:47 +05:30
Kovid Goyal
b169831810 remove unused import 2021-05-25 09:00:54 +05:30
Kovid Goyal
06b3c71304 Make is_multiple explicit 2021-05-25 08:46:26 +05:30
Kovid Goyal
fe94f4cbb4 Move type parsers for config into own module 2021-05-24 22:29:28 +05:30
Kovid Goyal
a4daa49f70 Micro-optimization 2021-05-24 17:11:20 +05:30
Kovid Goyal
3b1d534f6d The parser doesnt need the full defaults object 2021-05-24 14:01:50 +05:30
Kovid Goyal
c1777b1098 DRYer 2021-05-24 13:42:51 +05:30
Kovid Goyal
c827a29a7b Use the new get_options() function
Nicer than carrying around opts objects everywhere
2021-05-24 12:29:11 +05:30
Kovid Goyal
253b219d67 Store the options object globally 2021-05-24 11:50:03 +05:30
Kovid Goyal
b702f3daf1 In extend from point mode always restrict the top line to be from the point, even for multiline selections
Otherwise soft wrapped lines cause the full first line to be selected.
2021-05-23 15:52:48 +05:30
Kovid Goyal
76c9f46438 Disambiguate between click and doublepress
A doubleprpess should not generate a click event
2021-05-23 13:38:19 +05:30
Kovid Goyal
c6c203da43 Remove unused imports 2021-05-23 11:48:30 +05:30
Kovid Goyal
00302b74d1 Add a default mapping for line_from_point selection 2021-05-23 11:37:26 +05:30
Kovid Goyal
32f6f18527 DRYer 2021-05-23 11:22:29 +05:30
Kovid Goyal
4fd0446538 Merge branch 'new-menu-bar-item' of https://github.com/Luflosi/kitty 2021-05-22 06:03:32 +05:30
Luflosi
082ad61d14 macOS: move menu bar items for opening and closing OS windows and tabs to new menu
Most apps on macOS have the menu items for opening and closing tabs and windows in the "File" menu. Since this doesn't really apply to Terminal emulators, both Terminal.app and iTerm2 have them in the "Shell" menu instead.
This change makes the menu bar of kitty more consistent with these applications.
2021-05-21 18:21:31 +02:00
Kovid Goyal
0ca4faa25b New OS window -> New OS Window 2021-05-21 17:57:53 +05:30
Kovid Goyal
46a0566e2e Special handling for IOSevka's future ligatures
See https://github.com/be5invis/Iosevka/issues/1007
2021-05-21 17:53:49 +05:30
Kovid Goyal
97440d45d6 Add an example showing how to run things in scripts via launch 2021-05-21 16:02:05 +05:30
Kovid Goyal
c5afe4e745 Merge branch 'feat/undercurl-retina' of https://github.com/disrupted/kitty 2021-05-21 08:30:21 +05:30
Kovid Goyal
bc6e819396 typos in text 2021-05-19 20:35:43 +05:30
disrupted
d650a97dda Fix undercurl height & thickness on HiDPI screens
Update positioning
2021-05-18 19:00:46 +02:00
Kovid Goyal
cf88eb9d60 ssh kitten: Mimic behavior of ssh more closely
Execute any command specified on the command line via the users' shell
on the remote side just as ssh does

Fixes #3638
2021-05-18 15:12:57 +05:30
Kovid Goyal
0a742ea8d0 middle is more common than start or end 2021-05-18 09:55:00 +05:30
Kovid Goyal
cb8935746f Pass the font group to init_face
Allows using the DPI there if needed
2021-05-18 07:58:32 +05:30
Kovid Goyal
608ac953e5 Pass DPI through to special render function 2021-05-18 07:46:04 +05:30
Kovid Goyal
4d0d0b205d Improve parser error messages a bit 2021-05-17 21:29:54 +05:30
Kovid Goyal
07b643e24c Remove expected behavior section from issue template
Its largely redundant and a waste of time. Not to mention
no one likes being told what's expected of them :))
2021-05-17 18:38:46 +05:30
Kovid Goyal
02fb020dfd Better fix for minimal border layout issue
Keep _set_dimensions() private
2021-05-17 15:30:03 +05:30
Kovid Goyal
bac6ebdf95 Fix incorrect border drawing when multiple tabs and multiple OS Windows are present and some of the OS Windows have tab bars and some dont
Fixes #3634
2021-05-17 15:04:33 +05:30
Kovid Goyal
b7072d4097 Mention how to unmap mouse actions 2021-05-17 08:26:12 +05:30
Kovid Goyal
d7c7bb00b8 Merge branch 'master' of https://github.com/copy/kitty 2021-05-17 07:42:13 +05:30
Fabian
0485f0c7ed kitty @ get-text add an option to wrap long lines 2021-05-16 15:19:22 -05:00
Kovid Goyal
2ade6c0739 Update outdated info in build docs 2021-05-16 21:22:33 +05:30
Kovid Goyal
5eeb19871b Update dependency requirements for build from source 2021-05-16 21:20:11 +05:30
Kovid Goyal
083a0ae5fc ... 2021-05-16 09:33:06 +05:30
Kovid Goyal
ccc370e1c4 Dont initialize FontConfig when importing fast_data_types
This reduces the import time for fast_data_types by 12ms on my machine.
FontConfig initialization is very slow and it is only needed by the
main kitty program, however fast_data_types is imported in kittens and
remote control as well, where FontConfig is useless.
2021-05-15 10:41:54 +05:30
Kovid Goyal
23b8cafc41 Add layout name completion to @ goto-layout 2021-05-15 10:25:34 +05:30
Kovid Goyal
d7ab96856c ... 2021-05-15 09:42:52 +05:30
Kovid Goyal
3c77229f61 Add --no-response to set-background-image 2021-05-15 09:41:22 +05:30
Kovid Goyal
fcd206891f kitty @ get-text add an option to also get the current cursor position and state as ANSI escape codes
Fixes #3625
2021-05-15 09:27:28 +05:30
Kovid Goyal
3bf9130b0a Fix deleting windows that are not the last window via remote control leaving no window focused
Fixes #3619
2021-05-14 07:25:48 +05:30
Kovid Goyal
4125ac013f Validate command line args to @ goto-layout better 2021-05-13 20:46:37 +05:30
Kovid Goyal
e089e9c121 Clarify what --debug-config does 2021-05-13 20:19:34 +05:30
Kovid Goyal
81af379bbc correct spelling 2021-05-13 17:46:21 +05:30
Kovid Goyal
9b07aa6894 Simplify Quickstart section by delegating repo link to repology.org
Also add a warning about some Linux distros with outdated packages.
2021-05-13 17:42:29 +05:30
Kovid Goyal
a75140c6d7 Add a --working-directory alias for --directory as this is commonly used in many terminal emulators 2021-05-13 16:13:46 +05:30
Kovid Goyal
f3364cfdc0 Guard against invalid cache file in a couple more places 2021-05-13 09:51:57 +05:30
Kovid Goyal
f64b4e0e56 ... 2021-05-12 20:26:38 +05:30
Kovid Goyal
a1356d3bcf ... 2021-05-12 12:29:53 +05:30
Kovid Goyal
4c5a1ceefa Add a FAQ entry for why one should never output binary data into terminals 2021-05-12 12:24:29 +05:30
Kovid Goyal
e4b4a35375 macOS: Fix rendering getting stuck on some machines after sleep/screensaver
This is caused, as far as I can tell, by CVDisplayLink getting stuck.
Apple apparently are incapable of writing a simple timer robustly.
So if it remains stuck after a second delete and recreate it to force it
to restart.

Fixes #2016
2021-05-12 07:30:17 +05:30
Kovid Goyal
cc2afef390 Make the max number of unscrolled lines implementation defined 2021-05-11 14:55:14 +05:30
Kovid Goyal
7c5706ead9 Add the ability to unscroll the screen to the `kitty @ scroll-window` remote control command
Fixes #3604
2021-05-11 14:36:52 +05:30
Kovid Goyal
bcb739fcd2 Allow clicking URLs to open them without needing to also hold ctrl+shift 2021-05-11 14:20:12 +05:30
Kovid Goyal
85ef3724f1 Proper prefix when reporting Move events 2021-05-11 14:02:17 +05:30
Kovid Goyal
cb21422836 Add click and doubleclick events as well 2021-05-11 13:59:52 +05:30
Kovid Goyal
1c9674cec9 SPlit up add_click into two functions 2021-05-11 13:19:34 +05:30
Kovid Goyal
6dcc09a96f Port mouse selection tests to new framework 2021-05-11 11:49:44 +05:30
Kovid Goyal
0260c9d3fb Add a note about selection drag being auto-released 2021-05-11 11:18:10 +05:30
Kovid Goyal
80c03f28f8 Add a note about backward incompatibility 2021-05-11 10:36:48 +05:30
Kovid Goyal
eeaf67079a DRYer 2021-05-11 10:33:01 +05:30
Kovid Goyal
c50863c0d5 Add a note about --debug-input 2021-05-11 10:28:27 +05:30
Kovid Goyal
f4ab6542fa ... 2021-05-11 10:24:48 +05:30
Kovid Goyal
dfbe1bd234 Add debug prints for mouse events 2021-05-11 10:22:30 +05:30
Kovid Goyal
1e89cdc055 Get middle click paste working and dont trigger when mouse is grabbed 2021-05-11 09:20:27 +05:30
Kovid Goyal
7a40959f13 Add a configurable mouse action to select from the clicked point to the end of the line.
Fixes #3585
2021-05-11 09:01:52 +05:30
Kovid Goyal
2b4d55804c Document the mouse action mapping infrastructure 2021-05-11 08:39:13 +05:30
Kovid Goyal
858dac5601 Port mouse selection handling to the new generic mouse actions framework 2021-05-10 21:33:13 +05:30
Kovid Goyal
e944945b7a Implement URL clicking handler 2021-05-10 15:35:50 +05:30
Kovid Goyal
920151a460 Fix mouse event dispatch 2021-05-10 14:48:29 +05:30
Kovid Goyal
ac2a01fb09 Implement documentation generation and conf file generation for mouse actions 2021-05-10 14:27:45 +05:30
Kovid Goyal
a7933018cb Start work on intercepting mouse events 2021-05-10 07:16:43 +05:30
Kovid Goyal
5ee889eadd Dont carry around a bunch of definitions that were only needed during parsing on the opts object 2021-05-10 07:16:43 +05:30
Kovid Goyal
e811f03011 Match key names 2021-05-10 07:16:43 +05:30
Kovid Goyal
417c81de60 Implement parsing for mouse_map config 2021-05-10 07:16:43 +05:30
Kovid Goyal
212c653165 Maintain separate click queues for every button 2021-05-10 07:16:43 +05:30
Kovid Goyal
e36f11385f Convert mouse buttons to an enum 2021-05-10 07:16:43 +05:30
Kovid Goyal
abb05f4883 ... 2021-05-10 07:16:43 +05:30
Kovid Goyal
2973f33959 Start work on parsing mouse mappings 2021-05-10 07:16:43 +05:30
Kovid Goyal
053c2ed2b9 Make pow10_array const 2021-05-10 07:16:43 +05:30
Kovid Goyal
1865570390 Dont force dragging to be with left button 2021-05-10 07:16:43 +05:30
Kovid Goyal
ba1ee7e6cc Code to dispatch mouse events to python 2021-05-10 07:16:43 +05:30
Kovid Goyal
f6b0fcbc0f Add a link to patat 2021-05-10 07:12:31 +05:30
Kovid Goyal
a802058886 Add a link to hologram.nvim 2021-05-10 07:08:27 +05:30
Kovid Goyal
bbc1f68966 Add a link to euporie 2021-05-10 07:04:45 +05:30
Kovid Goyal
ca0b42c3bd oops 2021-05-10 06:28:03 +05:30
Kovid Goyal
9536a475ff Add changelog entry for last PR 2021-05-10 06:12:41 +05:30
Kovid Goyal
cfd731c376 Merge branch 'background-process-always-inherit-env' of https://github.com/trygveaa/kitty 2021-05-10 06:11:31 +05:30
Trygve Aaberge
de1015f6ac When running a background process, always inherit env
subprocess.Popen inherits the current environment if you pass env=None,
but only sets the environment you pass when you pass something else.
This causes an issue with using launch with --stdin-source and
--type=background, e.g. that DISPLAY is not set so you can't launch
graphical processes. Therefore, we have to include os.environ when we
pass an env to Popen.

Fixes #3602
2021-05-09 20:52:25 +02:00
Kovid Goyal
6c0730fef4 ... 2021-05-09 15:27:36 +05:30
Kovid Goyal
c73132610e Merge branch 'master' of https://github.com/jean/kitty 2021-05-09 15:26:56 +05:30
Jean Jordaan
77abaaf8b8 Oh yes, gather stow'd directories in one place for tidiness 2021-05-09 16:43:22 +07:00
Jean Jordaan
2787e86fd7 Shout-out to stow, it deserves to be used :-) 2021-05-09 16:38:49 +07:00
Kovid Goyal
355808b0f6 Fix dynamically changing the background color in a window causing rendering artifacts in the tab bar
Fixes #3595
2021-05-09 11:54:51 +05:30
Kovid Goyal
80c13fa75b Use same co-ord system for cursor as in KITTY_PIPE_DATA 2021-05-09 08:11:05 +05:30
Kovid Goyal
9a6c2aa1ea Add a few more special command line arguments for launch
Now all ``KITTY_PIPE_DATA`` is also available via command line argument substitution
Fixes #3593
2021-05-09 07:46:37 +05:30
Kovid Goyal
63d76ee837 macOS: When the Apple Color Emoji font lacks an emoji glyph search for it in other installed fonts
Fixes #3591
2021-05-09 07:17:32 +05:30
Kovid Goyal
7c48db7da8 Merge pull request #3592 from aaronjanse/allocation_typo
fix allocation typo
2021-05-08 15:10:10 +05:30
Aaron Janse
bd8d5f6288 fix allocation typo 2021-05-08 01:51:29 -07:00
Kovid Goyal
7413b7c4f6 Merge pull request #3590 from dankamongmen/master
graphics-protocol.rst: s/and/an/
2021-05-07 16:37:17 +05:30
nick black
80e3c871ce graphics-protocol.rst: s/and/an/ 2021-05-07 06:15:12 -04:00
Kovid Goyal
74c1e02274 Remove redundant F1-F4 defs in cursor key more 2021-05-07 15:20:26 +05:30
Kovid Goyal
efb0f6f24a Fix a regression in 0.20.0 that sent incorrect bytes for the F1-F4 keys in rmkx mode
Fixes #3586
2021-05-07 15:09:42 +05:30
Kovid Goyal
dbf8580dc3 Add issue reference for infinite length ligatures
Fixes #3504
2021-05-07 11:55:38 +05:30
Kovid Goyal
f110a01ffe Only use the last line of ssh hostname -f output incase the user has configured ssh to print random junk on login 2021-05-07 11:42:52 +05:30
Kovid Goyal
eced40a761 ... 2021-05-07 09:31:31 +05:30
Kovid Goyal
5ac315bc3a DRYer 2021-05-07 09:30:44 +05:30
Kovid Goyal
32df4daa63 Fix warning from CodeQL 2021-05-07 09:27:52 +05:30
Kovid Goyal
5836e456e5 Cleanup mouse features documentation 2021-05-07 09:19:17 +05:30
Kovid Goyal
dc6ab69387 Workaround spurious error reported by ASAN 2021-05-07 08:34:18 +05:30
Kovid Goyal
7301c56753 ... 2021-05-07 07:42:39 +05:30
Kovid Goyal
3b76d657bd Fix colored indication not being sent to GPU 2021-05-07 07:41:19 +05:30
Kovid Goyal
2adb6240e4 Reduce GPU memory for infinite length ligatures
An infinite length ligature (longer than 9 glyphs) that has long
sequences of a repeated glyph now does not store a separate sprite
for every repeat.

For example in the ligature ---------- even though there are 10 hyphen
glyphs only four will be stored on the GPU.
2021-05-07 06:59:30 +05:30
Kovid Goyal
e11af496da Remove incorrect cast 2021-05-07 06:59:30 +05:30
Kovid Goyal
f6e33406d7 Dont assume all sprites are rendered if the first one is 2021-05-07 06:59:30 +05:30
Kovid Goyal
6eab138d68 ... 2021-05-07 06:59:29 +05:30
Kovid Goyal
33287115de Support infinite length ligatures 2021-05-07 06:59:24 +05:30
Kovid Goyal
8e36056dd8 oops 2021-05-07 06:58:55 +05:30
Kovid Goyal
4a34f596a8 Remove MAX_EXTRA_GLYPHS_IN_GROUP 2021-05-07 06:58:55 +05:30
Kovid Goyal
7616a3e743 ... 2021-05-07 06:58:55 +05:30
Kovid Goyal
c64353c324 Dont make canvas dependent on max num of glyphs 2021-05-07 06:58:55 +05:30
Kovid Goyal
8eac22d37a typo 2021-05-07 06:58:55 +05:30
Kovid Goyal
35fab12330 Dont rely on max glyphs limit for scratch space 2021-05-07 06:58:55 +05:30
Kovid Goyal
a46988bc50 Simplify code by getting rid of ExtraGlyphs 2021-05-07 06:58:54 +05:30
Kovid Goyal
26e1d6fe5c Use uthash for glyph properties as well 2021-05-07 06:58:54 +05:30
Kovid Goyal
ec68739585 Make it harder to forget to redefine uthash_fatal 2021-05-07 06:58:54 +05:30
Kovid Goyal
33de0f821f Use uthash for the sprite position cache 2021-05-07 06:58:54 +05:30
Kovid Goyal
86ce11134a Unicode input kitten: Fix a regression in 0.20.0 that broke keyboard handling when the num lock or caps lock modifiers were engaged.
Fixes #3587
2021-05-07 06:55:25 +05:30
Kovid Goyal
bef4905416 Also remove -pedantic-errors when using --ignore-compiler-warnings
Fixes #3584
2021-05-07 06:26:00 +05:30
Kovid Goyal
baa8152248 Add link to changelog in github release notes
Fixes #3588
2021-05-07 06:18:42 +05:30
Kovid Goyal
34fe103c2b Prefix by GPG signature instead 2021-05-07 06:14:40 +05:30
Kovid Goyal
0d08014bd5 Dont append GPG signature twice to release file descs 2021-05-07 06:13:21 +05:30
Kovid Goyal
dd0130180b Use the kitty fatal function 2021-05-06 11:19:06 +05:30
Kovid Goyal
accdf9a6a8 DRYer 2021-05-06 08:57:38 +05:30
Kovid Goyal
c891432c9d version 0.20.3 2021-05-06 08:11:41 +05:30
Kovid Goyal
1a4efd9d81 Remove unused code 2021-05-06 07:46:31 +05:30
Kovid Goyal
bf462e535a Fix focus changes not being sent to windows when focused window changes because of the previously focused window being closed
Fixes #3571
2021-05-05 14:45:57 +05:30
Kovid Goyal
5cf228e362 Fix tab activity tracking not working unless there is some other activity in tab bar as well
Fixes #3571
2021-05-05 14:30:16 +05:30
Kovid Goyal
4dcccc553c ... 2021-05-05 14:02:58 +05:30
Kovid Goyal
7e53db8aac DRYer 2021-05-05 13:58:10 +05:30
Kovid Goyal
4a83584934 Fix #3576 2021-05-05 13:55:46 +05:30
Kovid Goyal
c735d1f6ac Merge branch 'master' of https://github.com/alexDarcy/kitty 2021-05-05 08:39:44 +05:30
Alexis Praga
7bd0fdf3da Freebsd: use gmake to build docs 2021-05-04 22:48:23 +02:00
Kovid Goyal
b570dfcd09 Move the inline ToC above quickstart
local doesnt work below quickstart and it also serves as a good overview
2021-05-04 11:31:34 +05:30
Kovid Goyal
2bc35539f0 Exclude document titles from local ToCs 2021-05-04 11:19:49 +05:30
Kovid Goyal
80e05319c6 ... 2021-05-04 11:08:04 +05:30
Kovid Goyal
49459b3774 Merge branch 'fix-help-menu-spotlight-search' of https://github.com/Luflosi/kitty 2021-05-04 08:20:58 +05:30
Luflosi
0788032003 macOS: fix spotlight search in help menu not working on some machines
The spotlight search in the "Help" menu of the menu bar did not appear when the system language is set to a language other than English. macOS magically adds the search box when the text in that menu matches the translation of "Help" in the system language. On my German system for example replacing "Help" with "Hilfe" will make the search box appear again. This is however not a good solution for kitty as it would require implementing localization support for all languages. Removing `CFBundleAllowMixedLocalizations=True` from `setup.py` also brings back the search box but that may break the locale again. The line was added in  8818b5d8df to fix an issue related to https://github.com/kovidgoyal/kitty/issues/1233.
Luckily I found a seemingly undocumented function that helps us out here, which does not rely the text comparison magic.
2021-05-02 22:21:09 +02:00
Kovid Goyal
d4c7c205cb Add a changelog entry for universal binaries 2021-05-02 07:35:59 +05:30
Kovid Goyal
96ce33792d Build kitty as a universal binary 2021-05-01 14:58:06 +05:30
Kovid Goyal
13bf8a20b0 Build universal binaries of all deps on macOS 2021-05-01 14:50:22 +05:30
Kovid Goyal
6b9b478492 Linux: Fix keyboard layout change keys defined via compose rules not being ignored 2021-05-01 08:09:26 +05:30
Kovid Goyal
c4e8bcb876 Merge branch 'add_attribution_logo' of https://github.com/MindTooth/kitty 2021-04-29 13:11:23 +05:30
Kovid Goyal
28b4fe5cb6 A new show_key kitten
Fixes #3556
2021-04-29 13:10:20 +05:30
Birger J. Nordølum
58b5e645c6 chore(logo): add missing attribution
The Big Sur template includes a CC BY 4.0 license, hence the attribution
with the details of the change.
2021-04-29 09:11:20 +02:00
Kovid Goyal
3e00ee4155 When releasing also upload GPG signatures
Fixes #3555
2021-04-29 08:08:35 +05:30
Kovid Goyal
d1169a0f37 Fix #3549 2021-04-28 19:46:56 +05:30
Kovid Goyal
c8c22d3dd2 Merge branch 'update_macos_icon' of https://github.com/MindTooth/kitty 2021-04-28 19:22:37 +05:30
Birger J. Nordølum
689fd03250 fix(logo): make the icon more inline with Big Sur
This tries to follow the Human Interface Guidelines
from Apple.
2021-04-28 15:37:13 +02:00
Kovid Goyal
56fe6480ce Merge branch 'patch-1' of https://github.com/kidonng/kitty 2021-04-28 16:00:49 +05:30
Kid
017d5f2991 Fix tasks shortcut on macOS 2021-04-28 16:59:39 +08:00
Kovid Goyal
ae43b1565e DRYer 2021-04-28 13:41:48 +05:30
Kovid Goyal
3206e1b12c ... 2021-04-28 13:11:59 +05:30
Kovid Goyal
93d4eca2d4 Fix kitty.conf man page being installed in incorrect location
Fixes #3543
2021-04-28 13:11:01 +05:30
Kovid Goyal
57b5e493a4 version 0.20.2 2021-04-28 10:50:34 +05:30
Kovid Goyal
fc184984a0 ... 2021-04-27 15:11:34 +05:30
Kovid Goyal
2178ff1c48 DRYer 2021-04-27 15:07:27 +05:30
Kovid Goyal
ae1df38c88 Fallback to mkostemp if O_TMPFILE fails 2021-04-27 12:03:24 +05:30
Kovid Goyal
162e498347 Fix @ set-colors for active_tab_foreground 2021-04-26 20:18:50 +05:30
Kovid Goyal
172023afca Forgot the double backslash in the docs 2021-04-26 17:31:43 +05:30
Kovid Goyal
18c7ea50b4 Cleanup text 2021-04-26 13:46:03 +05:30
Kovid Goyal
bdddb238f8 Also generate a man page for kitty.conf 2021-04-26 13:35:22 +05:30
Kovid Goyal
8d46237935 Add the most common keyboard shortcuts to the kitty man page 2021-04-26 12:39:25 +05:30
Kovid Goyal
3fcf83e685 Use a framed icon on macOS
Fits better with Apple's icon style
2021-04-26 12:07:35 +05:30
Kovid Goyal
d374af4341 Type check supersampled functions 2021-04-26 09:12:38 +05:30
Kovid Goyal
f32ad617a2 Special case rendering of the few remaining Powerline box drawing chars
Fixes #3535
2021-04-26 09:07:55 +05:30
Kovid Goyal
62656b24eb GNOME: Add a new option to control the color of the kitty window titlebar 2021-04-25 11:22:23 +05:30
Kovid Goyal
12763e19d8 Add a build argument to turn off -Werror
Fixes #3530
2021-04-24 18:32:57 +05:30
Kovid Goyal
89fd726e07 A new remote control command @env to change the default environment passed to newly created windows
Fixes #3529
2021-04-24 18:06:57 +05:30
Kovid Goyal
0b428987b1 ... 2021-04-24 18:02:16 +05:30
Kovid Goyal
1e29fad5f0 Typecheck @ls cli opts 2021-04-24 17:51:02 +05:30
Kovid Goyal
19524a4459 Update uthash 2021-04-24 09:47:40 +05:30
Kovid Goyal
7043d565c9 ... 2021-04-24 09:44:40 +05:30
Kovid Goyal
d6f856f2f2 Fix https://trac.macports.org/ticket/62732 2021-04-24 07:43:02 +05:30
Kovid Goyal
24f0451c10 Merge branch 'bug3514-fix' of https://github.com/orki/kitty 2021-04-23 21:27:31 +05:30
Ravi R Kiran
3c4460ca98 Give shift, control and caps lock precedence over other modifiers 2021-04-23 10:47:26 -05:00
Kovid Goyal
cbf33fa14b Fix #3523 2021-04-23 16:23:13 +05:30
Kovid Goyal
d782654819 Forgot to handle case of empty scrollback 2021-04-23 16:07:10 +05:30
Kovid Goyal
3c39cbf333 Add a note about over large scrollback fill 2021-04-23 15:54:21 +05:30
Kovid Goyal
bd746e5151 Add a note about what happens when no scrollback lines are present 2021-04-23 15:48:47 +05:30
Kovid Goyal
b32c346eed A new protocol extension to unscroll the screen
See https://gitlab.freedesktop.org/terminal-wg/specifications/-/issues/30
2021-04-23 15:44:38 +05:30
Kovid Goyal
77b8e204ad Fix graphics being cleared when switching to alt screen if the switch mode is to not clear the alt screen 2021-04-23 14:51:32 +05:30
Kovid Goyal
93dfe19c35 GNOME: Fix maximize state not being remembered when focus changes and window decorations are hidden
Apparently mutter needs window geometry set after the surface commit not
before, otherwise it doesnt "stick". When decorations are not hidden
there were other commits caused by the decorations, masking the issue.

Fixes #3507
2021-04-23 14:04:12 +05:30
Kovid Goyal
6dc8df5178 icat kitten: Respect EXIF orientation when displaying JPEG images
Fixes #3518
2021-04-23 07:31:37 +05:30
Kovid Goyal
237fd73702 Fix removal of inactive tab that is before the currently active tab causing the highlighted tab to be incorrect
Fixes #3516
2021-04-22 22:28:05 +05:30
Kovid Goyal
5f2d0142d1 Re-organize README a bit 2021-04-22 20:32:34 +05:30
Kovid Goyal
572d576d5b Merge branch 'fix-compilation-on-old-macos' of https://github.com/Luflosi/kitty 2021-04-22 14:30:38 +05:30
Luflosi
6606f51636 Fix compilation on macOS 10.12
The constants `NSControlStateValueOn`, `NSControlStateValueOff` and `NSControlStateValueMixed` are only available for macOS 10.13 or above according to https://developer.apple.com/documentation/appkit/nscontrolstatevalueon?language=objc.
Without this commit, compilation fails with this message:
```
glfw/cocoa_window.m:1537:28: error: use of undeclared identifier 'NSControlStateValueOn'
              item.state = NSControlStateValueOn;
                           ^
glfw/cocoa_window.m:1539:28: error: use of undeclared identifier 'NSControlStateValueMixed'
              item.state = NSControlStateValueMixed;
                           ^
glfw/cocoa_window.m:1542:47: error: use of undeclared identifier 'NSControlStateValueOn'
          item.state = controller.isDesired ? NSControlStateValueOn : NSControlStateValueOff;
                                              ^
glfw/cocoa_window.m:1542:71: error: use of undeclared identifier 'NSControlStateValueOff'
          item.state = controller.isDesired ? NSControlStateValueOn : NSControlStateValueOff;
                                                                      ^
```
To fix this, simply redefine the constants to use the old and now deprecated constants on older macOS versions.

The code that causes this was introduced in 98519bf326.
2021-04-22 10:53:34 +02:00
Kovid Goyal
36da65120a It's only alt and alt+shift that dont work in global menubar
alt in combination with ctrl/cmd works fine.
2021-04-22 10:50:43 +05:30
Kovid Goyal
b6c1e1a609 ... 2021-04-22 10:24:57 +05:30
Kovid Goyal
5d003ec772 Fix @close-tab not working with pipe based remote control
Fixes #3510
2021-04-22 10:23:04 +05:30
Kovid Goyal
b9210a2ba4 macOS: Prevent option based shortcuts for being used for global menu actions
Fixes #3515
2021-04-22 10:15:10 +05:30
Kovid Goyal
f3c559ea13 Cleanup secure keyboard entry logging 2021-04-22 09:41:01 +05:30
Kovid Goyal
6cee6b6429 More accurate ignoring message 2021-04-22 09:31:41 +05:30
Kovid Goyal
84f6aabf5b Clean up debug keyboard on macOS 2021-04-22 09:28:11 +05:30
Kovid Goyal
9ce947d6ea Ignore failure to read the readline init file on Linux as well
There are apparently people that like to break things randomly on their
systems by removing needed files. Fixes #3513
2021-04-22 08:13:57 +05:30
Kovid Goyal
0f23ad0d7e Merge branch 'u_int8_t' of https://github.com/sgn/kitty 2021-04-21 18:45:18 +05:30
Đoàn Trần Công Danh
1b760b6c53 freetype_render_ui_text: use uint8_t instead of u_int8_t
uint8_t is a standard type, while u_int8_t isn't. And we're assigning to
an uint8_t anyway.
2021-04-21 19:23:43 +07:00
Kovid Goyal
cdf64bf016 Linux: Fix binary kitty builds not able to load fonts in WOFF2 format
Fixes #3506
2021-04-20 17:07:47 +05:30
Kovid Goyal
f3726023c2 version 0.20.1 2021-04-19 21:45:08 +05:30
Kovid Goyal
cb41683f47 ... 2021-04-19 20:12:20 +05:30
Kovid Goyal
629a8ad055 Fix #3501 2021-04-19 19:58:02 +05:30
Kovid Goyal
4ba0fa00b4 Update changelog 2021-04-19 18:07:03 +05:30
Kovid Goyal
f1e73c015a Merge branch 'hyperlink_unbound_variable' of https://github.com/miseran/kitty 2021-04-19 18:03:18 +05:30
Reto Schnyder
926c3540ff Fix unbound variable in hyperlink handling 2021-04-19 14:19:13 +02:00
Kovid Goyal
1aebd83e45 A little clearer code 2021-04-19 17:42:15 +05:30
Kovid Goyal
8225351145 icat: When displaying an animated GIF image with no delays between frames, add a 100ms delay between every frame.
This allows some broken images tested with broken software *cough* browsers to work.
See #3498
2021-04-19 17:17:45 +05:30
Kovid Goyal
379add8d6f IntEnum was needed 2021-04-19 17:09:23 +05:30
Kovid Goyal
ea11ce8664 Use a normal enum for Dispose rather than an IntEnum 2021-04-19 16:57:43 +05:30
Kovid Goyal
82e9e96f0c Fix CodeQL warnings 2021-04-19 14:00:53 +05:30
Kovid Goyal
8c4e426534 Silence some unused parameter warnings 2021-04-19 13:53:27 +05:30
Kovid Goyal
636771e566 Fix test crashing on 32bit machines 2021-04-19 13:48:39 +05:30
Kovid Goyal
363b20bdd2 Add debug symbols when not stripping 2021-04-19 13:29:50 +05:30
Kovid Goyal
b16317e2ca Silence spurious compiler warning 2021-04-19 13:27:17 +05:30
Kovid Goyal
2c5c869228 Print command used to run tests 2021-04-19 13:14:25 +05:30
Kovid Goyal
3f5f218e0b Use correct printf codes 2021-04-19 13:00:48 +05:30
Kovid Goyal
c9cc425aad version 0.20.0
Fixes #3248
Fixes #3287
2021-04-19 10:14:00 +05:30
Kovid Goyal
9a2b0b6995 Wayland CSD: Double clicking on titlebar should toggle window maximize 2021-04-19 08:58:29 +05:30
Kovid Goyal
50f8aeeaf6 Dont output an error when none is used as a modifier 2021-04-18 18:11:56 +05:30
Kovid Goyal
fe291dd769 ... 2021-04-18 10:46:06 +05:30
Kovid Goyal
58850a0e14 Switch to ALE instead of syntastic 2021-04-17 16:53:48 +05:30
Kovid Goyal
518057489c Also output layout state in kitty @ ls 2021-04-17 12:11:56 +05:30
Kovid Goyal
cf0b2389a3 Also report window sizes in kitty @ ls 2021-04-17 11:49:57 +05:30
Kovid Goyal
6179cfc670 Abort parsing of APC and PM escape codes on 0x00 and 0x7f
Correct as per ECMA-48 section 8.3 and matches parsing of other escape
codes
2021-04-15 12:57:58 +05:30
Kovid Goyal
e6ccc2d178 Fix #3485 2021-04-15 08:57:47 +05:30
Kovid Goyal
db719eafac Remove num/caps locks from modifier processing in mouse events 2021-04-14 10:08:33 +05:30
Kovid Goyal
a4db27a807 Ignore the lock modifiers in legacy mode 2021-04-13 21:35:18 +05:30
Kovid Goyal
111c123435 X11: Fix resize_in_steps being applied even when window is maximized
Fixes #3473
2021-04-13 12:48:23 +05:30
Kovid Goyal
75d067e411 Merge branch 'fix-timg-link' of https://github.com/hzeller/kitty 2021-04-13 11:09:31 +05:30
Henner Zeller
fbeb991f7d Fix timg link (underscore was missing).
Signed-off-by: Henner Zeller <h.zeller@acm.org>
2021-04-12 22:27:32 -07:00
Kovid Goyal
ea2db51bbb Output all modifier indices in debug 2021-04-13 10:21:26 +05:30
Kovid Goyal
15f4c476c3 Ignore locked mods for legacy encoding in a few more places 2021-04-13 10:01:16 +05:30
Kovid Goyal
a7c5b8c634 Fix #3471 2021-04-13 09:53:57 +05:30
Kovid Goyal
1aeafcaebf Remove unused code 2021-04-13 09:02:30 +05:30
Kovid Goyal
8d743e9511 Fix is_self 2021-04-13 08:54:45 +05:30
Kovid Goyal
958d4d8a6a kitty @ ls: Show only environment variables that are different for each window, by default.
Makes the output much less noisy, and env vars that are common across
all windows are useless for selection/identification purposes.
2021-04-13 08:44:11 +05:30
Kovid Goyal
05fb09f56c Fix #3470 2021-04-13 08:23:15 +05:30
Kovid Goyal
cdcf8ed3bd Add some colors to keyboad debug output 2021-04-13 07:41:47 +05:30
Kovid Goyal
572466eed1 XKB: Honor numlock state when reporting keypad keys 2021-04-13 07:35:13 +05:30
Kovid Goyal
4c644b8556 Add NumLock and CapsLock reporting to the keyboard protocol 2021-04-13 07:10:00 +05:30
Kovid Goyal
c989a7198b Add support for the keypad Begin key
Fixes #3468
2021-04-11 07:58:27 +05:30
Kovid Goyal
084b028eac Merge branch 'macos-secure-keyboard-entry' of https://github.com/multi/kitty
This is the usual Apple security theatre. Prevent key loggers from
reading key events from the OS, but those same key events are written to
the unsecured tty device from where the keylogger could read them
anyway.

But, since I dont want to have to explain why this is simply security
theatre to every rando on the internet, merging anyway. It only costs
one line in the application menu and maybe it will make some people that
click on it *feel* more secure.
2021-04-10 14:41:54 +05:30
Kovid Goyal
699d88e393 ... 2021-04-10 14:36:31 +05:30
Kovid Goyal
8c6566580a ... 2021-04-10 14:32:13 +05:30
Kovid Goyal
effe30ad3f Add a FAQ entry about memory leaks 2021-04-10 14:23:28 +05:30
Kovid Goyal
e91b8d4556 ... 2021-04-10 14:08:03 +05:30
Kovid Goyal
76fca0641e Fix memory leak in utf_8_strndup test 2021-04-10 13:39:04 +05:30
Kovid Goyal
7ec803222f Fix a mem leak of the disk cache directory path 2021-04-10 13:21:58 +05:30
Kovid Goyal
03f0f065ee Use a single alloc per history buf segment 2021-04-10 13:18:27 +05:30
Kovid Goyal
63e5be6ff0 Dont use the python memory pool for the history buffer
It's not optimized for this use case
2021-04-10 12:11:05 +05:30
Kovid Goyal
4ccd2afd78 Free ChildMonitor at end of dealloc 2021-04-10 11:49:39 +05:30
Georgi Yonchev
98519bf326 [macos] - Add "Secure Keyboard Entry" menu item 2021-04-09 16:39:51 +03:00
Kovid Goyal
82d11b80dd Add a test for filling from scrollback with large continued line 2021-04-09 17:04:55 +05:30
Kovid Goyal
cf3662442f Fix #3460 2021-04-09 16:56:53 +05:30
Kovid Goyal
0be5347e6a Better error message when screen_resize() fails 2021-04-09 10:09:17 +05:30
Kovid Goyal
1b39c42e92 ... 2021-04-08 12:36:44 +05:30
Kovid Goyal
5b4f5a1e2a Add a link to the nb note taking application 2021-04-08 12:06:02 +05:30
Kovid Goyal
4eb8b1db01 Merge branch 'bug3446-fix' of https://github.com/orki/kitty 2021-04-08 08:37:55 +05:30
Ravi R Kiran
b5555b9a8d Handle multiple real modifiers mapping to the same virtual modifier 2021-04-07 21:36:11 -05:00
Kovid Goyal
67bb426eb2 Fix recent Wayland chagelog entries in the incorrect section 2021-04-08 07:59:34 +05:30
Kovid Goyal
cf3a088a53 Allow running under Wayland on GNOME by default 2021-04-08 07:52:28 +05:30
Kovid Goyal
a79d024c09 Accept window_id as an alias for id when matching 2021-04-08 07:19:45 +05:30
Kovid Goyal
253de1eeca Move the CSD metrics initialization into the CSD module 2021-04-07 22:28:04 +05:30
Kovid Goyal
4e6d5d3f1e Fix GNOME breaking when setting window geometry
The current version of GNOME has a regression that causes the compositor
to send incorrect geometry with the next configure event if the CSD
buffers are created after a call to set_window_geometry.

So call set_window_geometry last. And shake head sadly.
2021-04-07 22:14:09 +05:30
Kovid Goyal
82a5733ec5 _glfwPLatformSetWindowSize() should not be called when handling configure events as it does a bunch of work already done before 2021-04-07 19:55:15 +05:30
Kovid Goyal
4822fa989e Wayland: wire up live resize notification 2021-04-07 18:29:28 +05:30
Kovid Goyal
fe0e1adb2a DRYer 2021-04-07 15:26:30 +05:30
Kovid Goyal
850a8218db Allow toggling xdg configure debug output at runtime 2021-04-07 15:24:58 +05:30
Kovid Goyal
bf3fc5fb92 Also implement programmatic window resizing 2021-04-07 15:13:22 +05:30
Kovid Goyal
a19d1fc140 Restore size after all types of docking not just maximize/unmaximize
We make use of the fact that wayland tells us when the window is being
resized to track actual user requested sizes as opposed to compositor
requested ones.
2021-04-07 15:08:44 +05:30
Kovid Goyal
593eb1d952 Focus state needs to be updated always 2021-04-07 14:28:11 +05:30
Kovid Goyal
75ec801941 Get the window geometry with CSD fully correct (I think)
The co-ordinates are in the surface co-ordinate system. When the
compositor specifies sizes it apparently adds one subsurface size
in both x and y directions, not both. Possibly because the origin is
placed after the top and left subsurfaces. So modify it by adding
and extra subsurface size to that.
2021-04-07 14:21:43 +05:30
Kovid Goyal
5a1bd93518 Handle all known xdg top level states 2021-04-07 13:33:06 +05:30
Kovid Goyal
f849f383cb Use the proper number for wayland CSD vertical shadow geometry
Apparently set_wayland_geometry uses buffer co-ordinates not surface
co-ords so the numbers need to be multiplied by the scale
2021-04-06 22:19:17 +05:30
Kovid Goyal
ac3080f0e2 Fix #3446 (I hope) 2021-04-06 21:51:03 +05:30
Kovid Goyal
0935dd053c Modifier indices are unsigned 2021-04-06 21:45:02 +05:30
Kovid Goyal
7e78f30739 Wayland: Fix un-maximizing a window not restoring its size to what it was before being maximized 2021-04-05 13:47:50 +05:30
Kovid Goyal
d0f34e99a6 Fix fringing in shadow due to using integer operations 2021-04-05 11:09:34 +05:30
Kovid Goyal
c781825b00 Make setting sigma independent of kernel size 2021-04-05 10:55:30 +05:30
Kovid Goyal
7199c62b76 ... 2021-04-05 10:13:33 +05:30
Kovid Goyal
2074a0d958 Forgot that the top margin is scaled 2021-04-05 09:57:44 +05:30
Kovid Goyal
3e2b626107 Inform compositor of visible window geometry
The numbers dont make logical sense, but they do what is expected on
GNOME and since only GNOME is stupid enough to insist on CSD, that's
all we care about.
2021-04-05 09:10:47 +05:30
Kovid Goyal
abf515ece9 Mention that w3m now supports the kitty graphics protocol 2021-04-05 08:15:34 +05:30
Kovid Goyal
07de9c021d Decrease shadow intensity when un-focused 2021-04-04 23:04:12 +05:30
Kovid Goyal
ff420b6495 Render top CSD shadow 2021-04-04 22:49:07 +05:30
Kovid Goyal
78908e5b93 Finish rendering of side shadows for CSD 2021-04-04 20:16:13 +05:30
Kovid Goyal
bd6643a523 Use a tile to reduce startup CPU cost of shadows 2021-04-04 18:16:33 +05:30
Kovid Goyal
71fddeb1f5 Start work on shadow based CSD 2021-04-04 17:13:50 +05:30
Kovid Goyal
9f708be8fd Fix name of wttr -> wttr.in 2021-04-04 17:13:17 +05:30
Kovid Goyal
a13f815591 Fix index_selection() not updating empty selections
Newly created selections are empty but must still be indexed.
Fixes #3431
2021-04-03 10:48:43 +05:30
Kovid Goyal
b5ac06e652 Fix #3422 2021-04-03 06:48:10 +05:30
Kovid Goyal
e56d259b8e Also free() when loading fails 2021-04-03 06:41:11 +05:30
Kovid Goyal
11d13c406a Fix a memory leak when setting default window icon or background image 2021-04-03 06:37:57 +05:30
Kovid Goyal
d5448e6902 Add documentation and cleanup previous PR 2021-04-03 06:25:47 +05:30
Kovid Goyal
777b9eb68e Merge branch 'hyper' of https://github.com/orki/kitty 2021-04-03 06:15:55 +05:30
Kovid Goyal
ff1585acfe Unicode input: Make diamond a synonym for gem
Fixes #3437
2021-04-02 12:53:58 +05:30
Kovid Goyal
cb515157b3 Fix the selection getting changed if the screen contents scroll while the selection is in progress
When the selection object was refactored to track the input
co-ordinates, index_selection() was not updated accordingly.
Fixes #3431
2021-04-01 23:17:13 +05:30
Kovid Goyal
da39fb2880 Add a note about when the splits layout was added to kitty
Bloody Ubuntu/Debian and their absurd release policies.
2021-04-01 23:04:13 +05:30
Kovid Goyal
eb3a2126ee Changelog entry for CSD work
Bloody two days of my life I will never get back thanks to those
*&^(*&%*%*& at GNOME.
2021-04-01 22:57:19 +05:30
Kovid Goyal
9c1c399716 ... 2021-04-01 22:52:13 +05:30
Kovid Goyal
e209c3329b Allow specifying a right_margin that is not rendered for the CSD title
Can void double rendering if I ever decide to add button to the titlebar
2021-04-01 22:50:54 +05:30
Kovid Goyal
802147e255 More robust ellipsis width calculation 2021-04-01 22:18:13 +05:30
Kovid Goyal
1a7291276c Add a cat face emoji at the start of the CSD title 2021-04-01 22:07:37 +05:30
Kovid Goyal
6d6273af48 Properly scale emoji rendered in the CSD 2021-04-01 22:07:00 +05:30
Kovid Goyal
b7d967b6bc Dont offset title from left edge 2021-04-01 18:19:59 +05:30
Kovid Goyal
779a06fa72 DRYer 2021-04-01 13:54:20 +05:30
Kovid Goyal
0656a5079a CSD titles: Render ellipsis when too long 2021-04-01 13:48:58 +05:30
Kovid Goyal
a1669267b3 Fix hiding on window decorations not working with new CSD code 2021-04-01 12:32:48 +05:30
Kovid Goyal
bbb40f2a21 Use a little less contrast for CSD title 2021-04-01 12:20:53 +05:30
Kovid Goyal
c5b3e43b6c Use bold for CSD titles 2021-04-01 12:18:48 +05:30
Kovid Goyal
55dc354e68 Improve at exit cleanup functions
Now they are run in a defined order not based on
the order of initialization
2021-04-01 11:48:36 +05:30
Kovid Goyal
0ec7e6c36f Make the freetype text rendering code re-useable in multiple contexts 2021-04-01 11:28:23 +05:30
Kovid Goyal
b1da76eefa Set CSD color based on focus state 2021-04-01 10:54:22 +05:30
Kovid Goyal
5c6e55d37f Vertically center CSD title 2021-04-01 10:34:22 +05:30
Kovid Goyal
5d496216e0 Implement rendering of titles in CSD 2021-04-01 10:23:04 +05:30
Kovid Goyal
e92ed67021 Add a callback glfw can use to request text rendering 2021-04-01 08:22:06 +05:30
Ravi R Kiran
b074533b29 Fix regression 2021-03-31 08:54:10 -05:00
Kovid Goyal
f3665ddfab Cleanup some used memory 2021-03-31 15:29:28 +05:30
Kovid Goyal
dd2b6119b3 Implement rendering of emoji for CSD 2021-03-31 15:23:05 +05:30
Kovid Goyal
ada3f9e547 Add a wcswidth() implementation useable from C code 2021-03-31 15:19:39 +05:30
Kovid Goyal
0372242d12 Use an enum for UTF8 decoder state 2021-03-31 15:19:27 +05:30
Kovid Goyal
9838a336d5 Make wcwidth-std.h more generally includeable 2021-03-31 15:18:19 +05:30
Kovid Goyal
debd9fe419 Dont render glyphs that would overflow the canvas 2021-03-31 11:06:37 +05:30
Kovid Goyal
73a06b0e9e Text rendering for CSD now works 2021-03-31 11:02:35 +05:30
Ravi R Kiran
fdfba4ea04 Fix pyflakes failures 2021-03-30 14:57:41 -05:00
Ravi R Kiran
953253de99 Implementation of hyper and meta 2021-03-30 14:23:17 -05:00
Kovid Goyal
da0009a46b More work on CSD title rendering 2021-03-30 22:12:54 +05:30
Kovid Goyal
d7e1e53450 More work on text rendering for CSD 2021-03-30 08:25:01 +05:30
Kovid Goyal
4a3c57054f Function to get fallback font for a char 2021-03-29 15:35:38 +05:30
Kovid Goyal
41b9495588 More work on text rendering 2021-03-29 14:56:49 +05:30
Kovid Goyal
cdbc096990 Start work on rendering text for CSDs 2021-03-29 12:15:47 +05:30
Kovid Goyal
53f2df115e Hook up re-render of title bar when title changes 2021-03-29 12:15:47 +05:30
Kovid Goyal
0593158a86 Refactor CSD code to avoid un-needed rerenders and use a single shm pool for all CSD buffers 2021-03-29 12:15:47 +05:30
Kovid Goyal
c1f8372efc Hide edges when not focused 2021-03-29 12:15:47 +05:30
Kovid Goyal
6e3db0be3d Rename variable 2021-03-29 12:15:47 +05:30
Kovid Goyal
0f084faca5 Forgot to scale the title buffer 2021-03-29 12:15:47 +05:30
Kovid Goyal
c6829766bb Properly scale the decorations buffers 2021-03-29 12:15:47 +05:30
Kovid Goyal
e7931b0121 Get rid of the no longer needed viewporter protocol 2021-03-29 12:15:47 +05:30
Kovid Goyal
aeb82e7fb0 Refactor the rendering of CSD on Wayland 2021-03-29 12:15:47 +05:30
Kovid Goyal
1e6fe7785a Dont set the EDITOR env var in child processes
It isnt really needed, since the various kittens dont rely on it
anymore, instead calling get_editor() to get the path to the editor.
Has the nice side-effect of not needing to run the shell at startup
to read its environment. Now the shell is only run if the user calls
the edit config file kitten. Fixes #3426
2021-03-29 11:56:48 +05:30
Kovid Goyal
4edbe0ea4f Remove unnecessary opacity marking for decoration buffers 2021-03-25 16:28:49 +05:30
Kovid Goyal
0788b98ae4 Fix header comment 2021-03-25 16:05:14 +05:30
Kovid Goyal
8a267894f3 Make createShmBuffer re-useable 2021-03-25 16:04:12 +05:30
Kovid Goyal
0510cd47f4 Rename buffer -> edge_buffer 2021-03-25 15:19:11 +05:30
Kovid Goyal
5dbbed3dcc Ignore text input done if serial is incorrect 2021-03-25 15:05:48 +05:30
Kovid Goyal
7b130dc220 Double buffer pre-edit and commit events 2021-03-25 14:59:58 +05:30
Kovid Goyal
d28caf15b2 More glyph grouping fixes 2021-03-25 14:06:16 +05:30
Kovid Goyal
44df11c443 Move CSD metrics into the window object
Makes them potentially configurable
2021-03-25 12:52:09 +05:30
Kovid Goyal
63a50ec066 Use the correct mouse cursor theme on GNOME
Relies on a working desktop settings portal (xdg-desktop-portal-gtk)
2021-03-25 12:20:13 +05:30
Kovid Goyal
3d0cff1f47 Merge branch 'fix-rectircle-subpixel-rendering' of https://github.com/jesseleite/kitty 2021-03-25 09:55:05 +05:30
Jesse Leite
97a8b718dd Merge branch 'master' of https://github.com/kovidgoyal/kitty into fix-rectircle-subpixel-rendering 2021-03-25 00:17:47 -04:00
Kovid Goyal
fc8e147e4a Fix mouse handling when using client side decorations
The mouse co-ordinates used by glfw were all wrong.
2021-03-25 09:27:25 +05:30
Jesse Leite
af4083a8b7 Prevent subpixel rendering via floor/ceil on left/right side of box drawn corners. 2021-03-24 23:56:53 -04:00
Kovid Goyal
7c7933efa9 Fix #3416 2021-03-24 13:17:38 +05:30
Kovid Goyal
317ecbc9fa Wayland: Add support for the text input protocol
Fixes #3410
2021-03-24 11:24:37 +05:30
Kovid Goyal
67445a22d3 ... 2021-03-23 16:33:05 +05:30
Kovid Goyal
62997956a0 Start work on Wayland text input protocol support 2021-03-23 16:33:04 +05:30
Kovid Goyal
df7790fdfe ... 2021-03-23 16:31:25 +05:30
Kovid Goyal
34d06fa3e9 Use a struct for IME update events
Allows for easier extension in the future
2021-03-23 16:05:22 +05:30
Kovid Goyal
a981b46ec9 Use an enum for updateimestate as well 2021-03-23 10:52:11 +05:30
Kovid Goyal
84dcf8fd27 Use an enum for ime_state 2021-03-23 10:42:07 +05:30
Kovid Goyal
11268ffa16 Fix marking of text not working on lines that contain zero cells
Zero cells are passed to the regex engine as spaces, so they must
increment the match_pos counter. Fixes #3403
2021-03-23 10:04:58 +05:30
Kovid Goyal
c0ec60c113 Forgot to change a couple of usages of line_as_unicode 2021-03-23 09:56:58 +05:30
Kovid Goyal
ca7587c084 Allow skipping zero cells when converting a line to unicode 2021-03-23 09:53:22 +05:30
Kovid Goyal
33ecfc6f84 ... 2021-03-22 22:33:30 +05:30
Kovid Goyal
83bbcf0aa1 Graphics protocol: Add a control to allow clients to specify that the cursor should not move when displaying an image
Fixes #3411
2021-03-22 22:16:40 +05:30
Kovid Goyal
ba32e481ca ... 2021-03-22 10:46:41 +05:30
Kovid Goyal
af9da2e495 Make pt_to_px useable in state.c 2021-03-21 07:29:48 +05:30
Kovid Goyal
77f7672e98 ... 2021-03-20 13:19:11 +05:30
Kovid Goyal
9dd8185f37 rectciricle -> rectircle 2021-03-20 13:17:17 +05:30
Kovid Goyal
12f61fd24f super sample factor is included in height 2021-03-20 13:11:26 +05:30
Kovid Goyal
c9864c994f Improve rendering of rounded corners by using a rectcircle equation rather than a cubic bezier
Fixes #3409
2021-03-20 12:59:20 +05:30
Kovid Goyal
9e476127d3 macOS: Add native keyboard shortcut for unicode input
Fixes #3407
2021-03-19 14:44:38 +05:30
Kovid Goyal
fae99a24bf Merge branch 'installation-doc-bug' of https://github.com/Dsantra92/kitty 2021-03-18 18:17:14 +05:30
Deeptendu Santra
8d9ab15c40 Fix installation docs
Added `/` at the applications, otherwise applications may be considered a file if the directory is not present. The addition of `/` also ensures user knows that he/she needs to create new directory if it is not present.
2021-03-18 17:55:53 +05:30
Kovid Goyal
ccafdacc6f Ensure cursor position is correct when filling line buffer 2021-03-18 10:39:08 +05:30
Kovid Goyal
4a996c1f76 Use the final cursor position when calculating number of continued lines in resized buffer 2021-03-17 22:29:59 +05:30
Kovid Goyal
d743aff4bc Make the code to copy lines into linebufs general 2021-03-17 22:02:47 +05:30
Kovid Goyal
0f3ff4e2d9 Scrollback filling should happen after cursor position is finalized 2021-03-17 21:59:11 +05:30
Kovid Goyal
a4d9d948ab ... 2021-03-17 14:45:23 +05:30
Kovid Goyal
32e6c0c6a6 Add a security policy 2021-03-17 14:38:57 +05:30
Kovid Goyal
ba2efaacd8 Fix regression in launching executables as command line arguments without full paths 2021-03-17 14:32:43 +05:30
Kovid Goyal
37e3e29c8c Fix a crash on systems using musl as libc
Fixes #3395
2021-03-17 14:13:50 +05:30
Kovid Goyal
90722ecbe7 historybuf should be used only when current screen is the main linebuf 2021-03-17 13:51:30 +05:30
Kovid Goyal
5a2eaa24d0 Add changelog entry for last PR 2021-03-17 13:49:24 +05:30
Kovid Goyal
071986138b Cleanup previous merge 2021-03-17 13:43:26 +05:30
Kovid Goyal
d61c4a9569 Merge branch 'scrollback-fill-enlarged-window' of https://github.com/elebow/kitty 2021-03-17 12:22:12 +05:30
Eddie Lebow
9fff829ab4 Implement scrollback_fill_enlarged_window 2021-03-17 02:27:59 -04:00
Eddie Lebow
4682da83c1 Add linebuf_continued_lines_count() 2021-03-17 02:27:58 -04:00
Eddie Lebow
c93c87e8fe Add linebuf_add_line_to_top() 2021-03-17 00:09:03 -04:00
Kovid Goyal
f3e2a42c29 Fix #3400 2021-03-16 20:59:54 +05:30
Kovid Goyal
b063c8cda1 Fix inactive tab closing causing active tab to change
Fixes #3398
2021-03-16 18:06:01 +05:30
Kovid Goyal
d360d077d1 Handle the XTMODKEYS escape code
Treat the XTerm specific modifyOtherKeys escape codes as putting the
disambiguate mode on/off the stack. The escape code causes XTerm to use
a (broken, naturally) variant of CSI u encoding for many keys, so we
treat it as going into the disambiguate mode.
2021-03-16 17:46:11 +05:30
Kovid Goyal
a548c31d50 Add links to rasterm and notcurses in the graphics protocol docs 2021-03-16 17:11:01 +05:30
Eddie Lebow
6c44b4f451 Add historybuf_pop_line() 2021-03-15 23:59:26 -04:00
Eddie Lebow
b76491ba82 Add tests for scrollback_fill_enlarged_window 2021-03-15 23:58:11 -04:00
Eddie Lebow
e10919496f Add scrollback_fill_enlarged_window config option 2021-03-15 23:57:43 -04:00
Kovid Goyal
543b7dcf94 Increase the default set of recognized URL prefixes 2021-03-15 12:17:15 +05:30
Kovid Goyal
271c39cc9d Fix reading image index not working on older ImageMagick
Fixes #3384
2021-03-12 12:00:44 +05:30
Kovid Goyal
18186da90e Better error message for people running icat on systems with outdated/broken ImageMagick 2021-03-12 11:28:57 +05:30
Kovid Goyal
02d29d4816 Better error message when ImageMagick does not write correct output filenames 2021-03-12 11:07:42 +05:30
Kovid Goyal
82934b84d6 ... 2021-03-12 08:25:19 +05:30
Kovid Goyal
6177a7d71f Fix duplicated line in graphics protocol delete table
Fixes #3383
2021-03-12 08:06:13 +05:30
Kovid Goyal
1f4fdb174a Fix rendering of the new infinite length ligatures on CoreText
Apparently on CoreText, harfbuzz gives incorrect values for glyph
positions. So we use it only for selection and grouping of glyphs.
Actual positioning is done using CoreText. This means sophisticated
positioning using GPOS tables is probably broken, but that isn't really
useable in a character grid anyway.

Also remove the hack where glyph_centering was done for calt ligatures
as it seems to not be needed with modern FiraCode and CoreText
rendering. Fixes #3372
2021-03-11 20:11:40 +05:30
Kovid Goyal
a94b94cab0 Fix macos-freeze building everything twice 2021-03-11 13:03:45 +05:30
Kovid Goyal
399c700939 Prevent Cocoa from sending us open file events from command line args
We process command line args ourselves, thank you very much.
2021-03-11 10:59:03 +05:30
Kovid Goyal
077097c112 Also implement openFiles 2021-03-10 21:55:00 +05:30
Kovid Goyal
f70c9842f5 macOS: Allow opening script and command
Fixes #3366
2021-03-10 21:33:29 +05:30
Kovid Goyal
0f020d5b37 When passing a directory or a non-executable file as the program to run to kitty open it with the shell, instead of just failing.
Allows using kitty as the program to open directories or shell scripts
from desktop environments.
2021-03-10 14:27:07 +05:30
Kovid Goyal
2eccc81fee Show a message about how to exit --hold 2021-03-10 14:26:11 +05:30
Kovid Goyal
9fdaef1da6 Graphics protocol: Fix suppression of responses not working for chunked transmission
Now the starting escape codes q value is used unless the last escape
code specifies a non-zero q value of its own. Fixes #3375
2021-03-10 09:58:49 +05:30
Kovid Goyal
eb42edff09 Use builtin rfc linking 2021-03-10 08:30:13 +05:30
Kovid Goyal
07f27d0f54 Add a link to RFC 1950 2021-03-10 08:22:59 +05:30
Kovid Goyal
48d2aa14c8 Install libx11-xcb-dev on CI
Looks like it is no longer pre-installed
2021-03-10 08:20:35 +05:30
Kovid Goyal
3c1c8ecd20 Merge branch 'dankamongmen/deflate-docs' of https://github.com/dankamongmen/kitty 2021-03-10 08:07:32 +05:30
nick black
dcb8fcece4 Add some notes to graphics protocol docs
Clarify that RFC1950-style zlib-wrapped deflate (as opposed
to RFC1951-style raw deflate) payloads are sent in the
graphics protocol, and that base64 encoding follows
compression (implied by remarks elsewhere, but go ahead and
make it explicit here).
2021-03-09 18:25:18 -05:00
Kovid Goyal
958ccadc09 Also detect gemini:// URLs when hovering with the mouse
Fixes #3370
2021-03-06 11:12:45 +05:30
Kovid Goyal
c48a42bec5 Merge branch 'add-timg-to-graphics-docs' of https://github.com/hzeller/kitty 2021-03-06 10:48:54 +05:30
Henner Zeller
50858322d6 Add timg (http://timg.sh/) to graphics protocol users program list.
Signed-off-by: Henner Zeller <h.zeller@acm.org>
2021-03-05 20:45:32 -08:00
Kovid Goyal
62912a800a Ban a bunch of unsafe C functions from the codebase
List is taken from the git codebase
2021-03-05 08:26:05 +05:30
Kovid Goyal
1ded78a98c A new command to show the env vars of the kitty process 2021-03-03 16:04:08 +05:30
Kovid Goyal
90c6c2a366 ... 2021-03-03 15:11:05 +05:30
Kovid Goyal
fbe84698c4 Add a FAQ entry about env vars 2021-03-03 15:06:30 +05:30
Kovid Goyal
2c642406d8 Dont exclude glfw.c from LoC as it no longer is largely auto-generated 2021-03-01 10:59:57 +05:30
Kovid Goyal
b811976018 Ensure global shortcuts are never sent to children
This was happening with ctrl+tab and ctrl+shift+tab because cocoa eats
these and so glfw has a workaround to always send them. If they are
added as global shortcuts, for exmaple for next/previous tab they were
then being sent to children
2021-02-28 21:42:57 +05:30
Kovid Goyal
3ee7e5f800 Fix another use after free caused by a re-assigned pointer 2021-02-28 12:30:12 +05:30
Kovid Goyal
945cbca387 hints kitten: When using the linenumber action with a background action, preserve the working directory
Fixes #3352
2021-02-27 09:14:12 +05:30
Kovid Goyal
30c7ff341f DRYer 2021-02-27 09:10:16 +05:30
Kovid Goyal
12d7c7314a Only warn about Wayland's inadequacy once 2021-02-26 19:21:48 +05:30
Kovid Goyal
ce3cd691cc macOS: Add global menu action to detach current tab 2021-02-25 12:27:10 +05:30
Kovid Goyal
81f144df15 macOS: Add entries to global menu bar for creating and changing tabs 2021-02-25 11:54:53 +05:30
Kovid Goyal
78854d4a10 macOS: Disable cocoa tabs
kitty has its own tabs, and macOS inserts confusing menu entries for its
non-functional tabs into the global menu. So disable tabs. Fixes #3325
2021-02-25 11:26:55 +05:30
Kovid Goyal
dc3ad80d24 Window may not be in current os window if triggerred shortcut is detach_window 2021-02-25 07:20:07 +05:30
Kovid Goyal
ed1188dc61 Forgot modifier mask 2021-02-25 07:12:00 +05:30
Kovid Goyal
52347ced85 macOS: Make the global keybinding used for preferences also configurable 2021-02-25 06:58:20 +05:30
Kovid Goyal
5fd6c6b9a1 typos in docs 2021-02-24 14:17:28 +05:30
Kovid Goyal
9e7031f5d8 Dont call window_for_id() unnecessarily 2021-02-24 13:38:38 +05:30
Kovid Goyal
cca590c20a Fix a use-after-free introduced in the recent key handling refactor 2021-02-24 13:32:27 +05:30
Kovid Goyal
863fff8620 Cleanup previous PR 2021-02-24 12:32:26 +05:30
Kovid Goyal
18f42fe4c1 Merge branch 'tab_powerline' of https://github.com/slfotg/kitty 2021-02-24 12:23:11 +05:30
Sam Foster
2a3cc71641 Made powerline tab_bar_style have different display options 2021-02-24 00:14:00 -06:00
Kovid Goyal
bd67814485 Fix building with asan on macOS 2021-02-23 17:06:00 +05:30
Kovid Goyal
40dbf7f1c8 Use log_error instead of print 2021-02-22 08:33:26 +05:30
Kovid Goyal
42a7023203 Fix #3332 2021-02-21 13:18:48 +05:30
Kovid Goyal
14b33a845e Avoid compiler warning about using main as a variable name 2021-02-21 11:20:10 +05:30
Kovid Goyal
56fcbb95ab Key encoding: in legacy mode use legacy encoding for a few more combinations
Some legacy terminal applications get confused seeing CSI u escape
codes. Since it is relatively common to press ctrl or shift and
space/enter/tab/backspace, emit the same bytes as traditional terminals
do for these common keys.
2021-02-21 11:14:25 +05:30
Kovid Goyal
de100ac67c DRYer 2021-02-20 11:39:31 +05:30
Kovid Goyal
2a96d2621c Use cleanup in a few more places to simplify the code 2021-02-19 18:53:30 +05:30
Kovid Goyal
a097f5df23 Use the gcc cleanup attribute in launcher 2021-02-19 18:34:12 +05:30
Kovid Goyal
6a901ea048 Forgot that wayland is not built on CI 2021-02-19 18:09:12 +05:30
Kovid Goyal
dbc1ade5a9 Fallback to importlib_resources on python 3.6 2021-02-19 18:02:15 +05:30
Kovid Goyal
c2a924a5ea Run all tests on the full frozen build using the frozen launcher
Much more comprehensive test coverage at the cost of slightly increasing
the frozen build size.
2021-02-19 17:57:59 +05:30
Kovid Goyal
e06d40cb31 Fix test suite getting type checked accidentally 2021-02-19 15:19:04 +05:30
Kovid Goyal
45d89cfe55 Install importlib.resources on python 3.6 2021-02-19 15:08:47 +05:30
Kovid Goyal
d45a8309cb Dont use VLAs in launcher.c 2021-02-19 15:04:49 +05:30
Kovid Goyal
9cd8637e9c Remove another use of __file__ 2021-02-19 14:49:07 +05:30
Kovid Goyal
38992e25d7 Make the tests into a package
Useful to make the tests runnable in a frozen build.
2021-02-19 14:35:25 +05:30
Kovid Goyal
f25b3c2aee Canonicalize resource pathnames in the frozen build 2021-02-19 13:59:33 +05:30
Kovid Goyal
e3e2261005 Fix resources path in macOS bundle 2021-02-19 13:57:58 +05:30
Kovid Goyal
38a7e77058 Add build test for filesystem locations 2021-02-19 13:42:20 +05:30
Kovid Goyal
a920919b13 Workaround for bug in libxkbcommon/Debian/Ubuntu on en_IN locale
See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=903373
2021-02-19 12:35:59 +05:30
Kovid Goyal
625f0f77bb Ensure disk cache is cleared 2021-02-19 09:43:57 +05:30
Kovid Goyal
12604072fc Allow querying number cached in ram from c code as well 2021-02-19 09:28:56 +05:30
Kovid Goyal
0341b64748 Allow caching of disk cache entries in RAM 2021-02-18 10:22:42 +05:30
Kovid Goyal
e0620fbb1d Also implement the bypy freeze on macOS 2021-02-17 22:01:09 +05:30
Kovid Goyal
9114bda24c Get the new bypy based freezing process working with linux builds 2021-02-17 15:50:53 +05:30
Kovid Goyal
4cf73204a2 Forgot to exclude modules 2021-02-16 13:57:23 +05:30
Kovid Goyal
55e7f69768 Use importlib.resources to enumerate kitten names 2021-02-16 13:48:02 +05:30
Kovid Goyal
d2a16bc8e8 ... 2021-02-16 13:14:36 +05:30
Kovid Goyal
5fdeb3b3b4 Use a temp dir as cache dir when running tests during freezing on linux 2021-02-16 13:07:45 +05:30
Kovid Goyal
9ad5ef8b2d Fix compilation on ancient Linux distros without sys/random.h 2021-02-16 12:39:18 +05:30
Kovid Goyal
c244bcd978 Allow overriding the location of the kitty base directory in frozen builds 2021-02-16 10:29:19 +05:30
Kovid Goyal
7eb8e1df79 Use importlib to load the shaders 2021-02-16 10:23:18 +05:30
Kovid Goyal
74c4e94c3d ... 2021-02-16 10:21:28 +05:30
Kovid Goyal
275b8ce2e7 Fix #3322 2021-02-15 21:27:52 +05:30
Kovid Goyal
ff1b0a7e1b Maybe it's uuid-dev instead 2021-02-15 16:44:59 +05:30
Kovid Goyal
39026bc45c Apparently fontconfig now depends on uuid 2021-02-15 16:39:07 +05:30
Kovid Goyal
3d9a95d0cd ... 2021-02-15 16:24:39 +05:30
Kovid Goyal
085bc09dfb Micro-optimization 2021-02-15 16:24:04 +05:30
Kovid Goyal
886309850f Dont add alpha when rendering alpha mask on canvas
Instead use the larger of the two alphas. This gives better results
for overlapping text, such as the infinite length ligature glyphs used
by FiraCode. I dont think adding ever gave better results anyway.
2021-02-15 16:08:06 +05:30
Kovid Goyal
ba005e991a Improve handling of infinite length ligatures in newer versions of FiraCode and CascadiaCode.
Now such ligatures are detected based on glyph naming convention.
This removes the gap in the ligatures at cell boundaries. However, at
least in Fira Code the infinite length ligature glyphs define a negative
left side bearing. This means they overlap when drawn consecutively,
leading to unsightly bumps at the joins.

Fixes #2695
2021-02-15 15:49:09 +05:30
Kovid Goyal
912c46fc57 Fix rendering of ligatures in the latest release of Cascadia code
For some reason it puts empty glyphs after the ligature glyph rather than before it.
There is a possibility this fix might break something else, we will see.
Fixes #3313
2021-02-15 11:57:57 +05:30
Kovid Goyal
5675944c0c Recognize remaining ASCII keys for legacy mode as well 2021-02-15 05:33:57 +05:30
Kovid Goyal
6b9c280214 Add a test for encoding of : as a legacy ascii key 2021-02-15 05:27:32 +05:30
Kovid Goyal
19b882a0bd Also handle : as a legacy ASCII key
Fixes #3315
2021-02-15 05:24:21 +05:30
Kovid Goyal
323d5dba7e SingleKey parsing requires ASCII lowercase 2021-02-15 04:55:51 +05:30
Kovid Goyal
cd9755ffb3 Sphinx: replace use of deprecated css_files 2021-02-15 04:35:24 +05:30
Kovid Goyal
fbcdf352ac Allow resizing of OS Window framebuffers to a single cell
This is much smaller than before and essentially works around the issue
of the text being scaled when the window is resized to small sizes. Also
has the nice side effect of making the code simpler for the panel
kitten. Fixes #3307
2021-02-14 22:17:41 +05:30
Kovid Goyal
015fe9054e Fix shifted keys not matching shortcuts in kittens
Broke after keyboard refactoring for new keyboard protocol. Now a key
event will match a shortcut specification if either the mods and key
match or mods without shift and shifted key match. Fixes #3314
2021-02-14 07:52:08 +05:30
Kovid Goyal
9a031c5b0c Bump versions for bundled deps 2021-02-12 12:29:38 +05:30
Kovid Goyal
de0f225c45 Fix #3299 2021-02-09 22:10:40 +05:30
Kovid Goyal
41533bffdd Merge branch 'build_doc' of https://github.com/spenczar/kitty 2021-02-09 07:45:25 +05:30
Spencer Nelson
cdf7c4bf97 Add two more build-time dependencies to the docs 2021-02-08 10:40:15 -08:00
Kovid Goyal
57db384953 Add packaging status to README 2021-02-06 12:10:30 +05:30
Kovid Goyal
9f0785a160 Add a link to the RFC 2021-02-05 11:36:03 +05:30
Kovid Goyal
4541cf8807 Another CodeQL warning 2021-02-05 10:41:35 +05:30
Kovid Goyal
fe07306ff1 Use a nicer decorator for functions that only need to be run once 2021-02-05 10:40:52 +05:30
Kovid Goyal
726d736aac Type check return value of cache_dir 2021-02-05 10:34:17 +05:30
Kovid Goyal
db0360dc81 Fix a bunch of CodeQL warnings 2021-02-05 10:05:54 +05:30
Kovid Goyal
4ba35d4a93 Clear cache_dir lru cache when testing 2021-02-05 09:56:17 +05:30
Kovid Goyal
1d51fca879 Python 3.6 compat 2021-02-05 09:49:46 +05:30
Kovid Goyal
67ca1902a0 Use a cache dir in the cwd on CI 2021-02-05 09:42:01 +05:30
Kovid Goyal
1ef326e220 Better error message 2021-02-05 09:29:56 +05:30
Kovid Goyal
0e483f81ac Compat for python < 3.8 2021-02-05 09:23:54 +05:30
Kovid Goyal
e969dea3b7 Remove unused function 2021-02-05 09:20:58 +05:30
Kovid Goyal
89b4f59efa Update changelog to note animation support 2021-02-05 09:20:02 +05:30
Kovid Goyal
95dc87cf04 Prevent stack overflows when recursing to coalesce frames 2021-02-05 09:12:08 +05:30
Kovid Goyal
3fc29e0d11 ... 2021-02-05 09:03:39 +05:30
Kovid Goyal
cc3b71154d Document the animation protocol 2021-02-05 09:00:19 +05:30
Kovid Goyal
e4e9e29949 Add a note about broadcast kitten to index 2021-02-05 06:33:48 +05:30
Kovid Goyal
7a1785e1e8 Get chunked loading working with frames 2021-02-04 21:04:44 +05:30
Kovid Goyal
5d2baaac38 ... 2021-02-04 17:52:18 +05:30
Kovid Goyal
b479510f6c Allow controlling the number of loops in icat 2021-02-04 17:47:53 +05:30
Kovid Goyal
8033e9fef5 Fix error checking when rendering single frame 2021-02-04 17:16:52 +05:30
Kovid Goyal
83b8c8ea12 Reduce frequency of key frames slightly 2021-02-04 17:08:06 +05:30
Kovid Goyal
a447ba7d76 Fix typo in coalesce function causing incorrect coalesce for more than one level of recursion 2021-02-04 16:50:13 +05:30
Kovid Goyal
450e1c2f95 Use key frames for performance 2021-02-04 16:20:30 +05:30
Kovid Goyal
cf3a01f502 Handle images whose first frame is smaller than the canvas 2021-02-04 15:57:49 +05:30
Kovid Goyal
3925e18964 Use rgba data for opaque animations that uses blended frames 2021-02-04 14:39:06 +05:30
Kovid Goyal
2650c7dd9e Avoid calculation when over px is transparent 2021-02-04 14:26:10 +05:30
Kovid Goyal
0f18fedf13 Add support for animations to icat 2021-02-04 14:18:47 +05:30
Kovid Goyal
f18a56682f Fix animations not resuming when OS window is hidden and then shown 2021-02-04 13:34:27 +05:30
Kovid Goyal
af94e07618 Cache exe lookups 2021-02-04 11:36:59 +05:30
Kovid Goyal
7eba3b6cbc Use the magick executable from IMv7 preferentially 2021-02-04 11:34:32 +05:30
Kovid Goyal
e5ef9d9062 Ensure IM outputs multiple images in rgba format 2021-02-04 11:23:54 +05:30
Kovid Goyal
b72dbc973d Allow controlling how many times an animation will loop 2021-02-03 20:54:43 +05:30
Kovid Goyal
55d0e23c38 ... 2021-02-03 19:29:46 +05:30
Kovid Goyal
d3489712a6 Store mode data per frame 2021-02-03 18:00:36 +05:30
Kovid Goyal
56193f6902 Handle resizing of animated images with blended frames correctly 2021-02-03 17:51:38 +05:30
Kovid Goyal
2dad179285 ... 2021-02-03 16:00:31 +05:30
Kovid Goyal
19f0e2303d Refactor to store frame deltas instead of fully coalesced frames
Trades CPU usage for cache/memory space
2021-02-03 15:49:33 +05:30
Kovid Goyal
c152624634 Rename state variable to be closer to its actual purpose 2021-02-02 09:00:28 +05:30
Kovid Goyal
212906cf7d gap should be gap to next frame not gap from previous frame
Matches usage in the GIF format and makes the concept of gapless
clearer.
2021-02-01 17:08:59 +05:30
Kovid Goyal
bb5c5a8e4f Allow gapless frames 2021-02-01 16:22:36 +05:30
Kovid Goyal
9cf5348c36 Modify ImageMagick wrapper to handle animated images 2021-02-01 14:12:26 +05:30
Kovid Goyal
edf4e14e4c Work on animation support for icat 2021-01-31 20:58:43 +05:30
Kovid Goyal
8fa737f01c Rescan for animated images on various events 2021-01-31 20:58:43 +05:30
Kovid Goyal
f16e22fbec Forgot to convert gaps to monotonic_t 2021-01-31 20:58:43 +05:30
Kovid Goyal
19e0406459 Wire up animation state tracking 2021-01-31 20:58:43 +05:30
Kovid Goyal
354d7c2740 ... 2021-01-31 20:58:42 +05:30
Kovid Goyal
00edb6058e Start work on implementing frame transitions
Also ensure that the correct OS Window is current when uploading images
to GPU.
2021-01-31 20:58:42 +05:30
Kovid Goyal
597267d1d0 root frame gap should be set to the gap of the first received frame 2021-01-31 20:58:42 +05:30
Kovid Goyal
ad4665e638 Add support for newer keys to GraphicsCommand serializer 2021-01-31 20:58:42 +05:30
Kovid Goyal
b21850dd15 Implement updating of current frame on GPU 2021-01-31 20:58:42 +05:30
Kovid Goyal
4098f2d383 Add quota enforcement testing 2021-01-31 20:58:42 +05:30
Kovid Goyal
5eba754c60 Implement animation control escape codes 2021-01-31 20:58:42 +05:30
Kovid Goyal
b35084062d Remove old data from cache when re-using image objects 2021-01-31 20:58:42 +05:30
Kovid Goyal
1d20472759 Avoid a cache move when deleting frames 2021-01-31 20:58:42 +05:30
Kovid Goyal
c0e336a971 DRYer 2021-01-31 20:58:42 +05:30
Kovid Goyal
d76e757d53 Implement delete for frames 2021-01-31 20:58:42 +05:30
Kovid Goyal
43ea58ef48 Start work on delete for frames 2021-01-31 20:58:42 +05:30
Kovid Goyal
17f485d614 Basic frame loading works 2021-01-31 20:58:41 +05:30
Kovid Goyal
35f3312a1e Use shorter cache keys 2021-01-31 20:58:41 +05:30
Kovid Goyal
ca3c49099f Start work on tests for frame loading 2021-01-31 20:58:41 +05:30
Kovid Goyal
6631bb0eac Make the image dict more complete 2021-01-31 20:58:41 +05:30
Kovid Goyal
0adbbc6d62 Implement loading of frame animation data 2021-01-31 20:58:41 +05:30
Kovid Goyal
cc4f9ddad8 More work an animation handling 2021-01-31 20:58:41 +05:30
Kovid Goyal
5a182d3d13 Store image data in a disk cache 2021-01-31 20:58:41 +05:30
Kovid Goyal
c60d3af60b Add links to locations for discussion to README
Proof of reddit account:
1e2b9113-2d30-48f0-8f2f-f7a2bcbd4895
2021-01-31 20:54:21 +05:30
Kovid Goyal
4e67a92ec4 DRYer 2021-01-31 12:26:54 +05:30
Kovid Goyal
e43c3118d4 ... 2021-01-31 12:14:36 +05:30
Kovid Goyal
ffc0919790 Allow setting colors when creating windows using the launch command. 2021-01-31 12:13:27 +05:30
Kovid Goyal
2af145879e Make color spec parsing re-useable 2021-01-31 12:10:45 +05:30
Kovid Goyal
35517d3e6f Allow using the full launch command in session files
Note this is slightly backward incompatible.
2021-01-31 11:37:00 +05:30
Kovid Goyal
e9e8ef7210 ssh kitten: Allow using python instead of the shell on the server 2021-01-31 09:04:46 +05:30
Kovid Goyal
ee198ca863 Add versionadded notes 2021-01-31 07:42:01 +05:30
Kovid Goyal
0681e6a9b6 ... 2021-01-31 07:35:58 +05:30
Kovid Goyal
965a6dfd30 Add some more kittens to the list 2021-01-31 07:18:27 +05:30
Kovid Goyal
d55fde9eea Use EINTR safe wrappers for open() and shm_open() 2021-01-31 07:02:11 +05:30
Kovid Goyal
231f054bc3 Merge branch 'master' of https://github.com/dlh/kitty 2021-01-31 06:47:01 +05:30
Daniel Lee Harple
43fafd85f8 Allow cancellation of "detach_window ask" 2021-01-30 19:21:11 -05:00
Kovid Goyal
8a5a7b8807 Merge branch 'master' of https://github.com/dlh/kitty 2021-01-30 10:07:16 +05:30
Daniel Lee Harple
2c24cc1341 Allow quoted args to toggle_marker 2021-01-29 17:52:24 -05:00
Kovid Goyal
0fc93118f2 Make the error message when failing to get monitor display name more informative 2021-01-29 12:45:22 +05:30
Kovid Goyal
ac2a33d09f Silence the errors about OSC 7
Up to now this poorly designed and completely unnecessary escape code
was relegated to only GNOME, however, off late Apple has started using
it as well, so silently ignore it, instead of spamming error messages
for it.
2021-01-29 12:43:41 +05:30
Kovid Goyal
68423b3603 Fix compiler warning on newer Xcode
Fixes #3271
2021-01-29 11:29:29 +05:30
Kovid Goyal
6d18223f17 Use an id for keyboard focus tracking as well 2021-01-29 11:22:39 +05:30
Kovid Goyal
0443e5ad7f Wayland: Use window ids rather than pointers to track windows for key repeat
Might fix #3266
2021-01-29 08:43:00 +05:30
Kovid Goyal
4619921780 Add a link to the thread with discussion on using vim as pager 2021-01-29 08:35:15 +05:30
Kovid Goyal
df89266c03 diff kitten: Implement recursive diff over SSH
Fixes #3268
2021-01-28 14:23:56 +05:30
Kovid Goyal
36ca3838a6 Fix #3265 2021-01-27 17:19:06 +05:30
davidak
60ce88cf25 Update Nix package link 2021-01-27 13:43:21 +05:30
Kovid Goyal
5a2f2767ad Fix window icon not working on X11 with 64bits
Apparently on X11 the maximum icon size is 128x128. 256x256 is too
large for the X11 protocol because the X server unserializes the icons
using "unsigned long" which is 64 bits on Linux. So we have to use
64bits per pixel instead of 32, with 32bits padded to 0.

While there I also got rid of the kitty.rgba file replacing it with a
128x128 PNG file.

Fixes #3260
2021-01-25 20:54:19 +05:30
Kovid Goyal
6e73d3fac8 Fix extra space at bottom of OS window when using the fat layout with the tab bar at the top
Fix #3258
2021-01-25 09:30:14 +05:30
Kovid Goyal
d08ae5466d Dont use a function 2021-01-24 12:57:39 +05:30
Kovid Goyal
fc175732e1 Fix CodeQL warning 2021-01-24 12:48:47 +05:30
Kovid Goyal
dfe41217f8 Start work on allowing images to have multiple frames 2021-01-24 12:37:21 +05:30
Kovid Goyal
4870d07cbb Refactor handle_add_command to make it more readable 2021-01-24 12:00:35 +05:30
Kovid Goyal
2dd9fd83a3 Add some text to the control reference 2021-01-23 13:44:10 +05:30
Kovid Goyal
0b93153656 Add the I key to the control data reference 2021-01-23 13:20:32 +05:30
Kovid Goyal
714d64c417 Get type checking working with mypy 0.80
Add workaround for https://github.com/python/typeshed/issues/4964
2021-01-23 09:25:31 +05:30
Kovid Goyal
b823af00ff Get rid of a bunch of noqas 2021-01-22 22:04:53 +05:30
Kovid Goyal
77f456bd9c Fix #3253 2021-01-22 21:06:58 +05:30
Kovid Goyal
874fe2ed72 ... 2021-01-22 20:36:39 +05:30
Kovid Goyal
786f8c7b1f macOS: Ensure font size is correct if the OS moves the newly created window to a different monitor after it is shown 2021-01-22 20:22:09 +05:30
Kovid Goyal
0c784346cc Update blurb 2021-01-21 12:14:44 +05:30
Kovid Goyal
2ab0ff74c6 ... 2021-01-21 11:34:21 +05:30
Kovid Goyal
22cb9b9798 Add a note about kbs = backspace 2021-01-21 11:29:01 +05:30
Kovid Goyal
2ee1a366fd Also assert non-negative params for SET_MODE 2021-01-21 07:21:23 +05:30
Kovid Goyal
f9844ba3b0 Allow negative numbers in CSI codes 2021-01-21 07:06:43 +05:30
Kovid Goyal
7cea233de3 - is not a CSI start modifier 2021-01-21 06:44:18 +05:30
Kovid Goyal
e4d8aac3d5 Make CSI parsing a bit more spec compliant
Now the full list of secondary characters (intermediate bytes) is used from ECMA 48
Also the codes that accept only one parameter now report errors when
multiple parameters are passed.
2021-01-21 06:41:27 +05:30
Kovid Goyal
354d381372 Oops forgot to regen glfw wrapper 2021-01-21 05:37:13 +05:30
Kovid Goyal
60e589f775 Recognize Hyper key
Also use only one implementation for detecting if a key is a modifier
key
2021-01-21 05:33:14 +05:30
Kovid Goyal
f6d4b8e0b0 typo 2021-01-20 18:30:22 +05:30
Kovid Goyal
5fafd70b0f Fix detection of ASCII control chars in key event text 2021-01-20 17:35:24 +05:30
Kovid Goyal
dcfeab8461 Remove un-needed code
Space is now handled as legacy ascii key
2021-01-20 16:08:15 +05:30
Kovid Goyal
2a8e8d4b38 Fix #3252 2021-01-20 16:02:28 +05:30
Kovid Goyal
e6644aebcb Add a test to ensure caps lock does not produce bytes in legacy mode 2021-01-19 09:19:34 +05:30
Kovid Goyal
654cd54363 Add the ISO level 3 and 5 shift keys to functional keys 2021-01-19 09:11:44 +05:30
Kovid Goyal
16005d43e8 Dont send unknown keys that dont generate text
Fixes #3249
2021-01-19 09:01:52 +05:30
Kovid Goyal
b08c93032b ... 2021-01-19 08:58:06 +05:30
Kovid Goyal
dd08896c70 Lock keys should not be sent to applications in legacy mode 2021-01-19 08:55:01 +05:30
Kovid Goyal
f0ae5dfc73 ... 2021-01-18 16:31:09 +05:30
Kovid Goyal
0adc7e4d4b fix typo 2021-01-18 16:30:02 +05:30
Kovid Goyal
5c2056a7cb Fix parsing of + as a shortcut 2021-01-17 19:56:32 +05:30
Kovid Goyal
f0e7d26409 Fix typo 2021-01-17 19:12:12 +05:30
Kovid Goyal
95ebeebb84 Mention alternate screen mode in the quickstart 2021-01-17 11:41:35 +05:30
Kovid Goyal
a88875f98e ... 2021-01-17 11:17:31 +05:30
Kovid Goyal
39da92d8ab Now that glfw reports shifted keys, use it when encoding key events 2021-01-17 11:14:44 +05:30
Kovid Goyal
089d358031 ... 2021-01-17 09:06:03 +05:30
Kovid Goyal
6a4885df17 Add changelog entries for the new keyboard features 2021-01-17 08:52:10 +05:30
Kovid Goyal
d45d553eaf When using a non-US keyboard layout and pressing ctrl+key when the key matches an English key in the default layout, send that to the program running in the terminal automatically
See #2000
2021-01-17 08:25:19 +05:30
Kovid Goyal
2cbbd84987 Clean up some formatting 2021-01-17 07:34:35 +05:30
Kovid Goyal
1016586611 Fix compiler warning 2021-01-17 07:28:22 +05:30
Kovid Goyal
6bbf014152 ... 2021-01-17 07:24:12 +05:30
Kovid Goyal
4fea7bd8ef Fix building on systems with xkbcommon < 1.0 2021-01-17 07:22:21 +05:30
Kovid Goyal
aa63bf71cf macOS: Add menu items to close the OS window and the current tab
Fixes #3246
2021-01-17 06:49:25 +05:30
Kovid Goyal
4c9bd368c6 Implement alternate keys on macOS 2021-01-16 20:52:16 +05:30
Kovid Goyal
b1c1c497e4 More character key name aliases 2021-01-16 20:52:16 +05:30
Kovid Goyal
86ce72e725 Port the Cocoa backend to use unicode key numbers 2021-01-16 20:52:16 +05:30
Kovid Goyal
ae37b4b09b Add more character key aliases 2021-01-16 20:52:15 +05:30
Kovid Goyal
5ffbee1e8c Use shifted keys to match shortcuts as well 2021-01-16 20:52:15 +05:30
Kovid Goyal
19a3635c64 Dont send release events for kitty shortcuts to children 2021-01-16 20:52:15 +05:30
Kovid Goyal
3c648c05ec Report shifted and alternate keys from the XKB backend 2021-01-16 20:52:15 +05:30
Kovid Goyal
5607a3c2ed ... 2021-01-16 20:52:15 +05:30
Kovid Goyal
cf04a5a036 Add tests for encode/decode roundtripping 2021-01-16 20:52:15 +05:30
Kovid Goyal
c12680895e Fix key state tracking regression 2021-01-16 20:52:15 +05:30
Kovid Goyal
0163bf3edb Fix enter/tab/backspace not being reported in all keys mode 2021-01-16 20:52:15 +05:30
Kovid Goyal
af0a24c702 Make key demo output prettier 2021-01-16 20:52:15 +05:30
Kovid Goyal
7ea1deba8f Clean up code tables 2021-01-16 20:52:15 +05:30
Kovid Goyal
b60c84ecdc Add note on detection of support 2021-01-16 20:52:15 +05:30
Kovid Goyal
e09ed038e2 Port key handling in more kittens
Also fix decoding of enter/f3 key events
2021-01-16 20:52:15 +05:30
Kovid Goyal
9c6ba213f9 Fix key handling in diff kitten 2021-01-16 20:52:14 +05:30
Kovid Goyal
66341111e6 keyboard mode change should happen only in alternate screen 2021-01-16 20:52:14 +05:30
Kovid Goyal
abc1e3f289 Remove the function used to init glfw key events
Instead use C99 struct initializers. Much less error prone.
2021-01-16 20:52:14 +05:30
Kovid Goyal
027c5a57f1 Work on porting kittens to use new key infrastructure
Also move type definitions into their own module
2021-01-16 20:52:14 +05:30
Kovid Goyal
0714fd376b Fix handling of ctrl key in legacy mode
Also change the glfw constants used for the modifiers to match those
used in the terminal encoding. Less likely to make mistakes translating
that way.
2021-01-16 20:52:14 +05:30
Kovid Goyal
39f41faf9f Dont send events for modifier keys unless in all key mode 2021-01-16 20:52:14 +05:30
Kovid Goyal
6b2ffc774f Port shortcut and sequence matching code 2021-01-16 20:52:14 +05:30
Kovid Goyal
f94a5f4e5c Add a Quickstart section to the protocol documentation 2021-01-16 20:52:14 +05:30
Kovid Goyal
c421fd56be Ensure typing in shell works in disambiguate mode 2021-01-16 20:52:14 +05:30
Kovid Goyal
11de87d9d9 It's ok that Enter and F3 share a number
Enter has u has trailer, F3 has either ~ or 1R
2021-01-16 20:52:14 +05:30
Kovid Goyal
8f5d42fa11 Python wrapper for key events from window system 2021-01-16 20:52:14 +05:30
Kovid Goyal
e14fcf5590 Clean up docs 2021-01-16 20:52:14 +05:30
Kovid Goyal
f5b81c7ed6 ... 2021-01-16 20:52:13 +05:30
Kovid Goyal
47a901385f Implement reporting of all keys as escape codes with text 2021-01-16 20:52:13 +05:30
Kovid Goyal
819bd5cd70 Tests for alternate key reporting 2021-01-16 20:52:13 +05:30
Kovid Goyal
753ad68ca9 Add tests for event type reporting 2021-01-16 20:52:13 +05:30
Kovid Goyal
5498f4e526 ... 2021-01-16 20:52:13 +05:30
Kovid Goyal
83a01b6bf4 Add tests for the disambiguate flag 2021-01-16 20:52:13 +05:30
Kovid Goyal
c519013b20 Add tests for legacy letter key encodings 2021-01-16 20:52:13 +05:30
Kovid Goyal
78d45eb161 Port another use of the old key API 2021-01-16 20:52:13 +05:30
Kovid Goyal
eeacac227a Add tests for functional KP keys 2021-01-16 20:52:13 +05:30
Kovid Goyal
529e9f83f7 Finish up functional key tests 2021-01-16 20:52:13 +05:30
Kovid Goyal
5297f7474d Remove another use of GLFW_KEY 2021-01-16 20:52:13 +05:30
Kovid Goyal
e06b48a344 Identify SS3 in the docs 2021-01-16 20:52:13 +05:30
Kovid Goyal
7ba57ebf62 esc also needs a low number 2021-01-16 20:52:12 +05:30
Kovid Goyal
1ec9a8b777 Fix parsing of shortcuts to support the new keys 2021-01-16 20:52:12 +05:30
Kovid Goyal
1690718710 More removal of GLFW_KEY_ constants 2021-01-16 20:52:12 +05:30
Kovid Goyal
774a6c8c8b Remove glfw key constants 2021-01-16 20:52:12 +05:30
Kovid Goyal
f06eee8fe1 Define special numbers in one place only 2021-01-16 20:52:12 +05:30
Kovid Goyal
2b12bcc07f Docs for legacy functional encoding 2021-01-16 20:52:12 +05:30
Kovid Goyal
a30ea2b7f8 Implement progressive enhancement of key event reporting 2021-01-16 20:52:12 +05:30
Kovid Goyal
295e8db04c remove unused code 2021-01-16 20:52:12 +05:30
Kovid Goyal
b63ae10a09 Start documenting new keyboard protocol 2021-01-16 20:52:12 +05:30
Kovid Goyal
c8a9336160 Code to encode key events 2021-01-16 20:52:12 +05:30
Kovid Goyal
c0b6078438 Add more keypad keys 2021-01-16 20:52:11 +05:30
Kovid Goyal
ccce8c32a3 Mapping to unicode and back for XKB keys 2021-01-16 20:52:11 +05:30
Kovid Goyal
8f8be9c2b1 Add notice to not edit generated code 2021-01-16 20:52:11 +05:30
Kovid Goyal
eb8e2225e5 Add some more functional keys
Also define aliases for XKB codes
2021-01-16 20:52:11 +05:30
Kovid Goyal
397d7d044b Change key data type in some functions 2021-01-16 20:52:11 +05:30
Kovid Goyal
a681162326 Start work on supporting arbitrary unicode keys 2021-01-16 20:52:11 +05:30
Kovid Goyal
f00ec0ff60 Merge branch 'm1-build-fix' of https://github.com/pjjw/kitty 2021-01-15 10:52:01 +05:30
Peter Woodman
35982a9e58 Make is_arm predicate work on macos 2021-01-15 00:09:24 -05:00
Kovid Goyal
cf0bdf4d59 Add another couple of integrations 2021-01-14 06:36:18 +05:30
Kovid Goyal
8a9d43e84d Changelog item for last PR 2021-01-13 06:58:01 +05:30
Kovid Goyal
578bf963e3 Merge branch 'master' of https://github.com/quentin-fox/kitty 2021-01-13 06:57:25 +05:30
Quentin Fox
292c4ce450 add menu item to close window 2021-01-12 19:55:51 -05:00
Kovid Goyal
8ea589e5a3 Change blurb wording slightly 2021-01-12 20:01:44 +05:30
Kovid Goyal
ad09ccb0f2 Panel kitten: Allow setting WM_CLASS
Fixes #3233
2021-01-12 04:49:45 +05:30
Kovid Goyal
edfc6903ce Remove unused code 2021-01-08 13:32:52 +05:30
Kovid Goyal
b94d2b27f4 Refactor single key config parsing to use a special type 2021-01-07 18:07:17 +05:30
Kovid Goyal
31cb68840a Merge branch 'bugfix-unicode-names-input' of https://github.com/purxiz/kitty
Fixes #3221
2021-01-07 14:18:24 +05:30
purxiz
89c62377da fix type error
I moved the location of the check for an overflowing index to avoid a type error that was revealed by mypy. I also think this is a better place to put it from a code standpoint in general...
2021-01-06 13:24:38 -06:00
purxiz
85afda8832 fixes incorrect hint base
The bases for the hint were being decoded as base 16, despite being displayed as base 36 (0-9, a-z). This fix makes it so typing 'search string .index' returns the unicode char at the expected index, based on what is displayed by the program.

It also slightly changes the behavior. Before, only the selected result would appear. For example, musical note `musical note .18` would only show a single result, since there was only a single result at index 18. Now, searching by index doesn't remove codepoints/results, it simply highlights the result at the correct index for you.
2021-01-06 13:07:41 -06:00
Kovid Goyal
5184e4bde3 Fix #3217 2021-01-06 22:31:09 +05:30
Kovid Goyal
133b580262 Avoid error prints when rendering the space glyph and freetype fails to load it
Also a micro-optimization, since there is no need to actually render the
space glyph
2021-01-05 12:21:06 +05:30
Kovid Goyal
3e76cf87ce Linux: Fix rendering of emoji followed by the graphics variation selector not being colored with some fonts
Harfbuzz, for some reason has started rendering variation selector
glyphs. These fail to load for some fonts. https://github.com/harfbuzz/harfbuzz/issues/2804

Fixes #3211
2021-01-05 09:35:21 +05:30
Kovid Goyal
f72ff73344 Correct return type 2021-01-05 09:17:17 +05:30
Kovid Goyal
9aae346ab5 Better error message when failing to load glyph 2021-01-05 09:10:35 +05:30
Kovid Goyal
ca65ad6fa3 Inline qsort
Cleaner, more local code and faster sorting by virtue of inlining the
comparisons. What's not to like.
2021-01-04 14:14:15 +05:30
Kovid Goyal
0f4156c564 ... 2021-01-04 13:15:29 +05:30
Kovid Goyal
3a0d3dc0b3 Slightly improved command line 2021-01-04 13:14:14 +05:30
Kovid Goyal
d68c338304 Wait for write and check data, fixes test failure 2021-01-04 12:27:26 +05:30
Kovid Goyal
82f8c59bc7 ... 2021-01-04 12:18:42 +05:30
Kovid Goyal
c55f485166 Add an example of using the remote control protocol from a shell script 2021-01-04 12:17:20 +05:30
Kovid Goyal
2762488c81 Remove double increment 2021-01-03 21:10:37 +05:30
Kovid Goyal
ac13ae727f Fix failing test
We cant know what the size of the disk cache file is,
since defragmentation occurs asynchronously
2021-01-03 21:05:08 +05:30
Kovid Goyal
1b59a1c421 Finish tests of disk cache 2021-01-03 17:36:40 +05:30
Kovid Goyal
df00e9545d Add some more ensure_state() 2021-01-03 12:13:08 +05:30
Kovid Goyal
d1496f1eb5 Use O_TMPFILE when available 2021-01-03 07:07:50 +05:30
Kovid Goyal
14d9bcb08a Go back to nanosleep since it is in POSIX 2021-01-03 06:45:53 +05:30
Kovid Goyal
c869774c58 More tests for the disk cache 2021-01-03 06:22:48 +05:30
Kovid Goyal
18679348b2 Use usleep rather than nanosleep 2021-01-03 05:00:40 +05:30
Kovid Goyal
b3ed4c3f40 Simplify implementation of REP
Also make it align more with the standard by using the actual last drawn
graphics character rather than the character before the cursor
2021-01-03 04:38:02 +05:30
Kovid Goyal
8f58140419 Start work on tests for disk cache 2021-01-03 04:28:48 +05:30
Kovid Goyal
bc8a351558 Add repeat character to client.py 2021-01-02 12:49:33 +05:30
Kovid Goyal
9ae198ef8f Double clicking on empty tab bar area now opens a new tab
Fixes #3201
2021-01-02 11:45:18 +05:30
Kovid Goyal
bc86bc91f7 Auto-defrag cache file 2021-01-02 11:32:38 +05:30
Kovid Goyal
a60f347648 Merge branch 'kitten-diff-select-fg-none' of https://github.com/tomaskrizek/kitty 2021-01-02 09:01:25 +05:30
Tomas Krizek
dbe44c9e4b kitten/diff: allow specifying none color for select_fg
Allow diff kitten to not override foreground color for selections.

Related #1358
2021-01-01 23:25:06 +01:00
Tomas Krizek
fb8b9b3933 kitty/config_data: remove duplicate function
selection_foreground() serves the exact same purpose as
to_color_or_none()
2021-01-01 23:23:47 +01:00
Kovid Goyal
56ebc9fa92 Add a link to ctx.graphics 2021-01-01 15:20:47 +05:30
Kovid Goyal
7f73609c77 Update total_size when removing cache items 2021-01-01 14:31:57 +05:30
Kovid Goyal
3ac70042c1 Expose grman disk cache to python 2021-01-01 14:19:10 +05:30
Kovid Goyal
61637a7a74 Simplified API t read from disk cache
Avoids the need to pass a custom allocator by using malloc
2021-01-01 14:16:26 +05:30
Kovid Goyal
49562e96cc Python wrappers for the disk cache methods 2021-01-01 14:08:23 +05:30
Kovid Goyal
58b1868536 When cache is emptied clear disk file to avoid fragmentation 2021-01-01 13:15:21 +05:30
Kovid Goyal
1cad40e977 ... 2021-01-01 12:03:09 +05:30
Kovid Goyal
9fbf23fdcc Implement simple defrag for on-disk cache 2021-01-01 11:54:13 +05:30
Kovid Goyal
55e53db184 ... 2020-12-31 15:38:57 +05:30
Kovid Goyal
f790e8bd47 DRYer 2020-12-31 15:33:04 +05:30
Kovid Goyal
54de2d177e Enforce max key size
Also allocate it dynamically
2020-12-31 15:30:55 +05:30
Kovid Goyal
ec96771e4c track total size and since each cache has its own writer thread store current key per thread 2020-12-31 15:24:25 +05:30
Kovid Goyal
99d2647335 Code to write to cache file 2020-12-31 15:18:30 +05:30
Kovid Goyal
c346cbc252 Use a single file for the disk cache
This has the advantage that on crash it is automatically cleaned
2020-12-31 13:54:33 +05:30
Kovid Goyal
3c77290c2c Code to get random bytes in C, cross-platform 2020-12-31 11:26:22 +05:30
Kovid Goyal
72d193e852 Fix python3.7 fork registration not working 2020-12-31 10:38:26 +05:30
Kovid Goyal
1f7499e841 Detect more types of BSD 2020-12-31 10:26:15 +05:30
Kovid Goyal
c486fbb7c3 Add some aliases for shift key shenanigans 2020-12-30 21:09:03 +05:30
Kovid Goyal
fe1050fc0e More work on disk cache 2020-12-30 14:26:38 +05:30
Kovid Goyal
3162d391cc Start work on disk cache 2020-12-29 19:16:21 +05:30
Kovid Goyal
e2d61ab5be Fix error handling for pthread create 2020-12-29 15:53:40 +05:30
Kovid Goyal
2a026de526 More sophisticated PATH resolution for the launch command 2020-12-29 11:51:17 +05:30
Kovid Goyal
c1b7023e3a Look in ~/.local/bin preferentially 2020-12-29 11:50:11 +05:30
Kovid Goyal
175ff4b955 DRYer 2020-12-29 11:36:30 +05:30
Kovid Goyal
65361d56c4 Use find_exe() for resolving editor as well
Avoids having to exec the shell in most cases
2020-12-29 11:33:42 +05:30
Kovid Goyal
08fae7a0ac Add sbin to default paths 2020-12-29 10:50:31 +05:30
Kovid Goyal
a7e9030c12 Make finding ImageMagick a bit more robust on macOS 2020-12-29 10:48:26 +05:30
Kovid Goyal
aa8282f8f2 Update actual terminfo files from last PR
Also add entry to changelog
2020-12-29 10:03:56 +05:30
Kovid Goyal
7155400eb5 Merge branch 'bawr/terminfo-u6789' of https://github.com/bawr/kitty 2020-12-29 10:02:17 +05:30
Kovid Goyal
6760e38d93 Callback to create tempdir in cache 2020-12-29 10:00:34 +05:30
Bartosz Wróblewski
6bbe995d64 Generate u[6789] with terminfo.py
Should not hurt anything, it's just documenting kitty's existing VT220 compatibility.
2020-12-28 14:05:25 -08:00
Kovid Goyal
85bc8b61df Make wm_class/wm_name available in @ ls output 2020-12-26 10:46:07 +05:30
Kovid Goyal
a235509fa1 Make aliasing ssh kitten more prominent 2020-12-24 13:56:17 +05:30
Kovid Goyal
2e5b595a82 Clarify color table docs 2020-12-24 13:54:09 +05:30
Kovid Goyal
5f8dee8384 Add support for the color settings stack that XTerm copied from us without acknowledgement and decided to use incompatible escape codes for.
Completely in keeping with that project's past behavior.
See https://github.com/kovidgoyal/kitty/issues/879

XTerm announcement:
https://www.mail-archive.com/xorg@lists.x.org/msg06419.html
2020-12-21 21:39:05 +05:30
Kovid Goyal
e97f1a4310 Have the save/restore colors escape codes also save restore the ANSI color table 2020-12-21 19:38:03 +05:30
Kovid Goyal
c3c5a5446f Add window_id and window_title fields to --match-tab 2020-12-20 19:39:09 +05:30
Kovid Goyal
3ce04c3e4b version 0.19.3 2020-12-19 08:19:34 +05:30
Kovid Goyal
3b5951eb2f Add a note about aliasing the SSH kitten 2020-12-18 16:59:42 +05:30
Kovid Goyal
aa8dd4ddf4 ... 2020-12-17 11:30:37 +05:30
Kovid Goyal
4cd14aee42 Add a changelog entry for the last merge
Also some misc code/docs cleanups for it.
2020-12-17 11:24:38 +05:30
Kovid Goyal
0b2726ec33 Cleanup fc_match_postscript_name 2020-12-17 11:16:51 +05:30
Kovid Goyal
bc7f689165 Clean up pattern_as_dict 2020-12-17 11:12:35 +05:30
Kovid Goyal
6681652c21 Merge branch 'master' of https://github.com/Diaoul/kitty 2020-12-17 11:02:26 +05:30
Kovid Goyal
ed4b5f179e Full screen kittens: Fix incorrect cursor position after kitten quits
DECOM should be reset only after entering alternate screen as it also
changes cursor position. Fixes #3176
2020-12-17 08:58:44 +05:30
Kovid Goyal
e48e166584 And another 2020-12-17 08:41:58 +05:30
Kovid Goyal
e7675e8bab Add some more commands to the client 2020-12-17 08:37:55 +05:30
Antoine Bertin
cf7eaea88c Add documentation 2020-12-16 18:01:14 +01:00
Antoine Bertin
3e0855ff45 Properly convert font_features to a list 2020-12-16 17:52:43 +01:00
Antoine Bertin
822c9367c6 Support default font_features from fontconfig 2020-12-16 14:58:38 +01:00
Kovid Goyal
0e46e2a6a7 Forgot to add new delete flags to reference table 2020-12-16 19:07:25 +05:30
Kovid Goyal
ade7ef19e7 Fix #3173 2020-12-16 19:00:31 +05:30
Kovid Goyal
e82a6dedd9 Fix deletion with image numbers 2020-12-16 18:57:46 +05:30
Kovid Goyal
2fd6bf7442 Fix failing test
Error responses must be sent for put commands that refer
non-existent images
2020-12-16 18:41:47 +05:30
Kovid Goyal
d10681f27f Send responses when only a number and no id is specified 2020-12-16 18:31:30 +05:30
Kovid Goyal
e96ff19a7a Graphics protocol: Add support for having the terminal emulator assign image ids
Useful when multiple non co-operating programs want to share the screen.
Fixes #3163
2020-12-16 17:31:15 +05:30
Kovid Goyal
09e75ea329 Add a note about cursor movement after placing an image. 2020-12-15 07:37:14 +05:30
Kovid Goyal
84b03e9f77 ... 2020-12-14 20:06:43 +05:30
Kovid Goyal
55597dcea5 Add the needed import to the example 2020-12-14 19:23:30 +05:30
Kovid Goyal
3290bf3c35 Merge branch 'patch-1' of https://github.com/ThatNerdyPikachu/kitty 2020-12-14 08:37:53 +05:30
Pika
6771429911 Update faq.rst 2020-12-13 19:04:14 -05:00
Kovid Goyal
e428858ad6 Micro-optimization 2020-12-12 17:43:33 +05:30
Kovid Goyal
3e73f860d1 Fix assert in ringbuf_memcpy_from 2020-12-11 21:38:58 +05:30
Kovid Goyal
4cf5bd8d70 Turn on the asserts in ringbuf for debug builds 2020-12-11 21:26:15 +05:30
Kovid Goyal
bffe0f4a6c Use a separate, re-useable ring-buffer implementation
Not only is it re-useable it also allows for easier debugging by
separating the ring buffer specific logic and the pager history logic.

Hopefully it fixes #3049
2020-12-11 21:17:38 +05:30
Kovid Goyal
3b8be26cc7 Workaround for Ubuntu as usual shipping with insanely outdated packages
Fixes #3160
2020-12-11 12:22:28 +05:30
Kovid Goyal
9e95939c47 Add wttr.in to integrations 2020-12-11 07:21:22 +05:30
Kovid Goyal
0af7af95cf Merge branch 'master' of https://github.com/molly-cactus/kitty 2020-12-09 08:17:22 +05:30
Margaret K. Geiger
2b3e2ea6f8 Add tab_switch_strategy option 'right' 2020-12-08 16:55:27 -08:00
Kovid Goyal
19870983ca Allow specifying text formatting in tab_title_template
Fixes #3146
2020-12-08 21:42:40 +05:30
Kovid Goyal
6e83b4c1bc Make it more prominent when you dont need allow_remote_control 2020-12-07 16:24:54 +05:30
Kovid Goyal
14f5e10fd6 Fix mapping of remote_control not working for actions that yield generators
Fixes #3147
2020-12-07 16:15:44 +05:30
Kovid Goyal
ed41e3cd25 Add mentions of glkitty to the docs
Fixes #3111
2020-12-06 08:23:25 +05:30
Kovid Goyal
4cc58e8535 Better fix for filtering out -march=native 2020-12-04 20:59:18 +05:30
Kovid Goyal
e1d9686eb5 Merge branch 'master' of https://github.com/runchard/kitty 2020-12-04 19:35:25 +05:30
Runchard
c5cb4f9e69 do not use clang option -march=native on Apple Silicon
Apple Silicon arm64-apple-darwin clang do not support `-march` option.
2020-12-04 21:07:19 +08:00
Kovid Goyal
4a60413e0b ... 2020-12-03 21:38:42 +05:30
Kovid Goyal
245f5d60b5 Add a test for image put + delete + put 2020-12-03 21:37:32 +05:30
Kovid Goyal
23420adfa6 Graphics protocol: Allow suppressing responses from the terminal to graphics commands 2020-12-03 20:42:03 +05:30
Kovid Goyal
c9828dfece Removed unused parameter 2020-12-03 20:02:16 +05:30
Kovid Goyal
f52c843fa2 Add support for placement id to GraphicsCommand 2020-12-02 05:35:57 +05:30
Kovid Goyal
b5e704a934 Graphics protocol: Add support for giving individual image placements their
Fixes #3133
2020-12-02 05:25:19 +05:30
Kovid Goyal
0173959e64 Make a note that images can be placed and such are known as placements 2020-12-01 21:21:24 +05:30
Kovid Goyal
b00cd5cbc3 Match save/restore cursor behavior of other terms
For the sake of interoperability. This means that doing a DECRC without
a prior DECSC is now undefined. However, one can now issue multiple
DECRC for a single DECSC. Fixes #1264
2020-12-01 17:55:17 +05:30
Kovid Goyal
00aba7c646 Add basic editing support for the broadcast kitten 2020-12-01 17:35:15 +05:30
Kovid Goyal
34db18ea0a Also transmit key events when broadcasting 2020-12-01 14:11:50 +05:30
Kovid Goyal
457c292d3c Fix one ANSI formatting escape code not being removed from the pager history buffer when piping it as plain text
Fixes #3132
2020-12-01 13:17:35 +05:30
Kovid Goyal
f481c17732 The broadcast kitten
Fixes #1569
2020-12-01 13:11:32 +05:30
Kovid Goyal
4a049b14ca Fix infinite loop in send-text when stdin is a tty 2020-12-01 12:29:03 +05:30
Kovid Goyal
ed2dae5884 Fix error when sending empty write buf 2020-12-01 12:25:09 +05:30
Kovid Goyal
df61ee4ac3 ... 2020-12-01 11:39:50 +05:30
Kovid Goyal
850bc12929 DRYer 2020-11-30 22:16:21 +05:30
Kovid Goyal
559e17eb13 Add a couple more useful options to control selected windows for @ send-text 2020-11-30 22:04:46 +05:30
Kovid Goyal
4c4f6983d1 Fix env LC_CTYPE=UTF-8 not working on macOS 2020-11-30 16:23:29 +05:30
Kovid Goyal
2dbeb151f3 Changelog entry for traditional fullscreen on Big Sur 2020-11-29 12:04:52 +05:30
Kovid Goyal
82c137878c Graphics protocol: Dont return filename in the error message when opening file fails, since filenames can contain control characters
Fixes #3128
2020-11-29 12:02:14 +05:30
Kovid Goyal
8845bd6ed3 ... 2020-11-27 15:28:16 +05:30
Kovid Goyal
c89d861c0e Add A FAQ entry about opening new windows with the cwd 2020-11-25 17:47:20 +05:30
Kovid Goyal
3ed536ace1 ... 2020-11-22 12:32:12 +05:30
Kovid Goyal
d13ad4ec4b Merge branch 'nohand' of https://github.com/derekschrock/kitty
Also add a changelog entry and some stylistic fixes
2020-11-22 12:31:28 +05:30
Kovid Goyal
cb5ac1fcf8 DRYer 2020-11-22 12:24:00 +05:30
Kovid Goyal
53797b9ead Wayland: Fix key repeat being stopped by the release of an unrelated key
Fixes #2191
2020-11-22 12:14:52 +05:30
Derek Schrock
cb164e5cac Add new option detect_urls to check for URLs under the mouse cursor
Enabled by default add new option `detect_urls` that will allow you
contorl if kitty should detect URLs under the mouse cursor.  If disabled
the URLs are still clickable with open_url_modifiers.
2020-11-22 00:58:26 -05:00
Kovid Goyal
c46ebebbb3 Override the min-width for body from the alabaster theme
For some reason it sets min width to 450px which is too wide
for some mobile screens. Fixes #3116
2020-11-22 09:14:17 +05:30
Kovid Goyal
ff96036f62 Better window title when choosing tabs/OS windows 2020-11-21 14:58:08 +05:30
Kovid Goyal
6409786f8d Add a new mappable select_tab action to choose a tab to switch to even when the tab bar is hidden
Fixes #3115
2020-11-21 14:52:18 +05:30
Kovid Goyal
05eb07caf5 Add to changelog for last merge
Also remove a spurious return that was disabling a test. Fixes #3113
2020-11-20 20:23:23 +05:30
Kovid Goyal
f5b2a60549 Merge branch 'scroll-region-scrollback' of https://github.com/romkatv/kitty 2020-11-20 20:20:53 +05:30
Roman Perepelitsa
620eaf1ada Change the flow of lines from the scroll region to the scrollback
There are two user-visible changes in here:

1. If a scroll region is set such that there is a bottom margin and no
   top margin, scrolling the region forward used to discard the top
   lines. Now those lines are appended to the scrollback.
   ```shell
   # Assuming a terminal window with 24 lines.
   printf '\033[H\033[J\033[3J\033[0;5r' && seq 100
   ```
   This command used to result in an empty scrollback. Now it contains
   the numbers 1-96.
2. If a scroll region is set such that there is a top margin and no bottom
   margin, scrolling the region forward used to append the top lines to
   the scrollback. Now these lines are discarded.
   ```shell
   # Assuming a terminal window with 24 lines.
   printf '\033[H\033[J\033[3J\033[2;24r' && seq 100
   ```
   This command used to populate scrollback with the numbers 2-78. Now
   the scrollback is empty. The numbers on the screen are the same as
   before: 1 and 79-100.

Related issue: #3113.
2020-11-20 15:41:57 +01:00
Kovid Goyal
9193a20b44 macOS: Fix minimize not working for chromeless windows
Fixes #3112
2020-11-20 07:30:46 +05:30
Kovid Goyal
bdcac9aed3 Partial fix for traditional full screen on Big Turd 2020-11-16 10:23:01 +05:30
Kovid Goyal
e9a28550cc explanatory note 2020-11-15 14:31:40 +05:30
Kovid Goyal
f3cd3e74ae ... 2020-11-15 10:17:32 +05:30
Kovid Goyal
b853fc30c0 Merge branch 'master' of https://github.com/dankamongmen/kitty 2020-11-15 10:13:00 +05:30
nick black
63e32a94c0 Sextants: fix arithmetic mistake that broke 🬓, 🬦, 🬧
The scheme used in draw_sextant works well enough, but the
feed was broken. 21 and 42 need to be skipped, not 20 and
40. Without this change, the following glyphs are broken:

U+1FB13 BLOCK SEXTANT-35 🬓 renders as LEFT HALF
U+1FB26 BLOCK SEXTANT-46 🬦 renders as SEXTANT-146
U+1FB27 BLOCK SEXTANT-146 🬧 renders as RIGHT HALF

With this change, the entirety of the sextant block works
correctly. Found debugging the Notcurses sextant blitter:

https://github.com/dankamongmen/notcurses/issues/1112
2020-11-14 23:30:25 -05:00
Kovid Goyal
ef596f6a8b Distribute extra pixels among all eight-blocks rather than adding them all to the last block
Makes one block stand out less, every block is now at most a pixel in
size different from every other block. Fixes #3097
2020-11-14 11:06:47 +05:30
Kovid Goyal
c830097511 Add a note about using hyperlinks with the hints kitten 2020-11-14 00:03:15 +05:30
Kovid Goyal
d8790a4628 Make the help text for --linenum-action less confusing 2020-11-13 23:53:26 +05:30
Kovid Goyal
e06ef732d8 version 0.19.2 2020-11-13 09:32:53 +05:30
Kovid Goyal
792a3e7db8 Dont mix the raw/non-raw malloc/free for pagerhist 2020-11-13 08:12:26 +05:30
Kovid Goyal
9b32842f66 Fix #3096 2020-11-13 07:47:40 +05:30
Kovid Goyal
9816979169 Don't restrict the DCH control code to only the current scroll region
Matches behavior of other terminal emulators.  Fixes #3090
2020-11-12 11:44:09 +05:30
Kovid Goyal
a74679dd95 Fix last character of URL not being detected if it is the only character on a new line
Fixes #3088
2020-11-11 14:00:33 +05:30
Kovid Goyal
a40059729e Fix the send_text action not working in URL handlers
send_text keeps its args as byte string, so variable expansion was not
working. Fixes #3081
2020-11-11 07:51:43 +05:30
Kovid Goyal
6bab967586 Merge branch 'memory-leak' of https://github.com/Luflosi/kitty 2020-11-05 18:15:44 +05:30
Luflosi
bb88b33469 Fix memory leak
Found with the Clang Static Analyzer.
2020-11-05 13:15:19 +01:00
Kovid Goyal
c440470276 Entry point to edit config file 2020-11-04 16:30:29 +05:30
Kovid Goyal
ef6164eecb Merge branch 'incorrect-reference-count-decrement' of https://github.com/Luflosi/kitty 2020-11-04 07:44:00 +05:30
Luflosi
7ad360d872 Fix incorrect decrement of the reference counts of objects
Found with the Clang Static Analyzer.
The function `schedule_notification()` for the new notification API also does not `release` similar objects.
2020-11-03 18:17:58 +01:00
Kovid Goyal
0870a33956 Merge branch 'memory-leak' of https://github.com/Luflosi/kitty 2020-11-01 18:47:31 +05:30
Luflosi
3ccc2f538d Fix memory leak in unlikely failure condition
Found with the Clang Static Analyzer.
2020-11-01 13:41:52 +01:00
Kovid Goyal
17375f0be2 Add a link to nix-shell 2020-10-31 09:10:50 +05:30
Kovid Goyal
5a987a162e Merge branch 'add-shell.nix' of https://github.com/Luflosi/kitty 2020-10-31 07:31:19 +05:30
Luflosi
5058fb9919 Add shell.nix
This makes it possible to execute `nix-shell` to create the correct environment to build kitty. Use `nix-shell --pure` to eliminate most of the influence of the outside system, e.g. globally installed packages.
This works on NixOS and any Linux or macOS system with the Nix package manager installed.
The build inputs are split into `buildInputs`, `nativeBuildInputs`, `propagatedBuildInputs` and `checkInputs` so it closely resembles 2bb3a9da24/pkgs/applications/terminal-emulators/kitty/default.nix. This makes it easy to port changes between the two files.
2020-10-31 01:44:33 +01:00
Luflosi
3335f8602b Allow reading some build system flags as environment variables 2020-10-29 12:20:11 +01:00
Kovid Goyal
87ab1bbe54 Add a changelog entry for previous merge 2020-10-29 07:20:45 +05:30
Kovid Goyal
f8d52b33f4 Merge branch 'wl_fix_destroy_csds' of https://github.com/LeonardKoenig/kitty 2020-10-29 07:19:57 +05:30
Leonard König
bc2dcdf9db wl: Fix destroying CSDs in correct order (#3051)
On Wayland, some compositors refuse to implement SSDs in which case we draw
primitive CSDs.  However, the destructors were called in the wrong order,
leading to a dereference of an already freed object.
2020-10-28 18:57:37 +01:00
Kovid Goyal
93d1aacfb6 macOS: Fix kitty not being added to PATH automatically
Fixes #3063. Apparently in newer Python, Py_Initialize() nukes
sys._xoptions when the isolate flag is set.
2020-10-27 10:38:33 +05:30
Kovid Goyal
3ddaa4aff9 Make it clear that remote control mappings dont need remote control enabled 2020-10-26 16:51:53 +05:30
Kovid Goyal
75488d568a Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-10-26 16:34:30 +05:30
Luflosi
3df80545bd Reduce the difference of GLFW to upstream 2020-10-26 11:02:55 +01:00
Kovid Goyal
c605fd9783 Merge branch 'remove-extra-space' of https://github.com/Luflosi/kitty 2020-10-26 15:03:25 +05:30
Luflosi
60719e7bff Remove extra space 2020-10-26 10:22:14 +01:00
Kovid Goyal
e9faa3277a Merge branch 'fix-memory-leak' of https://github.com/Luflosi/kitty 2020-10-26 07:33:06 +05:30
Luflosi
35f7388725 Fix memory leaks in coretext_all_fonts()
Found with the Clang Static Analyzer.
2020-10-25 17:40:51 +01:00
Kovid Goyal
ef1486a779 Add .js and .json to known extensions 2020-10-25 20:25:31 +05:30
Kovid Goyal
95c44165e9 Merge branch 'fix-clang-analyze-error' of https://github.com/Luflosi/kitty 2020-10-25 20:24:28 +05:30
Kovid Goyal
7b816bb96f Font independent rendering for braille characters, which ensures they are properly aligned at all font sizes. 2020-10-25 20:20:22 +05:30
Luflosi
d2ac51aa4a Fix Clang Static Analyzer complaining about Apple coding conventions
The error message was: "Method accepting NSError** should have a non-void return value to indicate whether or not an error occurred".
2020-10-25 15:47:43 +01:00
Kovid Goyal
26974b1f3a Dont ignore --title when using an empty session
Fixes #3055
2020-10-25 18:53:57 +05:30
Kovid Goyal
3960c6678d Override MIME for some types that are actually text 2020-10-25 15:11:44 +05:30
Kovid Goyal
30b8991a73 DRYer 2020-10-25 13:47:12 +05:30
Kovid Goyal
75a94bcd96 Improving MIME type detection for some common file types when they are missing from the system MIME database
Also allow the user to specify their own database via mime.types in the
kitty config directory. See #3056
2020-10-25 13:42:11 +05:30
Kovid Goyal
e160cbf32b ssh kitten: Fix parsing of combined single letter options to more closely match ssh. Fixes #3053 2020-10-23 16:55:53 +05:30
Kovid Goyal
2da2e63245 Add another integration 2020-10-23 09:36:35 +05:30
Kovid Goyal
f160ea6012 Fix #3048 2020-10-21 21:57:35 +05:30
Kovid Goyal
8057bc639d Add diff context parser defs 2020-10-20 11:37:48 +05:30
Kovid Goyal
6f5ec5aa03 Merge branch 'fix-mistake-in-previous-pr' of https://github.com/Luflosi/kitty into master 2020-10-19 16:41:01 +05:30
Luflosi
e343c9445c Creating a temporary directory is not actually required
While developing the previous PR (https://github.com/kovidgoyal/kitty/pull/3043), I was using more compiler command line arguments, one of which was `-MMD`. This caused the .d file to be created. Without this argument, there is no need to create a temporary directory.
2020-10-19 13:08:32 +02:00
Kovid Goyal
c73e374f1a Remove unneeded space 2020-10-19 16:02:49 +05:30
Kovid Goyal
d9b292f808 Merge branch 'fix-macos-notification-api-detection' of https://github.com/Luflosi/kitty into master 2020-10-19 16:00:38 +05:30
Luflosi
46ef2f313b macOS: Fix detection for notification API
For some reason it can happen that the `UserNotifications` framework exists but the `UserNotifications/UserNotifications.h` header doesn't.
Closes https://github.com/kovidgoyal/kitty/issues/3042.
2020-10-19 12:19:51 +02:00
Luflosi
92a705c79e Add language parameter to first_successful_compile() and test_compile()
This allows compiling Objective-C files.
The temporary directory is needed because clang would try to write to `/dev/null.d`, which would obviously fail.
2020-10-18 23:08:19 +02:00
Kovid Goyal
12ebdd2574 Add a changelog entry for the last PR 2020-10-18 08:48:07 +05:30
Kovid Goyal
ed2e951032 Merge branch 'pointer_shape_when_dragging' of https://github.com/jaeheum/kitty into master 2020-10-18 08:46:18 +05:30
Kovid Goyal
01a34a8846 Add links to viu that supports the graphics protocol 2020-10-18 08:42:59 +05:30
Jay Han
b13174cb9c pointer_shape_when_dragging option + set_mouse_cursor_when_dragging() 2020-10-17 09:52:44 -07:00
Jay Han
03ac6cab99 default_pointer_shape option 2020-10-17 09:28:04 -07:00
Kovid Goyal
532eebaefb Merge branch 'fix-garbage-pointer-dereference' of https://github.com/Luflosi/kitty into master 2020-10-16 07:35:31 +05:30
Luflosi
f825345b14 Fix potential garbage pointer dereference
`create_os_window()` calls `get_window_content_scale()` without initializing the `xscale` and `yscale` variables. Instead of initializing them everywhere, where this function is called, just do it once in the function itself.
Found with the Clang Static Analyzer.
2020-10-15 20:41:16 +02:00
Kovid Goyal
1409477ed7 Merge branch 'double-free' of https://github.com/Luflosi/kitty into master 2020-10-15 19:11:31 +05:30
Luflosi
d8e4294432 Fix double free and memory leak
Found with the Clang Static Analyzer.
This is a copy & paste error. This bug was introduced in 72e2307c16 in Jul 2018.
2020-10-15 15:29:44 +02:00
Kovid Goyal
5d13908776 github actions CI updated to python 3.9
Pillow wheel currently not available for python 3.9. So tries to install
from source and fails on missing zlib. So install zlib in brew and make
it available via PKG_CONFIG_PATH. Apparently, this wont be necessary
after Pillow 8, but who knows.
2020-10-14 19:13:46 +05:30
Luflosi
2832a73285 GLFW: Wayland: Assume 96 DPI if physical size is <= 0
From upstream: 0ef149c8f2.
2020-10-14 14:43:40 +02:00
Kovid Goyal
4152ed5809 Update changelog 2020-10-14 08:51:07 +05:30
Kovid Goyal
8a90ed70ee Merge branch 'fix-upwards-selection-clearing' of https://github.com/Luflosi/kitty into master 2020-10-14 05:31:08 +05:30
Luflosi
e2646c08a5 Fix upwards selection not being cleared when lines change
When selecting text by dragging upwards, the "end" of the selection is above the "start". This causes the `selection_has_screen_line()` to never return `true` in this case.
In practice this bug causes the selection to not be cleared when the screen contents under the selection change if it was made by dragging upwards.
2020-10-13 21:40:03 +02:00
Kovid Goyal
7122ba820f Fix eight bar unicode chars not being rendered at very small font sizes
Fixes #3025
2020-10-13 20:00:25 +05:30
Kovid Goyal
efca2658ea Fix typing issues pointed out by updated mypy 2020-10-12 23:03:07 +05:30
Kovid Goyal
91a714947c Fix encoding error when reporting capabilities for number of colors 2020-10-12 22:39:05 +05:30
Kovid Goyal
5d3ac649ba Fix #3017 2020-10-08 17:39:44 +05:30
Kovid Goyal
6443e726a6 Add a note about how the query_terminal kitten works 2020-10-08 07:42:47 +05:30
Kovid Goyal
6a755bda45 A new kitten to easily query kitty for config values 2020-10-07 13:35:16 +05:30
Kovid Goyal
dab555ea3b kittens: Dont discard pending input on startup
Fixes #3012
2020-10-06 16:39:00 +05:30
Kovid Goyal
a3bbad0060 Allow specifying the optional actions for tcsetattr 2020-10-06 16:30:23 +05:30
Kovid Goyal
73db717a0c version 0.19.1 2020-10-06 14:03:25 +05:30
Kovid Goyal
f1552c8354 Avoid alias related complications with completion delegation for hyperlinked_grep 2020-10-06 13:53:41 +05:30
Kovid Goyal
fb87fc32f0 Fix a regression that caused a segfault when using scrollback_pager_history_size
Fixes #3011
2020-10-06 13:28:48 +05:30
Kovid Goyal
b04b0c670d Fix #3010
Probably ancient version of Python
2020-10-06 12:09:47 +05:30
Kovid Goyal
b33845df8a Update Changelog 2020-10-06 06:50:29 +05:30
Kovid Goyal
12c9d8d8f8 Delay load the ipaddress module 2020-10-06 06:50:17 +05:30
Kovid Goyal
fe97bbcbbf Merge branch 'master' of https://github.com/Sighery/kitty into master 2020-10-06 06:45:05 +05:30
Sighery
10533c3eba Hints kitten: validate IPs with ipaddress
On the initial commit of this feature, IPs were just matched with a
very simple regex that prioritised simplicity/readability over
accuracy.

This commit adds a postprocessor for ip matches that makes use of
Python's `ipaddress` in the standard library to validate all the IP
matches.

This way we don't need huge and complex regex patterns to match _and_
validate the IPs, and we can just use `ipaddress` to abstract us from
implementing all the validation logic into the regex pattern.
2020-10-05 20:11:25 +02:00
Sighery
b4415c90f9 Hints kitten: add support for IPs (v4 and v6)
It selects v4 and v6 IPs with a simple regex that doesn't actually
check for the validity of the IPs.
2020-10-05 20:11:22 +02:00
Kovid Goyal
2970bbdf6f Update GA tags
Also auto gen docs if running publish only for website
2020-10-05 20:04:32 +05:30
Kovid Goyal
95a420534d Remove the old asciidoc files
By now hopefully the kitty website is well established
2020-10-05 19:34:02 +05:30
Kovid Goyal
be56a21574 ... 2020-10-05 19:33:09 +05:30
Kovid Goyal
3741a235fe Merge branch 'patch-1' of https://github.com/Nudin/kitty into master 2020-10-05 19:28:22 +05:30
Michael F. Schönitzer
523b6c4c2d Fix wrong kittenname in documentation
It's called `hyperlinked_grep` not `hyperlink_grep`.
2020-10-05 15:54:11 +02:00
Kovid Goyal
c3b2300310 Merge branch 'remove-outdated-check' of https://github.com/Luflosi/kitty into master 2020-10-05 18:16:06 +05:30
Luflosi
1c4a20d86f Remove outdated Python version check
The Python version is already checked at the top of the file. That check was added in 81a58186c6.
2020-10-05 14:41:07 +02:00
Kovid Goyal
f5af475012 Merge branch 'notification_fix' of https://github.com/nertpinx/kitty into master 2020-10-05 18:09:35 +05:30
Martin Kletzander
f149b74332 Fix repeated version notifications
Without this fix the file with the list of notifications looks like this:
```
0.19.0,1601899026.4373078,<built-in method count of Notification object at 0x7f8c582193b0>
```
which ends up notifying about a new version all the time.
2020-10-05 14:27:47 +02:00
Kovid Goyal
8cd51386cb Fix some typos in the OSC 99 spec 2020-10-05 17:27:41 +05:30
Kovid Goyal
fb2cca88df Merge branch 'pip3-in-ci' of https://github.com/Luflosi/kitty into master 2020-10-04 21:23:29 +05:30
Luflosi
031d4dc85a Use pip3 instead of pip for CI
There was a warning when the CI executed the "macOS Brew" job:
```
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
```
To fix this, use pip3 instead of pip.
2020-10-04 17:47:41 +02:00
Kovid Goyal
bf66d1c0f5 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty into master 2020-10-04 21:13:48 +05:30
Luflosi
0edfa88755 Reduce the difference of GLFW to upstream 2020-10-04 17:34:51 +02:00
Kovid Goyal
dba1f3bcbc Merge branch 'add-comment' of https://github.com/Luflosi/kitty into master 2020-10-04 21:01:12 +05:30
Luflosi
e204cc8f12 Add comment on how to call send_test_notification() 2020-10-04 17:23:50 +02:00
Kovid Goyal
9e3c60f43f Make ancient gcc happy 2020-10-04 19:56:10 +05:30
Kovid Goyal
b03dd5b6b2 ... 2020-10-04 18:43:59 +05:30
Kovid Goyal
2aa9886ebb version 0.19.0 2020-10-04 18:42:21 +05:30
Kovid Goyal
225e52b8b9 Merge branch 're-add-deprecated-macos-notifications' of https://github.com/Luflosi/kitty into master 2020-10-04 18:16:09 +05:30
Luflosi
0ae1f9906f macOS: re-add deprecated notification API
The new User Notifications Framework is only available on macOS 10.14 and above, while the old NSUserNotification API is deprecated in macOS 11 (Big Sur) and will probably be removed in the future.
This commit compiles a simple test program to see if the Framework is available and then uses either the new or the old API.
2020-10-04 13:32:28 +02:00
Kovid Goyal
a5918b50f8 Merge branch 'better-build-output-for-pipes' of https://github.com/Luflosi/kitty into master 2020-10-04 15:50:39 +05:30
Luflosi
fa0374ee61 Better build system output when stdout is not a tty
When piping the output of `setup.py` to another program, that program cannot usually deal with escape sequences well. To fix this, output the compilation progress on new lines instead of overwriting the current line.
2020-10-04 12:02:49 +02:00
Kovid Goyal
5b1e1aee3d Merge branch 'flag-to-disable-lto' of https://github.com/Luflosi/kitty into master 2020-10-04 15:00:10 +05:30
Luflosi
3ba11d08fb Add flag to disable LTO
Disabling Link Time Optimization is useful for Nix on Darwin because LTO is broken there and has been for a long time, see https://github.com/NixOS/nixpkgs/pull/19312.
This is currently worked around in the Nix package with a patch that removes the lines that add -flto to the compiler flags.
2020-10-04 10:50:42 +02:00
Kovid Goyal
35d0f42d07 Add a note about creating self-signed app bundles 2020-10-04 08:25:58 +05:30
Kovid Goyal
f08f222337 Merge branch 'macos-notifications-add-subtitle' of https://github.com/Luflosi/kitty into master 2020-10-03 21:31:10 +05:30
Luflosi
7c4ad278d5 macOS: add ability to show subtitles in notifications
This used to be implemented before 4e3c6e52aa, when the now deprecated notifications framework was still being used.
Implement it again for feature parity.
2020-10-03 16:04:32 +02:00
Kovid Goyal
d3d2930bd2 typo 2020-10-01 20:19:14 +05:30
Kovid Goyal
b571c20acc Clean up docs for --copy-env 2020-10-01 12:43:26 +05:30
Kovid Goyal
f6cc0302c4 Remove trailing whitespace 2020-10-01 08:34:14 +05:30
Kovid Goyal
d9abcf0c83 Merge branch 'launch-doc' of https://github.com/poliorcetics/kitty into master 2020-10-01 08:22:30 +05:30
Alexis Bourget
5346849439 Add example of remote_control use with launch --copy-env 2020-10-01 01:01:56 +02:00
Alexis Bourget
9742b0c5b1 Add docs precisions for launch and --copy-env 2020-09-30 20:40:14 +02:00
Alexis Bourget
41cfe26898 use :code: block for @... in --stdin-source doc 2020-09-30 20:31:04 +02:00
Kovid Goyal
05a254eee9 Merge branch 'simplify' of https://github.com/Luflosi/kitty into master 2020-09-28 16:20:01 +05:30
Luflosi
8ef53aa363 Remove unnecessary condition
According to the python documentation, `Py_CLEAR()` has no effect when the argument is `NULL`, see https://docs.python.org/3/c-api/refcounting.html#c.Py_CLEAR.
2020-09-28 12:21:23 +02:00
Kovid Goyal
470abc25e4 Changelog entry for hyperlinks with hints kitten 2020-09-25 21:02:27 +05:30
Kovid Goyal
7fe6c7e78b Also handle EOFError 2020-09-25 18:58:03 +05:30
Kovid Goyal
6c8a4f8d9f Handle SIGINT more gracefully 2020-09-25 18:55:43 +05:30
Kovid Goyal
2a8c8c0cbb Fix #2980 2020-09-25 16:06:07 +05:30
Kovid Goyal
12bbe5459d Allow selecting hyperlinks via the hints kitten 2020-09-24 13:21:15 +05:30
Kovid Goyal
e0d9e05fd4 Preserve rg exit code 2020-09-23 20:33:03 +05:30
Kovid Goyal
8bea61cb99 hyperlinked_grep: Ensure filename is always printed
Fixes hyperlinks not working when a single file is searched
2020-09-23 19:11:09 +05:30
Kovid Goyal
d09666aba9 Unicode input kitten: Add symbols from NERD font
These are mostly Private Use symbols not in any standard,
however they are common enough to be useful.

Fixes #2972
2020-09-22 19:47:39 +05:30
Kovid Goyal
48e0ba1d3d Add a note about completion for the hyperlinked_grep kitten 2020-09-22 19:07:36 +05:30
Kovid Goyal
fb72be41f4 Add a test for serializing id less hyperlinks 2020-09-22 17:52:40 +05:30
Kovid Goyal
ef1db6d089 macOS: Add some keys to Info.plist to allow programs running inside kitty to access protected Cocoa APIs. 2020-09-22 16:32:40 +05:30
Kovid Goyal
9d4246a285 Output hyperlink markup when serializing as ANSI 2020-09-22 16:18:22 +05:30
Kovid Goyal
e0f5c39297 Get rid of unneeded malloc in as_text_generic 2020-09-22 09:57:45 +05:30
Kovid Goyal
e4d353b105 Ignore undecodeable bytes in pagerhist
Also add API to get pagerhist as bytes
2020-09-22 09:33:48 +05:30
Kovid Goyal
0d665495b8 Make getting hyperlinks from ids useable throughtout the codebase 2020-09-22 09:25:16 +05:30
Kovid Goyal
fdaf857885 Add more tests for pagerhist 2020-09-22 09:05:40 +05:30
Kovid Goyal
987b41d2cb Implement rewrp for pagerhist using the streaming wcswidth 2020-09-21 19:05:23 +05:30
Kovid Goyal
444080f320 Make wcswidth useable in a streaming fashion 2020-09-21 15:55:22 +05:30
Kovid Goyal
b5007ba276 Store pager history in UTF-8
Reduces storage requirement by a fator of 4 at the cost of some CPU
usage, to encode to UTF-8
2020-09-21 12:29:10 +05:30
Kovid Goyal
bf19d2b156 Add some tests for the pagerhist code 2020-09-21 09:08:46 +05:30
Kovid Goyal
a78515e5bf Remove the max size limit for line_as_ansi
Needed for output of hyperlinks, also more efficient, since avoids
malloc per line. Also fix pagerhist not having SGR reset at the start of
every line.
2020-09-20 11:26:59 +05:30
Kovid Goyal
581126c748 More powerful match criteria for fragments 2020-09-19 07:31:17 +05:30
Kovid Goyal
7b3e345a2a Document the framework for customizing URL open actions 2020-09-18 21:33:30 +05:30
Kovid Goyal
cc7cefd3ed Use unquoted path for filename and path matching 2020-09-18 21:11:39 +05:30
Kovid Goyal
de6528b7d8 Dispatch url actions once per event loop tick
This allows subsequent actions to act on the results of the previous
actions
2020-09-18 20:48:40 +05:30
Kovid Goyal
9efdfe0de4 Fix processing of non-string key actions 2020-09-18 20:41:31 +05:30
Kovid Goyal
f936918278 ... 2020-09-18 19:46:49 +05:30
Kovid Goyal
00125577a9 Add a link to rg hyperlink issue 2020-09-18 19:36:43 +05:30
Kovid Goyal
083c47b0f0 A new kitten to easily search files and open the results at the matched line by clicking on them. 2020-09-18 19:33:51 +05:30
Kovid Goyal
8021686154 Merge branch 'fix-typo' of https://github.com/Luflosi/kitty into master 2020-09-18 17:24:00 +05:30
Luflosi
f55ca296da Fix typo 2020-09-18 13:50:56 +02:00
Kovid Goyal
0d6bca3e5d Allow specifying rules to perform arbitrary actions in kitty when opening URLs 2020-09-18 15:01:25 +05:30
Kovid Goyal
be1ff61e4a Improve some utility functions
Make expandvars accept both $VARNAME and ${VARNAME} now matches
the behavior of posixpath.expandvars

Allow overriding the environment variables to_cmdline expands against
2020-09-18 13:25:59 +05:30
Kovid Goyal
e36d41b46f Add a --hold option to icat
Keeps it alive after display images
2020-09-18 11:48:31 +05:30
Kovid Goyal
b4693dc1b3 Fix some lines in the scrollback buffer not being properly rendered after a window resize/font size change
Fixes #2619
2020-09-18 08:26:50 +05:30
Kovid Goyal
ca6010789e Fix a memory leak when changing font sizes
had forgotten to free unused font groups
2020-09-18 07:40:30 +05:30
Kovid Goyal
f8a80ccf5f Move the wcswidth functions out of screen.c
They have nothing to do with screens
2020-09-17 21:24:52 +05:30
Kovid Goyal
6461dccbdc Make wcswidth ignore more escape codes
Needed to ignore OSC 8 hyperlinks since we will
eventually have to send those with SGR formatting to the hints
kitten.
2020-09-17 20:16:17 +05:30
Kovid Goyal
b06f4f2574 Use the correct type for png_row_bytes() result 2020-09-17 16:54:21 +05:30
Kovid Goyal
7695e3a9c8 Cleanup exit flow control for remote hostname not matching 2020-09-17 16:45:02 +05:30
Kovid Goyal
ae475b408f oops 2020-09-17 16:45:02 +05:30
Kovid Goyal
6d9d048287 Verify hostname before acting on remote file URL
Fixes #2971
2020-09-17 16:45:02 +05:30
Kovid Goyal
09e4d101c5 DRYer 2020-09-17 16:45:02 +05:30
Kovid Goyal
36340caf4c Fix URL marking + scrolling
The ranges have to use on screen line numbers not line->ynum
Fixes #2969
2020-09-17 16:44:10 +05:30
Kovid Goyal
9a80ab0700 More robust 2020-09-17 10:42:30 +05:30
Kovid Goyal
339d972d8d Use INT_MAX rather than self->lines + 10
More likely to never co-incide
2020-09-17 10:41:13 +05:30
Kovid Goyal
6d1e1030bd ... 2020-09-17 10:37:14 +05:30
Kovid Goyal
8a3665ce55 Add links to some modern terminal feature specs 2020-09-17 10:25:37 +05:30
Kovid Goyal
8351f0beab Fix #2970 2020-09-17 09:34:22 +05:30
Kovid Goyal
c26808c59e Fix #2967 2020-09-17 09:30:30 +05:30
Kovid Goyal
50b1dfc746 Fix #2968 2020-09-16 22:30:13 +05:30
Kovid Goyal
2ec8ec2327 Add a note about nested SSH sessions not being supported
Fixes #2971
2020-09-16 08:36:08 +05:30
Kovid Goyal
168480b0ee Docs for the remote file kitten 2020-09-15 18:16:45 +05:30
Kovid Goyal
58f78afc2e Assume localhost is always local
Required by the spec
2020-09-15 16:19:27 +05:30
Kovid Goyal
d60020f5ac Allow copying hyperlink URL to clipboard 2020-09-15 13:23:31 +05:30
Kovid Goyal
437efe5473 Allow using the ask kitten to pick a choice 2020-09-15 12:39:07 +05:30
Kovid Goyal
5737904cec Next release will be 0.19.0 2020-09-15 11:53:34 +05:30
Kovid Goyal
431a8af08b Add changelog entry for hyperlinks support
Fixes #68
2020-09-15 10:35:46 +05:30
Kovid Goyal
be29c4a243 Move class definition to utils so can be used from multiple kittens easily 2020-09-15 10:34:37 +05:30
Kovid Goyal
0a027fad9a Allow asking for confirmation before opening hyperlinks 2020-09-15 10:26:05 +05:30
Kovid Goyal
e21a8e3cc2 Implement save as action for remote file kitten 2020-09-15 09:28:59 +05:30
Kovid Goyal
4279d6514d Fix path completion for ~ paths 2020-09-15 09:22:24 +05:30
Kovid Goyal
457db5994b Fix coloring of links using target 2020-09-15 09:14:44 +05:30
Kovid Goyal
71c942d290 Add colors to the path completer 2020-09-14 22:19:56 +05:30
Kovid Goyal
ee5bc8523b Fix input redisplay when cursor not at end 2020-09-14 20:15:36 +05:30
Kovid Goyal
70f4112643 ... 2020-09-14 20:15:30 +05:30
Kovid Goyal
174f6b7ea8 Start work on a path completion implementation 2020-09-14 19:58:36 +05:30
Kovid Goyal
b14fb6f3c4 Implement editing of remote files 2020-09-12 18:43:04 +05:30
Kovid Goyal
d6e27e776b Start work on the remote_file kitten
Easy access to files over SSH
2020-09-12 06:36:41 +05:30
Kovid Goyal
e6839b45e3 typo 2020-09-10 11:57:41 +05:30
Kovid Goyal
229134cf31 Misc. fixes for issues reported by clang's static analyzer
Most of them are false positives. A couple of mem leaks after unlikely
failure conditions.
2020-09-10 10:47:28 +05:30
Kovid Goyal
b552173185 Start work on special handling for remote file hyperlinks 2020-09-10 10:47:28 +05:30
Kovid Goyal
399a1f8fee Add an option to disable OSC 8 2020-09-10 10:47:28 +05:30
Kovid Goyal
9293d9b0ed Add some tests for hyperlink marking 2020-09-10 10:47:28 +05:30
Kovid Goyal
4a75952fc7 Implement marking of hyperlinks 2020-09-10 10:47:27 +05:30
Kovid Goyal
c19906eb87 Fix read overflow reported by ASAN 2020-09-10 10:47:27 +05:30
Kovid Goyal
00ea189074 Infrastructure to support multiple selection ranges
Needed for hyperlinks, that can be discontinuous
2020-09-10 10:47:27 +05:30
Kovid Goyal
c8e2061e2a Move hyperlink to end of hash table when re-referenced 2020-09-10 10:47:27 +05:30
Kovid Goyal
78dc93721d Add tests for hyperlink storage 2020-09-10 10:47:27 +05:30
Kovid Goyal
33beecddda Implement storage of URLs in a hash map 2020-09-10 10:47:27 +05:30
Kovid Goyal
e99d93ca30 Implement parsing of OSC 8
Also start work on storing hyperlinks with cells
2020-09-10 10:47:24 +05:30
Kovid Goyal
0cc54484a4 Add a note about using the scrollback pager history for large scrollbacks 2020-09-09 12:17:19 +05:30
Kovid Goyal
4df7d59de0 ... 2020-09-09 10:18:56 +05:30
Kovid Goyal
9a54da84dc Add a setting tab_activity_symbol
Fixes #2515
2020-09-08 21:54:56 +05:30
Kovid Goyal
83315f7999 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty into master 2020-09-08 17:45:04 +05:30
Luflosi
eb5ebfd304 GLFW: Fix typo in GLFWwindowmaximizefun documentation
From upstream: 1ed1489831.
2020-09-08 12:57:00 +02:00
Kovid Goyal
77c9124a3d Merge branch 'gwl/fix-move_window_to_top-183' of https://github.com/gregorlarson/kitty into master 2020-09-08 08:38:18 +05:30
Kovid Goyal
317da76ced Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty into master 2020-09-08 07:46:13 +05:30
Luflosi
e8d8ced006 GLFW: Null: Fix out parameters not being set
From upstream: cd0dc76c7c.
2020-09-07 21:26:02 +02:00
Gregor Larson
0321f9bddf tabs.py::move_window_to_top fix 2020-09-07 14:01:56 -04:00
Kovid Goyal
5937892ebc Move focus tracking into the Screen object 2020-09-07 09:31:44 +05:30
Kovid Goyal
e429bea2f4 Move new features to the top of the changelog 2020-09-06 12:44:26 +05:30
Kovid Goyal
d33ad5c616 typo 2020-09-06 12:43:17 +05:30
Kovid Goyal
3e0614a293 Fix a regression that broke kitten_alias
Fixes #2952
2020-09-06 12:15:46 +05:30
Kovid Goyal
80e39212b8 Linux: Fix automatic detection of bold/italic faces for fonts such as IBM Plex Mono and have the regular face with a full name that is the same as the family name
Fixes #2951
2020-09-03 17:14:55 +05:30
Kovid Goyal
d7a6ceb3a6 Add character cell diagonals to box_chars 2020-09-03 13:51:54 +05:30
Kovid Goyal
9d3a9e9d1e Add the half triangle box chars 2020-09-03 11:22:36 +05:30
Kovid Goyal
e95c789d4b Add the block elements to box_chars
Also use a single eight_bar function for all blocks
2020-09-03 10:56:06 +05:30
Kovid Goyal
a508161265 Add smooth mosaic chars to box drawing 2020-09-02 22:00:58 +05:30
Kovid Goyal
a935c80adc Use box drawing for sextants
See the Symbols for Legacy Computing section in the Unicode standard
https://www.unicode.org/charts/PDF/U1FB00.pdf
2020-09-01 19:40:39 +05:30
Kovid Goyal
1d607bf13e Fix #2943 2020-08-30 20:42:01 +05:30
Kovid Goyal
ad57467c93 Avoid exception when generating minimal borders for empty tab in tall/vertical layouts 2020-08-30 20:41:57 +05:30
Kovid Goyal
430eaefc3e If a border width in pts is non-zero have it result in a minimum 1px border
Change the default to 0.5pt instead of 1px
2020-08-30 15:26:37 +05:30
Kovid Goyal
3d60724651 Allow specifying border sizes in either pt or px
Change the default to 1px borders as this works best with the new minimal border style.
2020-08-30 14:17:47 +05:30
Kovid Goyal
31d9f663fc Simplify border drawing code 2020-08-30 14:05:43 +05:30
Kovid Goyal
f324697c7c Implement new minimal border style for tall layout 2020-08-30 13:49:34 +05:30
Kovid Goyal
befae7e677 Make borders code for vertical layout re-usable 2020-08-30 11:32:45 +05:30
Kovid Goyal
7a2c2587ba Use new minimal borders style for vertical layouts 2020-08-30 09:17:14 +05:30
Kovid Goyal
cf3f9d68b3 Use similar border drawing techniques for splits 2020-08-30 08:37:16 +05:30
Kovid Goyal
c99f7c554f Fix unfocused windows in which a bell occurs not changing their border color to red until a relayout 2020-08-29 18:12:17 +05:30
Kovid Goyal
f01c0945da Fix mypy failing 2020-08-29 18:08:32 +05:30
Kovid Goyal
1bcd0c4471 Merge branch 'docs-kitten-example-mouse-buttons' of https://github.com/trygveaa/kitty into master 2020-08-29 18:06:55 +05:30
Trygve Aaberge
07f28e6ec7 Don't use GLFW buttons in custom kitten example
Since send_mouse_event now uses the same numbers as X11 for buttons
instead of the same numbers as GLFW, it is misleading to use the GLFW
constants. I forgot to change this example in commit 8efe08c4.
2020-08-29 13:33:34 +02:00
Kovid Goyal
7074f9f776 Grid layout: Improve rendering of borders when using minimal borders 2020-08-29 15:53:14 +05:30
Kovid Goyal
5029a9ad5a Dont use wheel_scroll_multiplier when sending scroll events in the main screen 2020-08-28 08:14:49 +05:30
Kovid Goyal
0bff30e954 Send wheel events to program when it asks to grab mouse, even in main screen
This matches behavior of other terminals and I dont have a strong
preference either way. Fixes #2939
2020-08-27 21:48:41 +05:30
Kovid Goyal
601d37aa3d Avoid malloc+copy for unknown OSC codes 2020-08-24 20:14:16 +05:30
Kovid Goyal
e2b1ca10c9 Save a line :P 2020-08-24 12:08:09 +05:30
Kovid Goyal
11942ed6dc Fix compilation on OpenBSD
Fixes #2935
2020-08-24 12:05:39 +05:30
Kovid Goyal
f65914599b Remove unreachable code 2020-08-23 10:53:47 +05:30
Kovid Goyal
392c31f5fe Allow specifying watchers in session files and via a command line argument 2020-08-23 10:41:36 +05:30
Kovid Goyal
f4ddaacb3c Allow tracking focus change events in watchers
Fixes #2918
2020-08-23 08:51:04 +05:30
Kovid Goyal
db64aef666 Prevent an infinite recursion if a watcher causes a resize in the on_resize handler 2020-08-23 08:38:25 +05:30
Kovid Goyal
95c8bbd7fb Forgot to increment token 2020-08-22 14:37:51 +05:30
Kovid Goyal
67b4f37d53 ... 2020-08-22 11:38:05 +05:30
Kovid Goyal
427288c16b Add a tmux FAQ
So I can just point to it for all the spurious tmux caused bug reports
2020-08-22 11:36:01 +05:30
Kovid Goyal
4202eee084 Fix launcher on OpenBSD
OpenBSD has apparently refused to move into the 21st century and lacks a
way of determining path to the executable. So we use a kludge, looking
for kitty in PATH and using that. To make it work, simply put a symlink
to kitty somewhere in PATH. Fixes #2675
2020-08-22 09:12:50 +05:30
Kovid Goyal
eca53bfab0 Add a new escape code to allow terminal programs to trigger desktop notifications
Fixes #1474
2020-08-21 20:29:54 +05:30
Kovid Goyal
cd76d109f5 Fix a couple of documentation build warnings 2020-08-21 07:50:35 +05:30
Kovid Goyal
2787f9f19b Drain the notifications queue in FIFO 2020-08-20 14:25:07 +05:30
Kovid Goyal
4e3c6e52aa macOS: Switch to the User Notifications framework
The current notifications framework has been deprecated in Big Sur. The new
framework only allows notifications from signed and notarized applications,
so people using kitty from HomeBrew/source are out of luck. And
notifications can only be displayed once the user grants permission. A
completely brain-dead design. Complain to Apple.
2020-08-20 13:03:00 +05:30
Kovid Goyal
ae5ceedfe9 Allow kitty to build on Big Sur 2020-08-19 20:33:14 +05:30
Kovid Goyal
022e2eb1db Allow updaing on ox with signed/notarized app easily 2020-08-19 20:08:34 +05:30
Kovid Goyal
2fe1ef4774 Mappable function to easily send test notification 2020-08-19 16:45:51 +05:30
Kovid Goyal
70afb2dd4d Fix lib names for OpenSSL 1.1 2020-08-19 12:33:54 +05:30
Kovid Goyal
efa02e3f94 Bump versions of openssl and glib 2020-08-18 21:25:00 +05:30
Kovid Goyal
5eefd41059 Add support for displaying correct colors with PNG files that contain embedded ICC color profiles 2020-08-12 10:34:16 +05:30
Kovid Goyal
6ca1b7c240 Convenience command to upload CI bundles 2020-08-12 10:30:15 +05:30
Kovid Goyal
31191fd48c Log warnings from libpng when debug rendering is on 2020-08-12 06:21:14 +05:30
Kovid Goyal
a6ed54ed48 Image display: Render PNG images with correct colors that have a gamma value different from the sRGB gamma value set in their metadata 2020-08-11 22:52:50 +05:30
Kovid Goyal
95132b4fe1 formatting 2020-08-11 20:19:29 +05:30
Kovid Goyal
df0c5d99e6 Fix #2913 2020-08-11 20:13:50 +05:30
Kovid Goyal
4b0724530e Fix #2912 2020-08-11 14:19:32 +05:30
Kovid Goyal
e5681a93f9 version 0.18.3 2020-08-11 13:38:38 +05:30
Kovid Goyal
fb838a694e ... 2020-08-11 13:08:16 +05:30
Kovid Goyal
8c6f188767 Forgot to use " for key names 2020-08-11 13:01:33 +05:30
Kovid Goyal
55e15dc79e Properly type check os window initial size function
Also use the sizes specified int he session file in preference to those
specified on the command line. Fixes #2909
2020-08-11 09:28:53 +05:30
Kovid Goyal
514073cb75 Fix #2911 2020-08-11 07:52:32 +05:30
Kovid Goyal
f6ece6522e Fix a regression that broke specifying OS window size in the session file
Fixes #2908
2020-08-10 21:55:54 +05:30
Kovid Goyal
817f0997cf Fix one pixel mis-alignment of rounded corners when either the cell dimensions or the thickness of the line is an odd number of pixels
The control points of the Bezier curve and the spread due to thickness
must match up with the values used to draw straight lines. In order to
ensure that, one calculates them before upscaling by the super sampling
factor, rather than after. Fixes #2907
2020-08-10 17:28:08 +05:30
Kovid Goyal
1d651270d3 Merge branch 'weechat-hints-kitten' of https://github.com/GermainZ/kitty into master 2020-08-07 21:55:51 +05:30
GermainZ
6ea58fac1a Add link to weechat-hints kitten 2020-08-07 17:38:38 +02:00
Kovid Goyal
c7eb63d4ff Avoid extra layer update if clearing images has no effect 2020-08-07 09:36:28 +05:30
Kovid Goyal
4062365b19 Revert "Adjust cell height automatically for buggy fonts that draw brackets outside the bounding box"
This reverts commit 5555a66638.
Since it does not fix the issue.
2020-08-06 21:20:54 +05:30
Kovid Goyal
7f48a927de Fix image leaving behind a black rectangle when switching away and back to alternate screen
layer_dirty was being reset if remove_images was called more than once
without an intervening call to update_layers.

Fixes #2901
2020-08-06 19:33:28 +05:30
Kovid Goyal
4a740cc556 Cleanup 2020-08-06 18:14:56 +05:30
Kovid Goyal
628b92f20b Speed up is_ignored_char in the common case 2020-08-06 18:05:33 +05:30
Kovid Goyal
8f9616c230 Speed up wcwidth_std in the common case 2020-08-06 17:57:57 +05:30
Kovid Goyal
df475dfde5 Fix indentation 2020-08-06 17:55:02 +05:30
Kovid Goyal
a835b56a51 Speed up is_combining_char() in the common case 2020-08-06 17:45:40 +05:30
Kovid Goyal
5555a66638 Adjust cell height automatically for buggy fonts that draw brackets outside the bounding box
See https://github.com/cormullion/juliamono/issues/14
2020-08-06 14:06:06 +05:30
Kovid Goyal
dad355b932 oops 2020-08-05 11:06:24 +05:30
Kovid Goyal
90a097d45c Ensure beep works even very soon after startup 2020-08-05 11:04:07 +05:30
Kovid Goyal
dba01bc014 Make ringing bell not dependent on having a OSWindow 2020-08-05 10:58:00 +05:30
Kovid Goyal
1d0a3ce998 Merge branch 'master' of https://github.com/ayang64/kitty into master 2020-08-05 07:46:27 +05:30
Ayan George
076ad850bb Declare _glfwPlatformInitJoysticks() to return bool
This patch declares _glfwPlatformInitJoysticks() to return bool which
matches its prototype in glfw/internal.h.
2020-08-04 20:24:35 -04:00
Kovid Goyal
868546abe4 Fix #2896 2020-08-03 22:14:13 +05:30
Kovid Goyal
6b421fabd1 Wayland: Fix a typo in the previous release that broke reading mouse cursor size
Fixes #2895
2020-08-03 17:08:08 +05:30
Kovid Goyal
ab3c9658bd Add hunter to integrations 2020-08-03 09:05:04 +05:30
Kovid Goyal
8c7886d429 Add a changelog entry for the last PR 2020-08-03 09:00:19 +05:30
Kovid Goyal
110a3e7e0f Merge branch 'master' of https://github.com/jaeheum/kitty into master 2020-08-03 08:58:24 +05:30
Jay Han
ee0b70f51b allow users to choose hint colors 2020-08-02 15:33:17 -07:00
Kovid Goyal
df48061a8f Merge branch 'master' of https://github.com/wengxt/kitty into master 2020-08-01 07:30:09 +05:30
Weng Xuetian
b1387d50f0 Register to bus when connect to ibus.
This is required when the actual dbus is not from ibus but session bus.
This may happen when other run a shim layer for ibus, or ibus is
running with flatpak mode.
2020-07-31 17:54:10 -07:00
Kovid Goyal
73dd218a95 Merge branch 'with-suppress' of https://github.com/Luflosi/kitty into master 2020-07-31 21:36:02 +05:30
Luflosi
ee4cedcc81 Use "with suppress()" to suppress a python exception 2020-07-31 18:00:01 +02:00
Kovid Goyal
d1b2f9c6a9 Dont use SystemExit if kitty exe not found 2020-07-31 20:03:04 +05:30
Kovid Goyal
40dee44978 Merge branch 'kitty-exe-error-message' of https://github.com/Luflosi/kitty into master 2020-07-31 20:02:15 +05:30
Luflosi
db04c70d4a Let kitty_exe() raise an error message if kitty could not be found 2020-07-31 15:46:47 +02:00
Kovid Goyal
7401c6ac97 Merge branch 'dryer' of https://github.com/Luflosi/kitty into master 2020-07-31 16:38:23 +05:30
Luflosi
f7a1222cc3 DRYer 2020-07-30 22:11:41 +02:00
Kovid Goyal
069f09c43c Move wlc destructor to just before the functions are unloaded 2020-07-29 17:18:03 +05:30
Kovid Goyal
35f821f6a1 Ensure wl_cursor_theme_destroy is called before it is released
Fix #2884
2020-07-29 17:13:00 +05:30
Kovid Goyal
67f60847ee Fix the spawn test in the bypy environment
Required the launcher to be built since the pre-built
one was being used. Fixes #2881
2020-07-29 15:11:35 +05:30
Kovid Goyal
65f6b142a5 typo 2020-07-28 15:22:14 +05:30
Kovid Goyal
81bda736d8 Skip multiprocessing spawn monkeypatch test on 32bit 2020-07-28 14:15:31 +05:30
Kovid Goyal
ec3998a9b8 version 0.18.2 2020-07-28 14:01:16 +05:30
Kovid Goyal
01be77e0bc Fix change in window size that does not change number of cells not being reported to the kernel
Fixes #2880
2020-07-25 22:49:39 +05:30
Kovid Goyal
6f40b8d0a1 Simplify Wayland cursor theme handling
Now themes are loaded once per scale and stored centrally not per
window. They are not unloaded till application shutdown. Since there
is unlikely to be more than two or three scales this is not a big waste
of resources. Since cursor lifetime is tied to theme lifetime and cursors
are stored per window, destroying a theme requires destroying all
cursors win all windows referring to that theme, which is too much work.

Should hopefully fix #2810
2020-07-25 15:36:46 +05:30
Kovid Goyal
a083aa04b2 vim also produces CSI > 4;m ignore that as well 2020-07-24 19:19:18 +05:30
Kovid Goyal
1f33348cf6 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-07-24 15:10:35 +05:30
Luflosi
a45651933c GLFW: Cocoa: Support some sim page joystick elements
From upstream: 0d355379e0.
2020-07-24 11:28:53 +02:00
Kovid Goyal
ab57fbff73 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-07-24 14:56:54 +05:30
Luflosi
6b3f774f05 GLFW: Cocoa: Fix potential leak of CFNumber object
From upstream: a2674a9034.
2020-07-24 10:59:04 +02:00
Kovid Goyal
1ef2880c6c Also make the platform window id available via kitty @ ls 2020-07-24 08:47:13 +05:30
Kovid Goyal
ace152d8a3 DRYer 2020-07-24 08:41:55 +05:30
Kovid Goyal
8d08036a9d Update changelog for previous PR 2020-07-24 08:35:01 +05:30
Kovid Goyal
b0876fae64 Merge branch 'cocoa-window-number' of https://github.com/eraserhd/kitty 2020-07-24 08:33:16 +05:30
Kovid Goyal
01633776d3 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-07-24 08:26:18 +05:30
Jason Felice
e4202228eb Update fast_data_types.pyi 2020-07-23 19:09:16 -04:00
Jason Felice
79d5049273 Provide cocoa_window_id() on non-Mac, also
So that its import in tabs.py doesn't have to be conditional.
2020-07-23 18:55:04 -04:00
Jason Felice
9120e3b790 Reorganize window id functions slightly 2020-07-23 18:47:36 -04:00
Jason Felice
974e6140b3 Extract find_os_window() 2020-07-23 18:36:32 -04:00
Jason Felice
1fd338cc6c Set Cocoa window number 2020-07-23 18:36:32 -04:00
Luflosi
bc61a81d7a GLFW: X11: Fix joystick detection before joystick init
From upstream: c01acc267a.
2020-07-23 23:57:03 +02:00
Luflosi
06b30d1cc3 GLFW: Cleanup
From upstream: f771d41292.
2020-07-23 23:56:32 +02:00
Luflosi
785973bb5e GLFW: Make joystick platform code init on demand
From upstream: 782e6b6cef.
2020-07-23 23:56:30 +02:00
Luflosi
78efefcea1 Revert "Linux: Fix slow startup on some systems caused by GLFW searching for joysticks. Since kitty does not use joysticks, disable joystick support."
This reverts commit ab960ea12d.
2020-07-23 23:56:21 +02:00
Kovid Goyal
1bb6242020 macOS: no longer render emoji 20% below the baseline. This causes some emoji to be cut-off and also look misaligned with very high cells
Fixes #2873
2020-07-23 20:38:02 +05:30
Kovid Goyal
1af426bf84 Add support for legacy DECSET codes 47, 1047 and 1048
Fixes #2871
2020-07-22 09:00:51 +05:30
Kovid Goyal
dc4762a69a Dont crash if Wayland returns a cursor image array with some null images 2020-07-21 19:33:05 +05:30
Kovid Goyal
a785b77da9 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-07-19 09:27:44 +05:30
Luflosi
1342767805 GLFW: Wayland: Fix scroll offsets being inverted
From upstream: f760b124ca.

This commit does not actually change any behaviour, it merely makes the code style of the two lines more similar to the new upstream code.
2020-07-18 19:32:03 +02:00
Kovid Goyal
a3fc3233cd Fix pre-edit text not always being cleared with iBus input
Fixes #2862
2020-07-18 19:31:38 +05:30
Kovid Goyal
8093d70643 Allow setting the class for new OS windows in a session file 2020-07-18 12:11:41 +05:30
Kovid Goyal
9d9ec84b54 fix talk mutex typo unlock -> lock 2020-07-18 11:47:22 +05:30
Kovid Goyal
6b26088c27 move wakeup out of locked region 2020-07-18 11:42:57 +05:30
Kovid Goyal
43af715caa free peer message queue at shutdown 2020-07-18 10:50:09 +05:30
Kovid Goyal
c6eea488b1 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-07-18 09:24:01 +05:30
Luflosi
b1c3999a81 GLFW: Wayland: Fix partial framebuffer size retrieval
From upstream: 5f60c22cfa.
2020-07-17 21:10:32 +02:00
Kovid Goyal
4f19403518 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-07-17 19:48:06 +05:30
Luflosi
4d1b537f78 GLFW: Documentation work for GLFW_MOUSE_PASSTHROUGH
From upstream: a122d91303.
2020-07-17 00:08:22 +02:00
Luflosi
dd54db47a9 GLFW: Move mouse passthrough before window showing
From upstream: dfeacee000.
2020-07-17 00:07:36 +02:00
Luflosi
44775e4644 GLFW: Remove no-op call at window creation
From upstream: 1095a43708.
2020-07-16 23:55:24 +02:00
Luflosi
805921d6a3 GLFW: Move management of shared state to shared code
From upstream: 6d2003d07a.
2020-07-16 23:54:16 +02:00
Luflosi
d7cd6edaa5 GLFW: X11: Include X Shape extension headers
From upstream: 68e4261d73.
2020-07-16 23:50:26 +02:00
Luflosi
6a472bd6da GLFW: X11: Fix disabling of GLFW_MOUSE_PASSTHROUGH
From upstream: e81d381256.
2020-07-16 23:24:48 +02:00
Luflosi
d0c6ce9fd7 GLFW: Add support for mouse input transparency
From upstream: d285a9fdeb.
2020-07-16 22:25:12 +02:00
Kovid Goyal
df48e2f9e2 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-07-16 23:43:07 +05:30
Luflosi
2b4b3bbf18 GLFW: Null: Fix typos in workarea retrieval
From upstream: 6c031af245.
2020-07-16 20:01:57 +02:00
Kovid Goyal
6ea5027bf6 Remote control close_tab should not ask for confirmation 2020-07-16 12:55:25 +05:30
Kovid Goyal
384ccb4fc7 Have the :opt:confirm_os_window_close option also apply when closing tabs with multiple windows
Fixes #2857
2020-07-16 12:51:19 +05:30
Kovid Goyal
ff763b099e Merge branch 'patch-1' of https://github.com/tammersaleh/kitty 2020-07-16 08:06:47 +05:30
Kovid Goyal
741ae4c04b Merge branch 'typo' of https://github.com/Luflosi/kitty 2020-07-16 08:06:20 +05:30
Tammer Saleh
d84ec941c0 Fix typo 2020-07-15 17:44:02 -07:00
Luflosi
f0b5dd9799 Fix typo 2020-07-15 19:09:35 +02:00
Kovid Goyal
cec4371b51 Rewrite the talk loop for interaction with peers
The new code is simpler and hopefully more robust. Supports
multiple requests/responses. Fixes #2852
2020-07-15 14:31:45 +05:30
Kovid Goyal
c0ff39c59d Fix extra close for loops with no signal_read_fd 2020-07-14 20:23:45 +05:30
Kovid Goyal
022634f2d9 Log an extra error message 2020-07-14 20:18:38 +05:30
Kovid Goyal
392f576d07 Instrument safe_close() to make it easy to see where an fd is closed from 2020-07-14 20:18:04 +05:30
Kovid Goyal
6d59e2125e Prevent invalid fds from spinning the talk thread forever 2020-07-14 19:09:04 +05:30
Kovid Goyal
6476a1d2e0 When a character from the Unicode Dingbat block is followed by a space, use the extra space to render a larger version of the character
Fixes #2850
2020-07-12 21:12:34 +05:30
Kovid Goyal
ca998fb4b0 Fix incorrect centering when a PUA or symbol glyph is followed by more than one space 2020-07-12 20:16:16 +05:30
Kovid Goyal
48631c4ea6 Add changelog entry for previous merge
Also clean up use of typing.cast
2020-07-12 14:47:14 +05:30
Kovid Goyal
294be2a772 Merge branch 'neighboring_window_changes' of https://github.com/juho-p/kitty 2020-07-12 14:33:21 +05:30
Kovid Goyal
533688a67a Implement support for box drawing rounded-corners characters
Fixes #2240
2020-07-12 12:35:52 +05:30
Kovid Goyal
4309e2371d Simplify code by using supersampling for diagonal lines as well
Wu antialiasing obviously performs better but since characters are
rendered only once and are very small in pixel size, performance is
irrelevant here.
2020-07-12 10:07:55 +05:30
Juho Peltonen
ea30c84240 Fix grid layout neighbors
Grid layout can have multiple neighbors in one side when either current
column or neighboring column is special.
2020-07-11 23:52:37 +03:00
Juho Peltonen
d4c2b13dda Prefer most recently activated window when selecting neighbors
This affects both activating and moving neighbor windows.
2020-07-11 23:52:33 +03:00
Juho Peltonen
1decae2938 Change splits layout neighbors to only include real neighbors 2020-07-11 21:35:29 +03:00
Kovid Goyal
145ec86d3b Forgot to add supersampling to rendering of filled D 2020-07-11 23:10:43 +05:30
Kovid Goyal
e17c96b20f Improve anti-aliasing of triangular box drawing characters, noticeable on low-resolution screens
Fixes #2844
2020-07-11 23:08:28 +05:30
Kovid Goyal
2cfcefd9eb Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-07-11 22:57:53 +05:30
Luflosi
356e950122 X11: Fix cursor hover query retry behavior
From upstream: 49dbcfcb8c.
2020-07-11 18:59:28 +02:00
Kovid Goyal
64dee63b73 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-07-11 22:26:32 +05:30
Luflosi
431d013d32 X11: Fix race in window hovered query
From upstream: ceb20c7f97.
2020-07-11 18:18:33 +02:00
Kovid Goyal
40eb8455d0 Fix `launch --location=last` not working
Fixes #2841
2020-07-09 22:29:24 +05:30
Kovid Goyal
c46b36509b macOS: Fix cmd+plus not increasing font size with keyboards where the + key is a shifted key. Fixes #2839 2020-07-09 22:14:07 +05:30
Kovid Goyal
f7ff63132d Merge branch 'remove-trailing-whitespace' of https://github.com/Luflosi/kitty 2020-07-09 07:42:02 +05:30
Luflosi
e17036a7a5 Remove trailing whitespace 2020-07-09 01:57:39 +02:00
Kovid Goyal
e678c41f56 More code scanning warning fixes 2020-07-07 10:24:57 +05:30
Kovid Goyal
ee3462592a Silence more code scanning warnings 2020-07-07 10:01:38 +05:30
Kovid Goyal
521f921424 Fix a bunch of code scanning warnings 2020-07-07 09:52:59 +05:30
Kovid Goyal
ee47a10b37 Simplify code a bit 2020-07-07 09:44:51 +05:30
Kovid Goyal
b81700144d Silence another code scanning warning 2020-07-07 09:38:33 +05:30
Kovid Goyal
9f28dd61d3 Silence a spurious code scanning warning
I hope it silences it anyway
2020-07-07 09:31:00 +05:30
Kovid Goyal
dad7d366b3 Fix out of bounds write on platforms where sizeof(bool) != 1
Found by code scanning
2020-07-07 09:25:14 +05:30
Kovid Goyal
209b78a3ec Silence a code scanning warning 2020-07-07 09:20:59 +05:30
Kovid Goyal
17f34d1f95 Use the more secure localtime_r variant
Pointed out by code scanning
2020-07-07 09:20:27 +05:30
Kovid Goyal
26699cd9ef Fix incorrect format specifier to printf
Detected by code scanning
2020-07-07 09:14:33 +05:30
Kovid Goyal
907db09a58 Only use pythonLocation if it is available 2020-07-07 08:57:50 +05:30
Kovid Goyal
d506fa0565 Use python3 in code analysis build step 2020-07-07 08:41:20 +05:30
Kovid Goyal
de1a0d48a6 Use ci script to build kitty for code scanning 2020-07-07 08:35:04 +05:30
Kovid Goyal
a20e5fefd3 ... 2020-07-07 08:27:10 +05:30
Kovid Goyal
44558560f9 Dont use autobuild for code scanning 2020-07-07 08:24:37 +05:30
Kovid Goyal
677f154f03 Create codeql-analysis.yml
Enable GitHub code scanning for vulnerabilities
2020-07-07 08:21:14 +05:30
Kovid Goyal
0adaf064e7 Fix #2832 2020-07-05 07:34:11 +05:30
Kovid Goyal
3c828feef2 Merge branch 'environmenterror-to-oserror' of https://github.com/Luflosi/kitty 2020-07-02 08:29:27 +05:30
Kovid Goyal
4d3c5e61fd Update changelog 2020-07-02 08:26:37 +05:30
Kovid Goyal
67baefb52a Merge branch 'hints-linenum-expand-home' of https://github.com/trygveaa/kitty 2020-07-02 08:23:59 +05:30
Trygve Aaberge
d509a4fa8c Expand ~ in the path argument for linenum in hints
Fixes #2822
2020-07-02 01:01:14 +02:00
Luflosi
cad1c12b7b Replace EnvironmentError with OSError
See 527ff0238a.
2020-07-01 22:39:01 +02:00
Kovid Goyal
9f751d8715 Add kitti3 to integrations.rst 2020-06-30 08:15:16 +05:30
Kovid Goyal
cf8a1dff33 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-06-30 08:13:27 +05:30
Luflosi
973d98457f EGL: Add support for EGL_ANGLE_platform_angle
From upstream: 0dea8a4441.
2020-06-30 00:34:32 +02:00
Kovid Goyal
ce262f810d Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-06-29 19:13:34 +05:30
Luflosi
bd31c2b484 Add GLFW_CONTEXT_DEBUG window hint alias
From upstream: b420ca7404.
2020-06-29 15:30:38 +02:00
Kovid Goyal
ef0e610802 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-06-29 18:45:19 +05:30
Luflosi
3040d4c83f Re-word docs for GLFW_OPENGL_DEBUG_CONTEXT attrib
From upstream: 4e3b43383a.
2020-06-29 11:43:24 +02:00
Kovid Goyal
c9252e8639 When erasing in display upto cursor, the line containing the cursor should be marked as not continued.
Also add some tests for the action of ED on continued flags
2020-06-29 14:29:03 +05:30
Kovid Goyal
e2e701460b Fix the CSI J (Erase in display ED) escape code not removing line continued markers
Fixes #2809

Remains to write tests for this.
2020-06-29 14:17:40 +05:30
Kovid Goyal
f0c3641ebd Some more commands for replay commands 2020-06-29 13:04:10 +05:30
Kovid Goyal
025f6d7701 Add keypad mode support to replay commands
Also name the constants correctly
2020-06-29 12:46:34 +05:30
Kovid Goyal
c68516ca8d Wayland: Fix a crash when using animated mouse cursors
Fixes #2810
2020-06-29 08:03:25 +05:30
Kovid Goyal
a9e739e08d Apply single instance BO override when different from current BO not when less than 1 2020-06-27 17:32:03 +05:30
Kovid Goyal
cc15ff73b7 Respect --override of background_opacity for --single-instance
Fixes #2806
2020-06-27 09:18:41 +05:30
Kovid Goyal
fd3a4536e7 Fix imperative close request being ignored in absence of any other activity 2020-06-26 16:37:17 +05:30
Kovid Goyal
75caafb5ac Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-06-26 16:34:33 +05:30
Kovid Goyal
cf2f8165eb Only ask application to abort once 2020-06-26 16:33:25 +05:30
Luflosi
a2f80740d7 Remove EGL and OSMesa struct member macros
From upstream: bcb8558189.
2020-06-26 12:51:11 +02:00
Kovid Goyal
c7703791d1 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-06-26 16:19:04 +05:30
Luflosi
c39e9e9c61 EGL: Add support for EGL_EXT_platform_base
From upstream: aec9fae8f3.
2020-06-26 12:39:17 +02:00
Kovid Goyal
713059319c Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-06-26 15:59:34 +05:30
Luflosi
d7a7509da6 EGL: Replace native handle macros with functions
From upstream: d7f7b0e1b5.
2020-06-26 12:17:13 +02:00
Kovid Goyal
57e6e7b2c5 Use ctrl+[] for changing tabs in unicode input as ctrl+tab is taken on macOS
ctrl+tab remains in addition for backwards compat
2020-06-26 12:29:42 +05:30
Kovid Goyal
d675977f10 Better error message for xterm specific key resource CSI codes that vim has started emitting 2020-06-25 23:07:34 +05:30
Kovid Goyal
7ef911e17d Fix #2798 2020-06-25 21:43:54 +05:30
Kovid Goyal
9a384c5045 Allow passing the current selection to kittens
Fixes #2796
2020-06-25 08:46:05 +05:30
Kovid Goyal
2b3753d99c Prevent super large tab margin widths from causing a crash
Fixes #2793
2020-06-24 22:56:54 +05:30
Kovid Goyal
d173ab9f45 macOS: Fix the LC_TYPE env var being set to UTF-8 on systems in which the language and country code do not form a valid locale
Fixes #1233
2020-06-24 22:09:25 +05:30
Kovid Goyal
fbd0e8e26a X11: Improve handling of multiple keyboards
Now pressing a modifier key in one keyboard and a normal key in another works. Fixes #2362

Don't rebuild keymaps on new keyboard events that only change geometry. Fixes #2787

Better handling of multiple keyboards with incompatible layouts (this is for free from the above fixes). Fixes #2726
2020-06-24 12:05:30 +05:30
Kovid Goyal
50414b333a Re-enable the spawn tesRe-enable the spawn test 2020-06-23 20:43:40 +05:30
Kovid Goyal
ee2fdb3d25 Merge branch 'typos' of https://github.com/Luflosi/kitty 2020-06-23 20:16:42 +05:30
Luflosi
2b884377d4 Fix typos 2020-06-23 16:35:13 +02:00
Kovid Goyal
36a20f7b00 Temporarily disable spawn test as it is failing in the Linux build container
Will investigate later
2020-06-23 17:37:04 +05:30
Kovid Goyal
35cbf49b08 version 0.18.1 2020-06-23 17:29:22 +05:30
Kovid Goyal
21836cedda Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-06-21 22:07:44 +05:30
Luflosi
0a892b72e6 Fix GLU header inclusion being disabled
From upstream: 81f475bccb.
2020-06-21 18:07:31 +02:00
Kovid Goyal
2c6e5a6e73 Get multiprocessing working in kitty
Monkeypatch the stdlib multiprocessing module to
use kitty as its python interpreter for spawning worker
processes.
2020-06-21 14:47:24 +05:30
Kovid Goyal
2cb25cf5a8 Build the launcher when freezing on macOS as well
Can be used by the test suite
2020-06-21 14:37:36 +05:30
Kovid Goyal
e07916425e macOS: Fix for diff kitten not working with python 3.8
Fixes #2780
2020-06-20 19:03:45 +05:30
Kovid Goyal
f62e2374e4 Ensure mimetype is sent to github 2020-06-20 13:02:34 +05:30
Kovid Goyal
eb4ee2f0af version 0.18.0 2020-06-20 12:48:59 +05:30
Kovid Goyal
be3c76da20 Fix remote control command docs order randomized 2020-06-20 12:45:05 +05:30
Kovid Goyal
b15e58621c Fix the kitty shell launched via a mapping needlessly requiring :opt:allow_remote_control to be turned on. 2020-06-20 12:43:46 +05:30
Kovid Goyal
601a6c9e3d Allow sending arbitrary signals to the current foreground process in a window using either a mapping in kitty.conf or via remote control
Fixes #2778
2020-06-20 12:37:27 +05:30
Kovid Goyal
3ff184348e Merge branch 'unused-macro' of https://github.com/Luflosi/kitty 2020-06-19 18:33:28 +05:30
Luflosi
c8efcd2be1 Remove unused macro 2020-06-19 14:31:58 +02:00
Kovid Goyal
9c116a2975 Fix #2776 2020-06-19 12:13:32 +05:30
Kovid Goyal
8818b5d8df Set CFBundleAllowMixedLocalizations in the app bundle to have NSLocale.currentLocale return the correct locale on non-English systems 2020-06-18 20:16:36 +05:30
Kovid Goyal
e96dfadae7 Ensure cocoa_get_lang() returns a valid locale or None
See #1233
2020-06-18 20:15:01 +05:30
Kovid Goyal
deb564e5a6 Even more integrations 2020-06-17 18:09:34 +05:30
Kovid Goyal
ffc71c348c A couple more integrations with external tools 2020-06-17 18:07:19 +05:30
Kovid Goyal
19df7b94ea Clarify documentation a bit 2020-06-16 09:53:08 +05:30
Kovid Goyal
a3ecc79f0d Dont actually need -- since kitty's option processing code is smart enough to stop looking for options after the first non-optional argument 2020-06-16 09:31:42 +05:30
Kovid Goyal
b140b15119 Add a -- to linenum hints examples 2020-06-16 08:30:34 +05:30
Kovid Goyal
b7b2b6075a Add mdcat 2020-06-15 09:31:51 +05:30
Kovid Goyal
7525e152b8 Make comment a bit better 2020-06-15 06:55:52 +05:30
Kovid Goyal
bc9dfec615 Fix #2764 2020-06-15 06:53:35 +05:30
Kovid Goyal
7824739034 Ensure selection GPU buffer is refreshed after a resize
Fixes #2747 (I hope since I cannot reproduce)
2020-06-13 22:59:46 +05:30
Kovid Goyal
e7b60a3628 Fix #2763 2020-06-13 20:09:26 +05:30
Kovid Goyal
97c3061b8f Allow having no tab separator
Fixes #2761
2020-06-13 12:33:15 +05:30
Kovid Goyal
1a042c873c Add a link to vim-test 2020-06-11 08:02:17 +05:30
Kovid Goyal
064aa3a150 Wayland: Ensure cursor theme is loaded before trying to set cursor 2020-06-11 07:57:08 +05:30
Kovid Goyal
8a178ebe55 Wayland: Apply the same framebuffer selection optimisation
Not as much of a win, since EGL only causes approx 1K getpid() calls of
which this optimization eliminates only half
2020-06-09 21:59:25 +05:30
Kovid Goyal
9a97f0bced X11: Further reduce startup time
Use the GLX 1.3 API function to choose the best framebuffer config
instead of doing it ourselves. Reduces the number fo getpid() calls by
a further ~15K
2020-06-09 20:18:07 +05:30
Kovid Goyal
5c7471910d Fix #2752 2020-06-09 09:51:15 +05:30
Kovid Goyal
27b6517594 X11: Reduce startup time by ~25% by only querying GLX for framebuffer configurations once
On my system reduces the number of getpid() calls from 67982 to 17327
I dont know why get framebuffer config attributes requires getpid() and
why it is so slow, probably a driver bug. Fixes #2754
2020-06-09 01:04:09 +05:30
Kovid Goyal
cd4dacb406 Fix #2753 2020-06-08 21:40:59 +05:30
Kovid Goyal
5f6faa1bf0 Make a central list of integrations in the docs
Fixes #2750
2020-06-08 14:49:59 +05:30
Kovid Goyal
cfc5a952f8 Add --no-response to @ last-used-layout 2020-06-08 09:16:26 +05:30
Kovid Goyal
10b186957b Update link to termpdf.py 2020-06-08 08:57:50 +05:30
Kovid Goyal
f597481736 Update changelog for last merge 2020-06-06 22:32:52 +05:30
Kovid Goyal
9fa97e6187 Merge branch 'mouse-events' of https://github.com/trygveaa/kitty 2020-06-06 22:27:54 +05:30
Kovid Goyal
3844321f20 Use a multiple of 8 size for mouse_button_pressed 2020-06-06 22:24:01 +05:30
Trygve Aaberge
8efe08c45b Support more mouse buttons for terminal mouse events
Previously, the mouse back and forward buttons sent the same codes as
scroll up and down. Now they instead send the same codes as xterm. Mouse
button 10 (in X11 numbering) also now sends the same as xterm, instead
of not sending anything.

This also changes the `send_mouse_event` function which can be called
from kittens to use X11 numbering for mouse buttons instead of what it
previously used, which turns out to be a hybrid of X11 and GLFW. It was
documented to use GLFW numbering, but GLFW doesn't have numbers for
scroll events (that's separate events with x/y offsets) and 4 and 5 in
GLFW is actually back and forward, while `send_mouse_event` interpreted
it as scroll up and down.

That means that this is a breaking change for `send_mouse_event` because
it swaps the number for the middle and right button to be consistent
with X11. I did this because I think it's better to use one consistent
numbering scheme for the function, and because people probably know X11
numbering better than GLFW numbering and GLFW doesn't have numbers for
the scroll buttons.
2020-06-06 14:19:06 +02:00
Trygve Aaberge
c78563b452 Report modifier key state when sending move and drag events to the terminal program 2020-06-06 12:28:42 +02:00
Trygve Aaberge
122e172092 Track modifier state correctly
When a modifier key is pressed, that modifier is not included in mods.
When it is released, it is included. Therefore, we have to special case
the modifier keys when storing the modifiers that are active. When a
modifier key is pressed, we add the modifier to
mods_at_last_key_or_button_event, and when it is released, we remove it.

This fixes an issue where move and drag events would still be sent to
the terminal program after pressing shift, but would stop being sent
after releasing shift until another key or button was pressed.
2020-06-06 12:28:42 +02:00
Kovid Goyal
8f85c0d167 Use bypy in update-on-ubuntu 2020-06-06 09:23:36 +05:30
Kovid Goyal
ac6d1ce174 Use bypy in the publish script 2020-06-06 09:19:48 +05:30
Kovid Goyal
03e0bf4c0e Migrate update-on-ox to use bypy 2020-06-06 09:11:50 +05:30
Kovid Goyal
1cb183f5e1 Add a note about what sort of ligatures disable_ligatures affects 2020-06-06 09:11:32 +05:30
Kovid Goyal
d78a553910 Fix #2739 2020-06-06 07:50:43 +05:30
Kovid Goyal
1326532850 macOS: Notarize the kitty application
This required the kitty package to be moved from Frameworks to
Resources, because Apple cant codesign .pyc files and its notarization
requires everything in Frameworks to be signed. Hopefully that does not
break anything. Also removed the kitty-deref-symlink since it is not
needed anyway and was only present for backwards compatibility.

Fixes #2040
2020-06-05 22:52:30 +05:30
Kovid Goyal
408508247d Merge branch 'replace_glfw_true' of https://github.com/Luflosi/kitty 2020-06-05 22:32:53 +05:30
Luflosi
e2be09e028 Remove GLFW_TRUE in comment
In 55ad228166 I forgot to replace `GLFW_TRUE` with `true` in a comment.
2020-06-05 18:51:50 +02:00
Kovid Goyal
c7c14f184c X11: Recompile keymaps on XkbNewKeyboardNotify events
Hopefully fixes #2726
2020-06-05 22:11:15 +05:30
Kovid Goyal
24ca919f33 Merge branch 'fake_scroll_correct_window' of https://github.com/Luflosi/kitty 2020-06-05 20:20:40 +05:30
Luflosi
85fe783652 Fix fake scroll when scrolling in unfocused kitty window
Scrolling should happen in the kitty window under the mouse cursor, not in the currently active kitty window.
2020-06-05 16:44:11 +02:00
Kovid Goyal
04b6bf3b74 bypy builds on macOS 2020-06-05 19:38:00 +05:30
Kovid Goyal
8b2fb105d0 Fix #2735 2020-06-05 19:24:40 +05:30
Kovid Goyal
558caa232d Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-06-05 07:10:39 +05:30
Luflosi
d8886edbeb Null: Make platform more conformant
From upstream: e0c77f71f9.
2020-06-05 00:27:47 +02:00
Kovid Goyal
f72ecf1791 Start work on building macOS binary with bypy 2020-06-04 23:18:48 +05:30
Kovid Goyal
45d1b978d8 bypy now builds the Linux binary 2020-06-04 19:54:01 +05:30
Kovid Goyal
0b780cc065 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-06-04 19:24:40 +05:30
Luflosi
5263f6598c Add feature available/implemented errors
From upstream: 9a87c2a4b4.
2020-06-04 13:55:52 +02:00
Kovid Goyal
f9e60e7ef6 Start work on using bypy to build the binaries 2020-06-04 13:51:50 +05:30
Kovid Goyal
45c00d0b1f Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-06-04 07:15:09 +05:30
Luflosi
c70e2f7d3e Add statement to docs for glfwTerminate
From upstream: 7486e12f88.
2020-06-03 20:07:09 +02:00
Kovid Goyal
1ec0bed1ce Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-06-03 22:45:24 +05:30
Luflosi
46b5e4513a Win32: Fix VS /W4 compile warnings
From upstream: a84a30ab63.
2020-06-03 19:05:05 +02:00
Kovid Goyal
ffb5196f3b Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-06-03 22:04:21 +05:30
Luflosi
107f1af3c4 Fix desktop GL header not always being suppressed
From upstream: 105cf32e0b.
2020-06-03 11:32:59 +02:00
Kovid Goyal
03b1484c96 Wayland: Abort on fatal error should bypass quit confirmation 2020-06-03 14:39:27 +05:30
Kovid Goyal
aaf64ad63e Add links to config settings to change mouse modifiers in the main mouse docs 2020-06-03 08:17:28 +05:30
Kovid Goyal
f548e795d5 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-06-02 17:05:02 +05:30
Luflosi
767da68239 Reduce difference to GLFW upstream
Only whitespace, formatting and comments were changed. This does not alter any functionality.
2020-06-02 11:45:08 +02:00
Kovid Goyal
f44e0ff4bd Merge branch 'patch-1' of https://github.com/TheDaemoness/kitty 2020-06-02 10:54:44 +05:30
TheDaemoness
7f226f2ea1 Avoid incrementing hidden cursors' images 2020-06-02 05:10:51 +00:00
Kovid Goyal
1c82a39a6e Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-06-02 08:13:33 +05:30
Kovid Goyal
b70cf276b4 Change the cursor image immediately on scale change 2020-06-02 08:09:27 +05:30
Kovid Goyal
80b2df2ef4 Better code when using a stack cursor 2020-06-02 07:59:32 +05:30
Kovid Goyal
ad27452275 Wayland: Avoid infinite timer fires if arrow cursor is animated 2020-06-02 07:53:15 +05:30
Kovid Goyal
196a0b6b7e Merge branch 'patch-1' of https://github.com/TheDaemoness/kitty 2020-06-02 07:49:57 +05:30
Luflosi
f356f63994 wayland: save serial from all input sources
From upstream: 92b3fd02e5.
2020-06-01 21:29:14 +02:00
TheDaemoness
4947fb6b57 Fix a missing cursorWayland-scale assignment. 2020-06-01 17:41:16 +00:00
Kovid Goyal
622f12b84e Add a changelog entry for wayland hidpi cursors 2020-06-01 21:26:18 +05:30
Kovid Goyal
c1f84ce603 cleanup for wayland hidpi cursors merge 2020-06-01 21:14:56 +05:30
Kovid Goyal
14912461ad Use left_ptr as default arrow cursor on Wayland
Matches X11.
2020-06-01 20:33:54 +05:30
Kovid Goyal
a9f265e8b7 Initialize a couple of local vars 2020-06-01 20:33:54 +05:30
TheDaemoness
199ee20adb Fixed an instance of eager cursor loading.
Also fixed a minor formatting issue.
2020-06-01 20:33:53 +05:30
TheDaemoness
7c3c87abf6 Initial implementation of proper HiDPI cursor support on Wayland. 2020-06-01 20:33:53 +05:30
Kovid Goyal
b0ad44bcf2 Fix #2714 2020-06-01 20:31:05 +05:30
Kovid Goyal
9ba808ec3c Merge branch 'ft/csi-code-rep' of https://github.com/keynslug/kitty 2020-06-01 14:31:34 +05:30
Kovid Goyal
eacf849e3a Add bounds check to left_shift_line()
Fixes #2710
2020-05-31 08:10:58 +05:30
Andrew Mayorov
42c2791182 Do not cap repetitions by row length
Instead cap by 65535 as a safeguard. This is more in line with ECMA 48.
2020-05-29 20:36:30 +03:00
Andrew Mayorov
390e883ecf Update terminfo with CSI REP support 2020-05-29 01:06:16 +03:00
Andrew Mayorov
9fe631ee3f Provide support for CSI REP control code 2020-05-29 01:05:49 +03:00
Kovid Goyal
82d8c4b230 Fix #2699 2020-05-27 20:18:05 +05:30
Kovid Goyal
9775bb0a9d Merge branch 'patch-1' of https://github.com/aslpavel/kitty 2020-05-27 09:05:09 +05:30
Pavel
139c9a2d6d Fix incorrect examples in graphic protocol
Examples in `Deleting images` section were incorrect.
2020-05-26 20:39:31 +01:00
Kovid Goyal
542880f87b Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-05-25 22:17:42 +05:30
Luflosi
3846286bee Wayland: Implement raw mouse motion control
From upstream: 44af6bb936.
2020-05-25 18:21:32 +02:00
Kovid Goyal
72be402a2d Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-05-25 21:47:56 +05:30
Luflosi
c6b9cb759a Wayland: Rename handlers for more unicity
From upstream: 754b7feaa1.

1fa66ca45d didn't include the changes to `wl_window.c`.
2020-05-25 15:29:17 +02:00
Kovid Goyal
13ccf269a6 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-05-25 15:25:01 +05:30
Luflosi
fcc7a0255a Align joystick axis to gamepad button behavior
From upstream: 02874d9c14.
2020-05-25 11:44:14 +02:00
Luflosi
e7447f38cf Fix half-axis to gamepad button value mapping
From upstream: c32dc3a085.
2020-05-25 11:44:02 +02:00
Kovid Goyal
7ae35631a6 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-05-25 10:32:54 +05:30
Luflosi
55ad228166 Rename raw input to raw mouse motion, cleanup
From upstream: 1155c83013.
2020-05-24 21:57:29 +02:00
Luflosi
48fb051253 Add GLFW_RAW_INPUT and glfwRawInputSupported
From upstream: 9e29f556fd.
2020-05-24 20:49:52 +02:00
Kovid Goyal
f97e8b7eeb The title for @ set-window-title is optional 2020-05-24 21:51:33 +05:30
Kovid Goyal
84f914742b Fix command names using undersore instead of hyphens in completion for the shell 2020-05-24 21:34:34 +05:30
Kovid Goyal
0d704f3715 kitty shell: show the previously active window id 2020-05-24 16:40:10 +05:30
Kovid Goyal
d8896eb210 Fix #2688 2020-05-24 12:40:54 +05:30
Kovid Goyal
b9d74e2012 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-05-24 08:16:51 +05:30
Luflosi
803fba9cfd Cocoa: Replace display link with IOKit query
From upstream: 4ec7daf3e9.
2020-05-23 16:28:31 +02:00
Kovid Goyal
581548ed67 Merge branch 'freebsd' of https://github.com/rkitover/kitty 2020-05-23 19:56:51 +05:30
Kovid Goyal
9a8c0f8e7e Merge branch 'cut_utf-8' of https://github.com/Luflosi/kitty 2020-05-23 19:53:40 +05:30
Rafael Kitover
328f569c16 Fix child spawn on FreeBSD.
Fix typo: "#ifdef TIOCSTTY" -> "#ifdef TIOCSCTTY"

Include standard header sys/ioctl.h for ioctl(), needed on MacOS.

Include standard header termios.h for TIOCSCTTY.

Fixes this error on spawn of child shell process:

bash: cannot set terminal process group (-1): Inappropriate ioctl for
device
bash: no job control in this shell

Tested on FreeBSD and Linux.

- Fix #2529

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2020-05-23 12:21:57 +00:00
Luflosi
7931654a7c Ensure valid UTF-8 when cutting string 2020-05-23 13:59:23 +02:00
Kovid Goyal
6eb0c10339 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-05-23 17:24:03 +05:30
Luflosi
269f294d19 Use CALayer instead of NSView for EGLNativeWindowType
From upstream: 91eebe922d.
2020-05-23 12:48:26 +02:00
Kovid Goyal
d19e2f1350 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-05-23 16:17:30 +05:30
Luflosi
3b745b82db X11: Clarify function name and comment
From upstream: 5f9dfe3d83.
2020-05-23 11:34:17 +02:00
Kovid Goyal
02f30c2a03 Merge branch 'master' of https://github.com/ahlinc/kitty 2020-05-23 10:47:26 +05:30
Andrew Hlynskyi
54002b386a Fixed issue with a cwd for kitty_mod+h scroll buffer viewer
There is an issue with ability to save scroll buffer from a default less
scroll buffer viewer by just typing relative path to an output file,
because the running less instance inherits cwd from Kitty's cwd
instead of cwd of active window.

How to reproduce:
  1. Start Kitty.
  2. Go to some place.
  3. Press 'kitty_mod+h'
  4. Press 's' and you'll see a less prompt like 'log file:'
  5. Type a just file name without any path and press Enter then press 'q'
  6. See that there is no such file in a current shell directory.
2020-05-23 07:19:45 +03:00
Kovid Goyal
0e2ff077af Fix #2682 2020-05-23 09:03:44 +05:30
Kovid Goyal
012cf70321 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-05-23 07:22:07 +05:30
Luflosi
9da0ba52db X11: Clarify code flow for Clang static analysis
From upstream: ef5220d6b1.
2020-05-22 23:32:12 +02:00
Kovid Goyal
7bfb07e59e Merge branch 'simplify' of https://github.com/Luflosi/kitty 2020-05-22 19:58:48 +05:30
Luflosi
9cb2c4b1ff Simplify code
There is already a check if `m` is `NULL`, so there is no need for a second `NULL` check after that.
2020-05-22 16:04:28 +02:00
Kovid Goyal
8c088fad0f Merge branch 'master' of https://github.com/ahlinc/kitty 2020-05-22 08:23:55 +05:30
Andrew Hlynskyi
392722aed0 Fixed misprint in .github/ISSUE_TEMPLATE/bug_report.md 2020-05-21 22:24:04 +03:00
Kovid Goyal
fabfb30fc4 Merge branch 'convert-tabs-to-spaces' of https://github.com/Luflosi/kitty 2020-05-21 19:51:02 +05:30
Luflosi
c7cb021e92 Convert two tabs to spaces
The rest of the file is also indented with spaces.
2020-05-21 15:34:08 +02:00
Kovid Goyal
be05d9c3e9 Proper confirm_os_window_close check condition 2020-05-21 15:12:20 +05:30
Kovid Goyal
e38690e8d9 Dont link against librt and libdl on OpenBSD
These are part of libc there
2020-05-21 11:43:55 +05:30
Kovid Goyal
7172115559 Merge branch 'patch-1' of https://github.com/TheDaemoness/kitty 2020-05-21 07:37:56 +05:30
TheDaemoness
7314019832 Fixed a typo and added some missing files. 2020-05-20 20:10:37 +00:00
TheDaemoness
b9684941c4 Create .editorconfig
[Most major editors](https://editorconfig.org/#download) support EditorConfig for declaring per-file per-project indentation rules. It costs almost nothing to maintain, and it makes it easier to follow the coding styles already used in kitty.
2020-05-20 19:46:13 +00:00
Kovid Goyal
a27289352c Merge branch 'master' of https://github.com/ahlinc/kitty 2020-05-20 19:56:58 +05:30
Andrew Hlynskyi
dc77009e55 Fixed confirm_os_window_close bug introduced in commit 7bf83603c8 2020-05-20 15:29:21 +03:00
Kovid Goyal
d12e10830d Wayland: Fix kitty being killed on some Wayland compositors if a hidden window has a lot of output
Sway falls over and dies if it receives many render frame
requests. So send only a single one per damaged window and hope and pray
that the compositor hasn't dropped it. Shrug, Wayland, no surprise.
Fixes #2329
2020-05-20 14:19:09 +05:30
Kovid Goyal
936f6c22f0 Merge branch 'configure_library_paths' of https://github.com/Luflosi/kitty 2020-05-20 07:17:07 +05:30
Kovid Goyal
9712be903d Fix #2667 2020-05-20 07:05:35 +05:30
Luflosi
7441cefdbb Make paths to libraries configurable at build time 2020-05-19 18:36:46 +02:00
Kovid Goyal
7bf83603c8 Forgot to treat confirm_os_window_close as a count 2020-05-19 08:19:17 +05:30
Kovid Goyal
6768bc1705 Fix SIGTERM/SIGINT on macOS causing kitty to enter an infinite loop 2020-05-18 17:53:35 +05:30
Kovid Goyal
707cb37212 Have the confirm on close also apply to quitting kitty
Use a dedicated API for handling quit requests on macOS rather than a
quit canary. Also create a mappable "quit" action for all platforms.
2020-05-18 16:06:40 +05:30
Kovid Goyal
1cf0a8b78e Allow only a single OS window close confirmation per OS window 2020-05-18 13:56:19 +05:30
Kovid Goyal
3d2cb37af0 Linux: Workaround for broken Nvidia drivers for old cards
Fixes #456
2020-05-18 13:41:23 +05:30
Kovid Goyal
09fbd6f5e0 Merge branch 'master' of https://github.com/ahlinc/kitty 2020-05-18 09:59:31 +05:30
Andrew Hlynskyi
474bef65cb Fixed marks grouping and coloring for simultaneous multi marks definition 2020-05-18 06:53:56 +03:00
Kovid Goyal
e97454c4a5 And ever more coalesce tests 2020-05-17 23:20:26 +05:30
Kovid Goyal
936dc74a27 Some more coalesce tests 2020-05-17 23:08:27 +05:30
Kovid Goyal
362e4266bb Better coalescing of multiple symbol_maps
When specifying multiple symbol_map values in kitty.conf later ones
should override conflicting previous ones. Fixes #2662
2020-05-17 23:03:28 +05:30
Kovid Goyal
d08f2e10f1 Add bug label to bug bug report template 2020-05-17 13:12:35 +05:30
Kovid Goyal
f1e5ee74a6 Add a feature request template 2020-05-17 13:11:23 +05:30
Kovid Goyal
7832d33348 Add a bug report template 2020-05-17 13:07:49 +05:30
Kovid Goyal
de25f94fae When extending selections to words, recognize ://
As part of the word even if : is not in select_word_chars. This allows
double-clicking to select common URLs with the default select_word_chars
2020-05-16 13:49:39 +05:30
Kovid Goyal
98625e9c36 Add an option confirm_on_os_window_close to ask for confirmation when closing an OS window with multiple kitty windows. 2020-05-15 13:39:58 +05:30
Kovid Goyal
5768cc98b6 ... 2020-05-15 13:31:35 +05:30
Kovid Goyal
da1cc6c1c5 Add a yes/no mode to the ask kitten 2020-05-15 13:16:14 +05:30
Kovid Goyal
50384fac97 DRYer 2020-05-14 09:18:29 +05:30
Kovid Goyal
424bd8a6cd Only compile tab template once 2020-05-14 09:15:11 +05:30
Kovid Goyal
421fae2b57 Merge branch 'fix/tab-title-template-f-string' of https://github.com/chriszarate/kitty 2020-05-14 09:09:18 +05:30
chriszarate
8bb8615a5a Compile template and restrict globals for eval 2020-05-13 23:30:12 -04:00
Kovid Goyal
80f8692e92 Tall/fat layout: Fix resizing of windows when number of windows is <= num of full size windows not working 2020-05-13 23:33:23 +05:30
Kovid Goyal
25623c758d Tall and Fat layouts: Add a `mirrored` option to put the full size window on the opposite edge of the screen
Fixes #2654
2020-05-13 23:19:34 +05:30
Kovid Goyal
e1a0a195a9 Forgot to change one call site for switch_focus_to 2020-05-13 21:39:26 +05:30
Kovid Goyal
f8cf49a90c Merge branch 'simplify' of https://github.com/Luflosi/kitty 2020-05-13 17:22:39 +05:30
Luflosi
ac9f8595c9 DRYer
Don't write `cppflags.extend()` twice.
2020-05-13 13:43:43 +02:00
Kovid Goyal
97f22bbff6 Update changelog 2020-05-13 11:01:04 +05:30
chriszarate
d6ddfa9d18 Use f-string instead of format for tab_title templates 2020-05-12 22:29:03 -04:00
Kovid Goyal
5e48ae8bac pep8 2020-05-12 22:54:08 +05:30
Kovid Goyal
cdd943ded4 Port layout tests to new API 2020-05-12 22:43:55 +05:30
Kovid Goyal
39b2bf963c Port the splits layout to the new groups API 2020-05-12 22:43:54 +05:30
Kovid Goyal
06827fd437 Update docs to point to new layouts package 2020-05-12 22:43:54 +05:30
Kovid Goyal
70ccc1cf6d Port Grid layout to new groups API 2020-05-12 22:43:54 +05:30
Kovid Goyal
f801c47d1e Port vertical/horz layouts to new groups API 2020-05-12 22:43:54 +05:30
Kovid Goyal
01c0e8da93 Tall and Fat layouts ported to new groups API 2020-05-12 22:43:54 +05:30
Kovid Goyal
e844ad6db3 Respect per-window margin/padding in stack layout
Also use the margin/padding of the base window for all overlay windows
2020-05-12 22:43:54 +05:30
Kovid Goyal
3f8c042bc3 Preserve active idx when removing windows/tabs 2020-05-12 22:43:54 +05:30
Kovid Goyal
707ad705a4 Notify on active window changed when adding/removing to same group 2020-05-12 22:43:54 +05:30
Kovid Goyal
79a780004f Remove references to overlay_for from boss 2020-05-12 22:43:54 +05:30
Kovid Goyal
81b28bc1bd More work on refactoring window groups, stack layout works 2020-05-12 22:43:54 +05:30
Kovid Goyal
e9c4d540b1 More work on refactoring window groups 2020-05-12 22:43:54 +05:30
Kovid Goyal
50d9718c68 Start work on refactoring management of windows 2020-05-12 22:43:53 +05:30
Kovid Goyal
e39da2b2bb Merge branch 'icat-http-timeout' of https://github.com/lamby/kitty 2020-05-11 16:58:21 +05:30
Chris Lamb
f08ec1522a Set a default socket timeout when retrieving remote items in icat.
Otherwise we can easily hang when "icat"-ing resources from unreliable
websites/webcams, etc.
2020-05-11 12:24:57 +01:00
Kovid Goyal
e61e93712c Merge branch 'patch-3' of https://github.com/ctrlcctrlv/kitty 2020-05-11 11:47:14 +05:30
Fredrick Brennan
c9e198e02e Graphics protocol: note best detection method
Per https://github.com/kovidgoyal/kitty/issues/2636#issuecomment-626467852
2020-05-10 23:02:12 -07:00
Kovid Goyal
0ce181b578 Fix #2639 2020-05-10 21:28:55 +05:30
Kovid Goyal
99950fe448 DECQRM responses for mouse tracking modes 2020-05-09 20:55:51 +05:30
Kovid Goyal
d8daf84a09 Fix #2636 2020-05-09 17:21:23 +05:30
Kovid Goyal
3d32202b3a version 0.17.4 2020-05-09 10:48:21 +05:30
Kovid Goyal
4f4d562670 Fix background_tint making the window semi-transparent
Fixes #2618
2020-05-09 09:06:18 +05:30
Kovid Goyal
28fc9c69da Allow showing the name of the current layout and the number of windows in tab titles
Fixes #2634
2020-05-09 08:00:17 +05:30
Kovid Goyal
6edf00e699 Wayland: Fix OS window title not updating for hidden windows
Fixes #2629
2020-05-05 17:51:36 +05:30
Kovid Goyal
a0d6445dda Move expandvars to utils 2020-05-05 08:22:08 +05:30
Kovid Goyal
e74797037c ... 2020-05-04 13:30:35 +05:30
Kovid Goyal
3fb125dba7 Fix mypy editor integration for changes in syntastic 2020-05-04 13:19:03 +05:30
Kovid Goyal
3c8640f9ad Infrastructure for close confirmation 2020-05-02 18:19:08 +05:30
Kovid Goyal
2e63a4c83f Wayland: Remove unused link-time dependency
6aca3e99f0
2020-05-01 15:00:38 +05:30
Kovid Goyal
9da5bee178 X11: Filter out Xlib errors from other connections
2c8e0512dd
2020-05-01 14:59:16 +05:30
Kovid Goyal
2fc6f3b542 Merge changes from upstream
e65de2941c
2020-05-01 14:57:55 +05:30
Kovid Goyal
4754f42e51 Merge branch 'omit-final-tab-separator' of https://github.com/trygveaa/kitty 2020-05-01 14:05:26 +05:30
Trygve Aaberge
941fe918fb Omit final tab separator
This makes tab separators only drawn between the tabs.

Relates to #2616
2020-05-01 10:29:18 +02:00
Kovid Goyal
f4e82e972e ... 2020-05-01 08:10:11 +05:30
Kovid Goyal
f66dbf111d Pass env to get_vcs_revs() 2020-05-01 08:03:31 +05:30
Kovid Goyal
1a2da5c49d Use python3 in session.vim 2020-04-30 23:12:37 +05:30
Kovid Goyal
8327dabb29 Allow @ send-text over a socket to work with more than 1MB of text 2020-04-30 08:58:46 +05:30
Kovid Goyal
195ea6c140 Dont send back an rc disallowed response for commands that dont expect responses 2020-04-29 21:53:20 +05:30
Kovid Goyal
fcc0707174 Fix kitty @ send-text not working with text larger than 1024 bytes when using --listen-on
Fixes #2607
2020-04-29 21:48:09 +05:30
Kovid Goyal
aa9c3cd634 Report modifier key state when sending wheel events to the terminal program 2020-04-29 20:02:55 +05:30
Kovid Goyal
b541341681 Avoid use of goto 2020-04-29 14:37:26 +05:30
Kovid Goyal
e5d50aca6d ... 2020-04-29 09:21:36 +05:30
Kovid Goyal
b738f4d4ff Fix a regression that broke drag and drop on macOS
Fixes #2605
2020-04-29 09:12:04 +05:30
Kovid Goyal
5c38aabf0e ... 2020-04-29 07:50:01 +05:30
Kovid Goyal
03e9ed6947 Fix set_window_padding() only working on first window 2020-04-28 22:34:32 +05:30
Kovid Goyal
63493fad22 Fix a regression that caused clicking in the padding/margins of windows in the stack layout to switch the window to the first window
Fixes #2604
2020-04-28 22:23:38 +05:30
Kovid Goyal
696b857f91 By default, double clicking no longer considers the : as part of words
Fixes #2602
2020-04-28 19:57:40 +05:30
Kovid Goyal
53ae2bbe0d Merge branch 'use_loop' of https://github.com/Luflosi/kitty 2020-04-28 19:40:40 +05:30
Luflosi
01069e919d Use loop instead of calling dlopen() multiple times
Having an array of library names and iterating over it looks nicer than having several variables and calling `dlopen()` multiple times manually.
It should also make it easier to use custom library names instead by using the preprocessor, which I plan to do in the near future.
2020-04-28 15:53:58 +02:00
Kovid Goyal
fc0095f505 Merge branch 'master' of https://github.com/ixydo/kitty 2020-04-27 21:34:52 +05:30
Jinn Koriech
421528e130 Update note about icat + tmux to be more generic 2020-04-27 16:40:24 +01:00
Jinn Koriech
7b70356515 Add note clarifying that icat won't work with tmux
When using icat with tmux we get the following:

```
$ kitty icat ~/Pictures/fc.jpg 
Terminal does not support reporting screen sizes via the TIOCGWINSZ ioctl
```

I found a suggestion[1] this is due to limitations between kitty and tmux, so I'm raising this PR to either confirm this is the case and make it clear in the documentation, or to have it rejected so an issue can be raised to address the feature.

1: https://unix.stackexchange.com/a/484776/41996
2020-04-27 14:11:16 +01:00
Kovid Goyal
e803505aad CoreText: When centering glyphs ignore negative origins
This is needed for FiraCode ligatures to line up correctly. See
https://github.com/kovidgoyal/kitty/issues/2591#issuecomment-619937030
2020-04-27 18:02:53 +05:30
Kovid Goyal
ad1ff455a0 macOS: Fix a regression in the previous release that caused ligatures to be not be centered horizontally
Fixes #2591
2020-04-27 16:17:05 +05:30
Kovid Goyal
7692cb5c3d Merge branch 'graphics-big-endian' of https://github.com/jamessan/kitty 2020-04-26 09:36:53 +05:30
James McCoy
a94e208db3 Use T_PYSSIZET for GraphicsManager.image_count
GraphicsManager.image_count is declared as a size_t, so the Python type
needs to be the same width.  On 64-bit big-endian architectures, this
mismatch was showing up as test failures:

    ======================================================================
    FAIL: test_gr_delete (kitty_tests.graphics.TestGraphics)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/<<PKGBUILDDIR>>/kitty_tests/graphics.py", line 319, in test_gr_delete
        self.ae(len(layers(s)), 0), self.ae(s.grman.image_count, 1)
        ch = 20
        cw = 10
        delete = <function TestGraphics.test_gr_delete.<locals>.delete at 0x3ffb7fc38b0>
        dx = 0.2
        dy = 0.4
        layers = <function put_helpers.<locals>.layers at 0x3ffb77709d0>
        put_image = <function put_helpers.<locals>.put_image at 0x3ffb77708b0>
        put_ref = <function put_helpers.<locals>.put_ref at 0x3ffb7770940>
        rect_eq = <function put_helpers.<locals>.rect_eq at 0x3ffb7770a60>
        s = <fast_data_types.Screen object at 0x1b60df0>
        self = <kitty_tests.graphics.TestGraphics testMethod=test_gr_delete>
    AssertionError: 0 != 1
2020-04-25 23:25:18 -04:00
Kovid Goyal
ba9d5cf3ff Merge branch 'use-fPIC' of https://github.com/jamessan/kitty 2020-04-25 21:11:10 +05:30
James McCoy
0dff0d03f9 Use -fPIC instead of -fpic
With large objects, use of -fpic will fail to link on certain
architectures due to size limitations of the global offset table (GOT).
For example, the link stage for glfw-wayland.so fails on sparc64, as
below.  Using -fPIC avoids these size limitations.

    ./glfw/osmesa_context.c:73:(.text+0xf2c): relocation truncated to fit: R_SPARC_GOT13 against symbol `_glfw' defined in .bss section in /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o
    /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o: in function `swapIntervalEGL':
    ./glfw/egl_context.c:238:(.text+0xf68): relocation truncated to fit: R_SPARC_GOT13 against symbol `_glfw' defined in .bss section in /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o
    /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o: in function `destroyContextOSMesa':
    ./glfw/osmesa_context.c:80:(.text+0x10a4): relocation truncated to fit: R_SPARC_GOT13 against symbol `_glfw' defined in .bss section in /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o
    /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o: in function `data_offer_action':
    ./glfw/wl_window.c:1692:(.text+0x15e4): relocation truncated to fit: R_SPARC_GOT13 against symbol `_glfw' defined in .bss section in /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o
    /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o: in function `data_offer_source_actions':
    ./glfw/wl_window.c:1683:(.text+0x1648): relocation truncated to fit: R_SPARC_GOT13 against symbol `_glfw' defined in .bss section in /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o
    /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o: in function `keyboardHandleRepeatInfo':
    ./glfw/wl_init.c:471:(.text+0x1704): relocation truncated to fit: R_SPARC_GOT13 against symbol `_glfw' defined in .bss section in /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o
    /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o: in function `checkScaleChange':
    ./glfw/wl_window.c:55:(.text+0x1768): relocation truncated to fit: R_SPARC_GOT13 against symbol `_glfw' defined in .bss section in /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o
    /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o: in function `primary_selection_copy_callback_done':
    ./glfw/wl_window.c:1833:(.text+0x18bc): relocation truncated to fit: R_SPARC_GOT13 against symbol `_glfw' defined in .bss section in /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o
    /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o: in function `clipboard_copy_callback_done':
    ./glfw/wl_window.c:1825:(.text+0x1910): relocation truncated to fit: R_SPARC_GOT13 against symbol `_glfw' defined in .bss section in /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o
    /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o: in function `primary_selection_source_canceled':
    ./glfw/wl_window.c:1582:(.text+0x1968): relocation truncated to fit: R_SPARC_GOT13 against symbol `_glfw' defined in .bss section in /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o
    /tmp/glfw-wayland.so.SYvdxr.ltrans0.ltrans.o: in function `data_source_canceled':
    ./glfw/wl_window.c:1576:(.text+0x19c0): additional relocation overflows omitted from the output
    collect2: error: ld returned 1 exit status
2020-04-25 10:08:28 -04:00
Kovid Goyal
c92aca5d19 Use a Literal as the type for choice based options 2020-04-24 19:45:51 +05:30
Kovid Goyal
5762baeed7 Typing fixes 2020-04-24 19:27:22 +05:30
Kovid Goyal
601cf01222 Fix #2581 2020-04-24 19:24:11 +05:30
Kovid Goyal
0eef48b516 Use literals as the type for cli opts that take choices 2020-04-24 15:28:04 +05:30
Kovid Goyal
3c1954f329 ... 2020-04-24 15:07:44 +05:30
Kovid Goyal
cc29640604 version 0.17.3 2020-04-23 08:39:07 +05:30
Kovid Goyal
d0329460b8 Fix #2573 2020-04-21 22:04:34 +05:30
Kovid Goyal
717c0c96de Allow mapping arbitrary remote control commands to key presses in kitty.conf 2020-04-19 20:14:23 +05:30
Kovid Goyal
b3f161efce ... 2020-04-19 19:39:56 +05:30
Kovid Goyal
0286940163 Allow changing margings/padding via remote control
Fixes #2546
2020-04-19 19:29:36 +05:30
Kovid Goyal
d4a4ee386f Fix minimal borders in grid layout 2020-04-19 17:58:35 +05:30
Kovid Goyal
33498f9133 ... 2020-04-19 11:01:22 +05:30
Kovid Goyal
da3d4d1bef ... 2020-04-19 09:51:06 +05:30
Kovid Goyal
c69b8870d2 Allow individually setting margins and padding for each edge (left, right, top, bottom) 2020-04-19 09:36:26 +05:30
Kovid Goyal
85b55b31b6 Add a new :opt:listen_on option in kitty.conf
Also allow using environment variables in this option
Fixes #2569
2020-04-19 09:23:52 +05:30
Kovid Goyal
948919e42b Forgot to apply --title on creation of subsequent OS windows
Also update changelog
2020-04-19 08:42:30 +05:30
Kovid Goyal
85c40090ed Fix #2570 2020-04-19 08:36:29 +05:30
Kovid Goyal
98b50ec145 ... 2020-04-19 08:28:40 +05:30
Kovid Goyal
1ab4f7d2d0 Fix a regression in 0.17 that broke displaying graphics over SSH
The new types GraphicsCommand can generate a command with only a payload
and no control keys, as the last command during chunked transfer.
Fix the parser to handle this. Fixes #2568
2020-04-19 08:13:33 +05:30
Kovid Goyal
98801b6fa6 Update changelog 2020-04-19 07:22:02 +05:30
Kovid Goyal
bdd68284b5 Merge branch 'terminfo' of https://github.com/wladh/kitty 2020-04-19 07:21:10 +05:30
Vlad Hanciuta
a61d70ea9a Add strikethrough capabilities to terminfo
The termcap aliases are not standard, but they are used by Vim, it
seems. As far as I can tell, there are no standard termcap attribute for
strikethrough.
2020-04-18 16:37:09 +01:00
Vlad Hanciuta
e271719dd2 Add strikeout capability to terminfo 2020-04-18 16:05:30 +01:00
Kovid Goyal
a08efa1fc5 Fix failing test 2020-04-17 19:57:37 +05:30
Kovid Goyal
ffac3600e0 Layouts: Apply per window padding and margin values
Also make the calculation of blank rects more robust and with less code,
which should hopefully fix #1762
2020-04-17 19:47:34 +05:30
Kovid Goyal
6499f8ac24 Allow window objects to store custom margin/padding 2020-04-17 09:02:08 +05:30
Kovid Goyal
63307cb1d8 Code to serialize state 2020-04-17 08:42:45 +05:30
Kovid Goyal
0a6fb362f6 kitty @ kitten: Allow no_ui kittens to return data to the remote client
Fixes #2552 since the OP can now write a kitten to query the window
manager and return position data even over SSH.
2020-04-15 08:29:55 +05:30
Kovid Goyal
457fcbfb90 Merge branch 'master' of https://github.com/akobel/kitty 2020-04-15 07:44:27 +05:30
Alexander Kobel
3b6277b9e2 Hide "No render frame received" without --debug-rendering 2020-04-14 19:36:58 +02:00
Alexander Kobel
e6e61028b1 Rename --debug-gl to --debug-rendering 2020-04-14 19:35:40 +02:00
Kovid Goyal
e9be66126b Merge branch 'hints-support-empty-word-characters' of https://github.com/trygveaa/kitty 2020-04-14 08:17:13 +05:30
Trygve Aaberge
681fe7f2f2 Don't set word_characters to select_by_word_characters when empty string
This allows you to pass in --word-characters "" which will make hints
only match \w.
2020-04-13 23:02:44 +02:00
Kovid Goyal
0196920533 icat kitten: Fix display of 16-bit depth images
Fixes #2542
2020-04-13 23:05:10 +05:30
Kovid Goyal
5f5bb3ace0 Update Changelog 2020-04-12 20:10:29 +05:30
Kovid Goyal
3c970e0122 Merge branch 'kitten-send-mouse-events' of https://github.com/trygveaa/kitty 2020-04-12 20:09:45 +05:30
Trygve Aaberge
43af6e3b8a Add support for sending mouse events from a kitten
This allows you to a control a program running in kitty from a kitten
using mouse events. If the program is not receiving mouse events of that
type, it is not sent.
2020-04-12 16:19:50 +02:00
Kovid Goyal
ac8cfc12fb Merge branch 'docs-fix-kitten-custom-indentation' of https://github.com/trygveaa/kitty 2020-04-12 19:49:18 +05:30
Trygve Aaberge
b19472e0f5 Fix indentation in kittens/custom.rst to 4 spaces
This file used 3 spaces some places and 4 spaces other places. Other
files like diff.rst and hints.rst use 4 spaces.
2020-04-12 16:04:32 +02:00
Kovid Goyal
b4d08044a0 ... 2020-04-12 17:01:39 +05:30
Kovid Goyal
b2fe02e63f Merge branch 'patch-1' of https://github.com/LesnyRumcajs/kitty 2020-04-12 16:55:10 +05:30
Kovid Goyal
d1a5d30233 Add another test for marking 2020-04-12 16:54:38 +05:30
LesnyRumcajs
bba30138e1 Update Fedora link
The link was pointing to a deprecated `copr`. Let's point it to official Fedora repos! (as copr page suggests anyway)
2020-04-12 13:13:02 +02:00
Kovid Goyal
082546a1e7 Marks: Fix marks not handling wide characters and tab characters correctly
Fixes #2534
2020-04-12 13:28:21 +05:30
Kovid Goyal
41ffd58e26 A bit of cleanup 2020-04-11 21:22:17 +05:30
Kovid Goyal
b4f24e4e1e Merge branch 'must_draw_borders_flag' of https://github.com/franco/kitty 2020-04-11 21:19:52 +05:30
Franco Sebregondi
75c8ffd715 Add flag to Layout to enforce drawing a border
Layout.must_draw_borders = True enforces drawing of a border even
though only a single window is visible. See #2531.
2020-04-11 17:01:44 +02:00
Kovid Goyal
688606ff7c Merge branch 'ignore-keyboard-layout-switch-keys' of https://github.com/trygveaa/kitty 2020-04-10 21:46:07 +05:30
Trygve Aaberge
2e3f9dffa7 Ignore keys for switching keyboard layout
XKB has various options for using keys to switch the keyboard layout.
When these are set, XKB will return keysyms which are unknown to GLFW,
so kitty will fallback to using a keymap without the options set, which
causes the keys to be interpreted as the original keysyms.

However, when these options are set, kitty shouldn't interpret the keys.
Therefore, check for some specific keysyms and return before translating
to GLFW keysyms.

There may be more keysyms which should be ignored, but as far as I can
see from https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/blob/xkeyboard-config-2.29/symbols/group
these are the ones which can be triggered by XKB options.

Fixes #2519
2020-04-10 17:21:53 +02:00
Kovid Goyal
859033415b macOS: Fix incorrect horizontal positioning of some full-width East Asian characters
Fixes #1457
Also render multi-cell PUA characters centered, matching behavior on other platforms
2020-04-09 13:25:19 +05:30
Kovid Goyal
1f1b52b580 Fix specifying options for layouts in the startup session file not working
Fixes #2520
2020-04-09 12:40:09 +05:30
Kovid Goyal
4e7bf80447 diff kitten: New option to control the background color for filler lines in the margin
Fixes #2518
2020-04-08 20:42:49 +05:30
Kovid Goyal
e39df50884 Merge branch 'patch-1' of https://github.com/georgeabr/kitty 2020-04-08 18:56:15 +05:30
George Abraham
8d6a9d45c2 Changing match target to "font"
As suggested in #2516, changing match target to "font" in the fonts.conf file.
2020-04-08 14:02:54 +01:00
Kovid Goyal
0862e85577 Rewrite wcswidth as a state machine 2020-04-07 10:10:30 +05:30
Kovid Goyal
0b9a37139e Render any flag pair in two cells not just known ones 2020-04-06 23:00:34 +05:30
Kovid Goyal
6357f7b811 Update wcswidth() to match new country flag rendering 2020-04-06 22:56:34 +05:30
Kovid Goyal
24197dc422 Render known country flags designated by a pair of unicode codepoints in two cells instead of four. 2020-04-06 22:16:59 +05:30
Kovid Goyal
9bc2ab3245 Function to detect flag pairs 2020-04-06 21:16:14 +05:30
Kovid Goyal
bf4e8c490c Update to Unicode 13.0
Fixes #2513
2020-04-06 18:59:35 +05:30
Kovid Goyal
590a4d70ee Fix --stdin-add-formatting not working
Fixes #2512
2020-04-06 09:35:16 +05:30
Kovid Goyal
40341d2ddd ... 2020-04-04 09:17:38 +05:30
Kovid Goyal
0cd2c41ee3 Update changelog 2020-04-03 22:42:06 +05:30
Kovid Goyal
5d65cdb6a8 Fix reverse video not being rendered correctly when using transparency or a background image
Fixes #2419
2020-04-03 22:40:33 +05:30
Kovid Goyal
759a15ccbb X11: Handle invalid data being sent with drag events by some applications
Fixes #2505
2020-04-02 21:01:19 +05:30
Kovid Goyal
5aead5eebe Replace new-window with launch in the docs 2020-04-01 08:39:37 +05:30
Kovid Goyal
a325a5fdee Merge branch 'strikethrough-info-from-font' of https://github.com/trygveaa/kitty 2020-03-31 09:34:07 +05:30
Trygve Aaberge
931e91f1a7 Read strikethrough info from font when using FreeType
This reads the strikethrough position and thickness from the font so it
is rendered correctly.

This is only implemented for FreeType, not Core Text, because I didn't
find any way to get the info from Core Text, and I don't have a Mac to
test it on either. When using Core Text or when the font doesn't provide
the info, the same approximation as before is used.
2020-03-30 20:09:30 +02:00
Kovid Goyal
6e13509720 Allow entry points and external command combined completion on first word 2020-03-30 11:38:54 +05:30
Kovid Goyal
5b4844e71e oops
Broke normal completion in previous commit. Delegate should only be used
when actual unknown words are present
2020-03-30 11:12:00 +05:30
Kovid Goyal
66cbbea9bb Add completion for executables at kitty invocation in zsh
So now kitty vi<TAB> and kitty vim something<TAB> delegate
completion to zsh for the command that will be executed inside kitty.
2020-03-30 10:54:17 +05:30
Kovid Goyal
b65119b8a9 Color separators in the tab bar using inactive bg except for the last one 2020-03-29 09:20:17 +05:30
Kovid Goyal
86703da917 version 0.17.2 2020-03-29 09:09:16 +05:30
Kovid Goyal
610e9afdf0 Add completion of conf filenames to kitty @ set-colors 2020-03-29 08:41:27 +05:30
Kovid Goyal
e3af9f68d3 Linux: Fix selection of fonts with multiple width variants not preferring the normal width faces
Fixes #2491
2020-03-29 01:52:33 +05:30
Kovid Goyal
747ac85e7c Add an :option:launch --watcher option that allows defining callbacks that are called for various events in the window's life-cycle
Fixes #2440
2020-03-28 12:13:42 +05:30
Kovid Goyal
8c23f9e526 DRYer 2020-03-28 09:20:28 +05:30
Kovid Goyal
e6e339fcd3 ... 2020-03-28 08:44:48 +05:30
Kovid Goyal
f04680ac47 Fix a regression in 0.17 that broke the kitty @ launch remote command and also broke the --tab-title option when creating a new tab.
Fixes #2488
2020-03-28 08:43:32 +05:30
Kovid Goyal
90985cc846 Merge branch 'hints-copy-to-primary-selection' of https://github.com/trygveaa/kitty 2020-03-28 08:21:08 +05:30
Trygve Aaberge
63917944f2 Add an option to hints for copying to the primary selection 2020-03-27 20:23:02 +01:00
Kovid Goyal
793605f80f Update changelog 2020-03-26 22:06:13 +05:30
Kovid Goyal
93a281c7e3 Add a new mappable action `close_other_windows_in_tab` to close all but the active window
Fixes #2484
2020-03-26 22:05:00 +05:30
Kovid Goyal
8f1c6c4d74 Fix #2482 2020-03-26 00:53:19 +05:30
Kovid Goyal
1610dba7ab patch tab bar colors correctly 2020-03-26 00:46:30 +05:30
Kovid Goyal
d9d419991c Respect tab_bar_background again 2020-03-26 00:41:19 +05:30
Kovid Goyal
f9e86b19aa Fix #2480 2020-03-26 00:20:10 +05:30
Kovid Goyal
fffb976e43 Fix blank space at the start of tab bar in powerline style when first tab is inactive
Fix #2478
2020-03-25 19:20:35 +05:30
Kovid Goyal
0da566b49f Hints kitten: Adjust the default regex used to detect line numbers to handle line+column numbers
See #2268
2020-03-25 10:03:25 +05:30
Kovid Goyal
da55717d20 The splits layout needs its own draw_minimal_borders implementation 2020-03-25 09:54:06 +05:30
Kovid Goyal
254836902c Merge branch 'fix/window-border' of https://github.com/pyrho/kitty 2020-03-25 09:35:46 +05:30
Damien Rajon
d01f8d1865 fix(window): inactive window border fix
Fixes #2474.
2020-03-25 00:09:10 +01:00
Kovid Goyal
a46c3f7007 Replace use of cast() 2020-03-24 22:03:10 +05:30
Kovid Goyal
4e58062025 Improve rendering of :option: in cli docs 2020-03-24 22:03:00 +05:30
Kovid Goyal
aa3be0535f version 0.17.1 2020-03-24 19:45:19 +05:30
Kovid Goyal
8ebf5e007c Fix rc setting cursor_text_color to background not working 2020-03-24 19:43:31 +05:30
Kovid Goyal
c2957e7f12 Fix a regression in 0.17 that caused kitty @ set-colors to require setting cursor_text_color
Fixes #2470
2020-03-24 19:29:25 +05:30
Kovid Goyal
bf7c26d357 CoreText: Prefer less bold variants over heavier variants when auto-selecting the bold face 2020-03-24 19:27:14 +05:30
Kovid Goyal
0547102bdd Fix #2468 2020-03-24 18:33:32 +05:30
Kovid Goyal
a07369ce69 Update changelog 2020-03-24 18:14:14 +05:30
Kovid Goyal
21c5610431 ... 2020-03-24 18:02:44 +05:30
Kovid Goyal
6dbdf72f40 CoreText: When matching fonts prefer non-expanded/condensed variants 2020-03-24 17:55:38 +05:30
Kovid Goyal
76a6bba643 Fix #2466 2020-03-24 17:07:37 +05:30
Kovid Goyal
b0b8222a96 ... 2020-03-24 17:04:17 +05:30
Kovid Goyal
0d87b8fac5 Fix a regression in 0.17 that caused tab bar background to be rendered after the last tab as well
Fixes #2464
2020-03-24 16:05:02 +05:30
Kovid Goyal
5227b1f98b Fix :opt:cursor_underline_thickness not working
Fixes #2465
2020-03-24 15:53:13 +05:30
Kovid Goyal
c4f7c5c1cd More explanation for OSC 52 extension 2020-03-24 11:58:30 +05:30
Kovid Goyal
33a84a609c ... 2020-03-24 11:35:34 +05:30
Kovid Goyal
037111715a ... 2020-03-24 11:34:29 +05:30
Kovid Goyal
93271b93e6 version 0.17.0 2020-03-24 10:33:51 +05:30
Kovid Goyal
04488ada06 Merge branch 'png2icns' of https://github.com/Luflosi/kitty 2020-03-21 08:50:57 +05:30
Luflosi
21c7002c68 Add support for png2icns as an alternative to iconutil
png2icns is used when building kitty with nix because iconutil seems to be closed-source.
libicns also has an iconutil clone called icnsutil in the source tree but the last release is from 2012, which does not include this utility yet.
2020-03-21 02:11:08 +01:00
Luflosi
97cae0e355 Simplify code
This piece of code ends up just extracting `appname` from `iconset_dir`.
2020-03-21 00:10:16 +01:00
Luflosi
85fc0a59b1 Rename variable logo_dir -> iconset_dir 2020-03-21 00:10:16 +01:00
Kovid Goyal
eddd45bbc3 diff kitten: Fix images losing position when scrolling using mouse wheel/touchpad 2020-03-19 18:46:10 +05:30
Kovid Goyal
e2339697b9 Fix #2449 2020-03-19 17:22:58 +05:30
Kovid Goyal
cfe9b408ce Move startup of first child out of the constructor of Boss 2020-03-19 16:48:16 +05:30
Kovid Goyal
83e8018787 Exclude very small values for content scale 2020-03-19 14:13:23 +05:30
Kovid Goyal
372d2008a6 Actually, we should use text/plain rather than text/uri-list since we are already converting to filesystem paths 2020-03-19 13:40:02 +05:30
Kovid Goyal
ab9a36f8c1 Port cocoa backend to use new drop API 2020-03-19 13:36:03 +05:30
Kovid Goyal
2458c3a7c6 Implement drag and drop of text/plain for Wayland as well 2020-03-19 13:28:21 +05:30
Kovid Goyal
e827e6fa21 X11: Allow drag and drop of text/plain in addition to text/uri-list
Fixes #2441
2020-03-18 22:37:23 +05:30
Kovid Goyal
342f0981d8 Add tests for selection extension by right click 2020-03-18 20:57:19 +05:30
Kovid Goyal
9c19e88288 Allow extending selections by dragging with right button pressed
Fixes #2445
2020-03-18 20:52:25 +05:30
Kovid Goyal
7329bd4910 Fix incorrect first line selection rendering when scrolling down 2020-03-18 20:27:54 +05:30
Kovid Goyal
b9ad62226e Fix selection not being extended by right click when scrolling down
Fix #2443
2020-03-18 20:17:38 +05:30
Kovid Goyal
3bff3bcbe4 Fix selection not updating properly while scrolling
Fixes #2442
2020-03-18 18:48:59 +05:30
Kovid Goyal
a06fdad034 Use a dedicated exception for rc_cmd.fatal() 2020-03-17 11:40:42 +05:30
Kovid Goyal
a49bd98ec6 ... 2020-03-15 13:36:09 +05:30
Kovid Goyal
90f41108d3 ... 2020-03-15 13:30:02 +05:30
Kovid Goyal
382c31ddf2 Use a stub rather than TYPE_CHECKING 2020-03-15 13:27:40 +05:30
Kovid Goyal
871ca4dda6 oops 2020-03-15 08:58:46 +05:30
Kovid Goyal
fa003f8233 Fix #2431 2020-03-15 08:55:04 +05:30
Kovid Goyal
12f37bcfad Dont strip trailing punctuation from end of URL if next line startswith url characters 2020-03-15 08:47:52 +05:30
Kovid Goyal
e86c712424 Dont strip :code:& and :code:- from the end of URLs
Fixes #2436
2020-03-15 08:29:56 +05:30
Kovid Goyal
e8a9935cb2 Allow setting WM_CLASS and WM_NAME when creating new OS windows with the launch command 2020-03-15 08:12:28 +05:30
Kovid Goyal
f353131b44 Fix #2433 2020-03-15 07:54:55 +05:30
Kovid Goyal
7c4a2ba329 Fix #2434 2020-03-14 20:19:26 +05:30
Kovid Goyal
dfb543bd94 ... 2020-03-14 15:27:38 +05:30
Kovid Goyal
c912eef040 Minor strictness increases 2020-03-14 14:59:31 +05:30
Kovid Goyal
5f06d3a427 Disallow untyped decorators 2020-03-14 14:50:04 +05:30
Kovid Goyal
a70fa9abc5 oops 2020-03-14 14:38:56 +05:30
Kovid Goyal
5956277863 All defs are now typed 2020-03-14 14:37:11 +05:30
Kovid Goyal
d3f37eeba4 more typing work 2020-03-14 11:42:05 +05:30
Kovid Goyal
ea48332f46 more typing work 2020-03-14 09:52:56 +05:30
Kovid Goyal
eb12511646 The uber-fussy sway does not like calling wl_data_offer_finish on a version 1 data manager 2020-03-14 09:12:06 +05:30
Kovid Goyal
aa11ddf32c Wayland: Fix a crash when drag and dropping into kitty
Fixes #2432
2020-03-14 08:20:44 +05:30
Kovid Goyal
a348f64833 more typing work 2020-03-13 21:41:07 +05:30
Kovid Goyal
626a96e20f Clean up code for matching windows/tabs in rc 2020-03-13 21:03:06 +05:30
Kovid Goyal
60995ff04b Fix #2429 2020-03-13 19:14:49 +05:30
Kovid Goyal
ba4e711715 Fix #2428 2020-03-13 18:13:11 +05:30
Kovid Goyal
891b184195 misc typing fixes 2020-03-13 16:45:39 +05:30
Kovid Goyal
5414dc398e Correct a few type definitions in layout.py 2020-03-13 16:21:36 +05:30
Kovid Goyal
917559f883 more typing work 2020-03-13 16:13:26 +05:30
Kovid Goyal
9f2fb76309 more typing work 2020-03-12 15:09:21 +05:30
Kovid Goyal
b6692849d6 more typing work 2020-03-12 14:52:11 +05:30
Kovid Goyal
b27f6d5957 more typing work 2020-03-12 14:26:51 +05:30
Kovid Goyal
cda1e28b32 more typing work 2020-03-12 13:51:51 +05:30
Kovid Goyal
8a3e71d3d0 oops 2020-03-12 11:28:58 +05:30
Kovid Goyal
149ae2866a more typing work 2020-03-12 08:10:51 +05:30
Kovid Goyal
21707171bb Simplify the protocol for the send-text remote command 2020-03-12 07:14:47 +05:30
Kovid Goyal
2ebdf738ca more typing work 2020-03-11 20:08:16 +05:30
Kovid Goyal
0e871a89aa more typing work 2020-03-11 09:57:49 +05:30
Kovid Goyal
2d4f194f0d more typing work 2020-03-11 09:43:28 +05:30
Kovid Goyal
ce94a9b2df More typing work 2020-03-11 09:35:59 +05:30
Kovid Goyal
bfbb3c7068 Merge branch 'zsh_compdef_comment' of https://github.com/Luflosi/kitty 2020-03-11 07:17:47 +05:30
Luflosi
6d1fd20542 Add #compdef comment to zsh completion
This will allow adding completions without using `kitty + complete setup zsh | source /dev/stdin` by piping the code into a file named `_kitty` in a directory in `$fpath` instead of piping to `source`. This is especially handy for package managers that package kitty.
See https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org.
The `compdef _kitty kitty` line at the end doesn't seem to have any ill effects when using the completion code in a completion function file. When piping the code to `source` like before, the added line should be interpreted as a comment and be ignored.
2020-03-10 20:48:43 +01:00
Kovid Goyal
bb8cab3a02 Add type information for tui operations cmds 2020-03-10 22:25:57 +05:30
Kovid Goyal
10435c23c2 more typing work 2020-03-10 20:25:09 +05:30
Kovid Goyal
01142cdc8c Add type information to the Graphics Command infrastructure 2020-03-10 20:14:04 +05:30
Kovid Goyal
fc0adfd965 more typing work 2020-03-10 15:48:51 +05:30
Kovid Goyal
8803eeb890 more typing work 2020-03-10 12:58:53 +05:30
Kovid Goyal
25be705bcf DRYer 2020-03-09 21:19:17 +05:30
Kovid Goyal
d8f214a267 oops 2020-03-09 21:11:21 +05:30
Kovid Goyal
f74fb846e5 Fix #2421 2020-03-09 21:10:04 +05:30
Kovid Goyal
8ae110691e More typing work 2020-03-09 21:06:13 +05:30
Kovid Goyal
abff2292c1 Workaround for sphinx type info being available magically on the CI server 2020-03-09 18:37:23 +05:30
Kovid Goyal
7d690bbad2 Run mypy on CI 2020-03-09 18:24:55 +05:30
Kovid Goyal
7298de646a more typing work 2020-03-09 18:17:24 +05:30
Kovid Goyal
3c2f3ecd8e Fix #2420 2020-03-09 17:24:51 +05:30
Kovid Goyal
ac2c21e046 more typing work 2020-03-09 16:13:00 +05:30
Kovid Goyal
c817ba9eae more typing work 2020-03-09 13:32:45 +05:30
Kovid Goyal
92827ae647 More typing work 2020-03-09 09:56:37 +05:30
Kovid Goyal
5bdb405635 More typing work 2020-03-09 08:56:02 +05:30
Kovid Goyal
9beae321d7 More typing work 2020-03-08 22:08:18 +05:30
Kovid Goyal
353db678a2 Add typing to box_drawing 2020-03-08 21:30:50 +05:30
Kovid Goyal
9b973ef99c More typing work 2020-03-08 20:36:50 +05:30
Kovid Goyal
308d171dae More typing work 2020-03-08 18:55:30 +05:30
Kovid Goyal
7057bc663e Implement proper editor integration for mypy 2020-03-08 14:39:46 +05:30
Kovid Goyal
d84cff0baf The hints kitten should by default use the URL prefixes from kitty.conf 2020-03-08 13:26:55 +05:30
Kovid Goyal
645890ccc8 Make the set of URL prefixes that are recognized while hovering with the mouse configurable
Fixes #2416
2020-03-08 13:16:34 +05:30
Kovid Goyal
cc1336a616 More typing work
Also use a mypy based linter when editing
2020-03-08 11:02:14 +05:30
Kovid Goyal
9b32f18109 Refactor remote control commands into individual modules
Also add type information
2020-03-08 08:39:26 +05:30
Kovid Goyal
a0321376d5 Fix `@selection` placeholder not working with launch command
Fixes #2417
2020-03-08 08:00:36 +05:30
Kovid Goyal
0a6e264d09 Fix #2414 2020-03-07 15:15:27 +05:30
Kovid Goyal
afec07b124 More typing work 2020-03-06 14:19:46 +05:30
Kovid Goyal
8a34fede55 More typing work 2020-03-06 08:35:23 +05:30
Kovid Goyal
686b5f297e Ensure glfw is imported from the correct place 2020-03-06 08:23:01 +05:30
Kovid Goyal
6609d219f4 Add type checking for glfw module as well 2020-03-06 07:59:55 +05:30
Kovid Goyal
804998ca69 oops 2020-03-06 07:55:54 +05:30
Kovid Goyal
de5254469c Fix #2412 2020-03-06 07:48:41 +05:30
Kovid Goyal
ef879bab9c Fix #2411 2020-03-06 07:19:33 +05:30
Kovid Goyal
f729985346 More typing work
Also move notification_activated into a standalone function which will
hopefully fix #2410
2020-03-06 07:07:18 +05:30
Kovid Goyal
1e998b6a3f Use mypy in daemon mode 2020-03-05 20:38:51 +05:30
Kovid Goyal
77e9460eea Make mypy a bit stricter 2020-03-05 19:57:28 +05:30
Kovid Goyal
81a58186c6 Drop support for python 3.5 2020-03-05 18:31:20 +05:30
Kovid Goyal
ac149be2bb py3.5 compat 2020-03-05 18:23:45 +05:30
Kovid Goyal
a76a163db5 kitty.config is typed 2020-03-05 18:17:21 +05:30
Kovid Goyal
4ae59d3f77 The launch module is now fully typed 2020-03-05 16:20:56 +05:30
Kovid Goyal
d83a450260 A command for test.py to generate the typing stubs and run mypy 2020-03-05 15:58:30 +05:30
Kovid Goyal
61acc0784e Dont store generated stubs in source control 2020-03-05 15:50:54 +05:30
Kovid Goyal
f05890719d Add type checking for the various CLI options objects 2020-03-05 15:47:12 +05:30
Kovid Goyal
0f4e7921ee Create an auto-generated stub file for the kitty Options object 2020-03-04 19:14:50 +05:30
Kovid Goyal
ec8c96b8e6 diff kitten: Highlight pyi files as python 2020-03-04 11:52:58 +05:30
Kovid Goyal
f0b29e15c3 The utils and constants modules are now fully typechecked 2020-03-04 10:26:41 +05:30
Kovid Goyal
8ad62106e0 No global typing issues in all code (excluding tests) 2020-03-04 08:10:20 +05:30
Kovid Goyal
36eb52424f No top level typing issues for kittens 2020-03-04 07:49:28 +05:30
Kovid Goyal
c9ce2f47dc No top level typing issues found in kitty package 2020-03-04 07:31:22 +05:30
Kovid Goyal
5035ed61ee More typing work 2020-03-04 06:26:02 +05:30
Kovid Goyal
a4cc10c41b More typing work 2020-03-04 06:10:57 +05:30
Kovid Goyal
5730ce5f53 More typing work 2020-03-03 20:18:24 +05:30
Kovid Goyal
27524bfc3d Restore global key definitions so as not to break third party kittens that might use them 2020-03-03 15:06:10 +05:30
Kovid Goyal
8843ded1c9 Refactor key encoding
Cannot have key names in global namespace as not all key names are valid
python identifiers. So move them into a dict.
2020-03-03 14:54:30 +05:30
Kovid Goyal
64b497589f Start adding typing info 2020-03-03 14:31:25 +05:30
Kovid Goyal
ee48fd7151 ... 2020-03-03 12:25:02 +05:30
Kovid Goyal
291cd5e23f Also switch badges in manual 2020-03-01 17:13:27 +05:30
Kovid Goyal
be668cfd9a Switch status badge to github actions 2020-03-01 17:11:39 +05:30
Kovid Goyal
f889c1c75a Switch to using GitHub actions for CI 2020-03-01 17:02:53 +05:30
Kovid Goyal
55c5f3e9fd ... 2020-02-29 11:17:01 +05:30
Kovid Goyal
242d335095 A new `copy_and_clear_or_interrupt` function
Fixes #2403
2020-02-28 21:17:05 +05:30
Kovid Goyal
c763db94ce Fix #2401 2020-02-28 10:28:01 +05:30
Kovid Goyal
a391732600 left half of cell should happen only if url is truly empty 2020-02-28 07:37:10 +05:30
Kovid Goyal
06b45fcace Fix #2402 2020-02-28 07:19:31 +05:30
Kovid Goyal
bdac5f7d5b Add a bounds check in text_for_range() as well 2020-02-27 21:33:42 +05:30
Kovid Goyal
74865efddb move break condition into for loop 2020-02-27 21:31:42 +05:30
Kovid Goyal
b1f4d16692 Left in a printf() 2020-02-27 21:23:27 +05:30
Kovid Goyal
01b8e2c3f5 ... 2020-02-27 21:16:48 +05:30
Kovid Goyal
8c1ef94b26 Bounds check for apply selection
Fixes #2400
2020-02-27 20:27:20 +05:30
Kovid Goyal
507fbc7abf Fix #2399 2020-02-27 07:14:44 +05:30
Kovid Goyal
2f8002c567 Add a test for #1616 2020-02-26 09:20:08 +05:30
Kovid Goyal
551e28d8e0 Run tests python3.8 on linux 2020-02-26 07:34:31 +05:30
Kovid Goyal
e84163e838 Remove unused code 2020-02-26 07:31:43 +05:30
Kovid Goyal
3a64b835fb DRYer 2020-02-26 07:28:39 +05:30
Kovid Goyal
08a44ed4dd Fix #2397
Have to send selection data to GPU on first render.
2020-02-26 07:22:22 +05:30
Kovid Goyal
4b8cc23a86 Fix selection marking incorrect when scrolling 2020-02-25 22:06:53 +05:30
Kovid Goyal
c4b2de8939 Refactor function to not combine input and output parameters 2020-02-25 21:49:31 +05:30
Kovid Goyal
e2a603dcda Fix failing selection test
Unintialized memory use, was not creating an issue in debug builds only
on the CI servers
2020-02-25 21:44:54 +05:30
Kovid Goyal
294d01def6 Clear the click queue before a multi-click 2020-02-25 21:20:41 +05:30
Kovid Goyal
05f289f912 Make py 3.8 available in the CI docker image 2020-02-25 21:14:16 +05:30
Kovid Goyal
4343c4067e Make clang happy 2020-02-25 20:33:19 +05:30
Kovid Goyal
c167dcc4e9 Allow selection of single cells with the mouse. Also improve mouse selection to follow semantics common to most programs
Fixes #945
Fixes #1007
2020-02-25 20:19:38 +05:30
Kovid Goyal
9a67176719 Fix scrolling selection tests 2020-02-25 20:17:49 +05:30
Kovid Goyal
42d1a4755a Add tests for multiline movement 2020-02-25 20:03:14 +05:30
Kovid Goyal
1690e6933f Clean up handling of scrolling in selections 2020-02-25 20:03:14 +05:30
Kovid Goyal
5bbc15583e Non-scrolling based selection tests all pass 2020-02-25 20:03:14 +05:30
Kovid Goyal
e03aabd972 Some consting 2020-02-25 20:03:14 +05:30
Kovid Goyal
6f5968eeb0 Get rid of the ugly macro used for iteration over selections 2020-02-25 20:03:14 +05:30
Kovid Goyal
71b6e8f12a More selection fixes 2020-02-25 20:03:14 +05:30
Kovid Goyal
9c486f6e69 Track left to right for selections based on actual mouse positions
Cant use the selection boundaries as these can be programmatically
altered when extending selection by word or line.
2020-02-25 20:03:14 +05:30
Kovid Goyal
2f24588c66 Fix cell select mode tests 2020-02-25 20:03:14 +05:30
Kovid Goyal
6b1ea326a0 Initial implementation of half cell based selection 2020-02-25 20:03:14 +05:30
Kovid Goyal
4512d0dbac Update test for changes to ANSI serialization 2020-02-25 19:23:05 +05:30
Kovid Goyal
511c4da6a3 Workaround for bug in less that causes colors to reset at wrapped lines
Fixes #2381
2020-02-25 19:14:24 +05:30
Kovid Goyal
af8fdf1dbe Dont use a macro for as_text_generic 2020-02-25 15:33:12 +05:30
Kovid Goyal
b7d12de0a7 Avoid transitions in line_as_ansi on marks 2020-02-25 14:49:17 +05:30
Kovid Goyal
2d870fc84a Fix colors in scrollback pager off if the window has redefined terminal colors using escape codes
Fixes #2381
2020-02-25 10:46:51 +05:30
Kovid Goyal
6e87929603 Dont imply inline comments are supported in the config file 2020-02-24 18:52:51 +05:30
Kovid Goyal
2b441df9e9 Log an error for invalid detach_tab argument 2020-02-24 18:43:15 +05:30
Kovid Goyal
3e672ac178 Log an error for invalid detach_window arguments 2020-02-24 18:42:52 +05:30
Kovid Goyal
12a24d5c86 Remove unused code 2020-02-24 07:10:05 +05:30
Kovid Goyal
dec1a0886d typo 2020-02-23 19:34:31 +05:30
Kovid Goyal
a82e45ad71 Allow passing the currently active kitty window id in the launch command
See #2391
2020-02-23 19:17:26 +05:30
Kovid Goyal
82e5750d71 Merge branch 'tui-line-edit-cursor-end' of https://github.com/trygveaa/kitty 2020-02-23 18:21:27 +05:30
Trygve Aaberge
6a3eb3f3d7 tui line_edit: Set correct cursor position on end
Previously, the cursor would end up one character after the last typed
character when pressing end in the unicode input kitten.
2020-02-23 11:58:44 +01:00
Kovid Goyal
533a739e2b Put back the Brewfile 2020-02-22 19:07:17 +05:30
Kovid Goyal
b12a8331f1 Bump version of macOS for brew based CI 2020-02-22 18:59:34 +05:30
Kovid Goyal
8f4ec036e7 Install sphinx via pip rather than brew
That's what brew advises
2020-02-22 18:47:46 +05:30
Kovid Goyal
cba36f2240 brew bundle seems to have been removed 2020-02-22 18:36:07 +05:30
Kovid Goyal
b54ffbefe4 Ignore setlocale() failures on Linux as well
There are apparently some Linux systems that manage to bork their
locales out there. So just go on with the C locale on these systems.
2020-02-22 18:13:49 +05:30
Kovid Goyal
6d470e4da0 Merge branch 'patch-1' of https://github.com/MaxNoe/kitty 2020-02-20 15:57:18 +05:30
Kovid Goyal
4e1ebec8c2 Merge branch 'fix-menory-leak' of https://github.com/Luflosi/kitty 2020-02-20 15:55:18 +05:30
Maximilian Nöthe
e9779258e9 Make links clickable in INSTALL.md 2020-02-20 11:10:49 +01:00
Luflosi
5c83f45bc6 Fix memory leak when realloc() fails 2020-02-20 10:54:10 +01:00
Kovid Goyal
eb65aca1f4 Merge branch 'fix-boolean-assign-to-pointer' of https://github.com/Luflosi/kitty 2020-02-20 08:02:30 +05:30
Luflosi
5d7e393c93 Fix boolean value assigned to pointer
Found with Cppcheck.
2020-02-20 02:51:40 +01:00
Kovid Goyal
d6d01102fe diff kitten: Fix directory diffing with removed binary files failing
Fixes #2378
2020-02-19 19:53:19 +05:30
Kovid Goyal
1ad802b194 Make re-using the tall neighbor code safer 2020-02-19 15:42:01 +05:30
Kovid Goyal
4a191b65bb Fix a regression in the previous release that broke switching to neighboring windows in the Grid layout when there are less than four windows
Fixes #2377
2020-02-19 15:27:56 +05:30
Kovid Goyal
65cc9f4e1b Merge branch 'patch-1' of https://github.com/felixonmars/kitty 2020-02-19 08:28:15 +05:30
Felix Yan
9f4b13b523 Correct a typo in cmds.py 2020-02-19 05:12:25 +08:00
Kovid Goyal
97e1b62a1e Merge branch 'typo' of https://github.com/Luflosi/kitty 2020-02-18 21:02:48 +05:30
Luflosi
3ac966a38b Fix typo 2020-02-18 16:00:28 +01:00
Kovid Goyal
6f1fda0a48 Store cell half information in selection objects 2020-02-18 17:45:07 +05:30
Kovid Goyal
c00b486864 Track which horizontal half of the cell the mouse is in 2020-02-18 10:20:26 +05:30
Kovid Goyal
7928fff645 Update list of GLFW keys in the doc to use kitty's forked GLFW 2020-02-17 17:52:35 +05:30
Kovid Goyal
0285f5a1ad oops 2020-02-17 16:24:40 +05:30
Kovid Goyal
56e5c8be32 macOS: When switching inpt method while a pending multi-key input is in progress, clear the pending input
Fixes #2358
2020-02-17 15:30:03 +05:30
Kovid Goyal
ef569976cb Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-02-17 09:40:55 +05:30
Luflosi
f8ae048d60 X11: Fix setting the clipboard string to itself
From upstream: 0c27ed1d0e.
2020-02-17 01:12:52 +01:00
Kovid Goyal
c51f4df0ca When the application running in the terminal grabs the mouse, pass middle clicks to the application unless the terminal_select_modifiers are pressed
Fixes #2368
2020-02-16 22:55:18 +05:30
Kovid Goyal
84453bf15c Add a test for #2284 2020-02-16 21:14:08 +05:30
Kovid Goyal
917350f058 Fix incorrect rendering of selection when using rectangular select and scrolling
Fixes #2351
2020-02-16 21:10:09 +05:30
Kovid Goyal
0c58662eb6 Fix fade style tab bar showing opaque background after last tab 2020-02-16 15:11:55 +05:30
Kovid Goyal
52ca75855e Use some of th eglyphs from the poweline extra glyphs set in the symbol_map example 2020-02-16 12:17:34 +05:30
Kovid Goyal
49a07651b9 Merge branch 'typo' of https://github.com/Luflosi/kitty 2020-02-16 08:13:06 +05:30
Luflosi
90a8ba3789 Fix typo in comment 2020-02-15 18:52:18 +01:00
Kovid Goyal
734c3199f0 Fix rendering of combining characters with fonts that have glyphs for precomposed characters but not decomposed versions
Fix #2365
2020-02-15 21:55:17 +05:30
Kovid Goyal
64567646d9 Build with fortify source on clang as well 2020-02-13 11:20:57 +05:30
Kovid Goyal
1a1638cc7f Build with _FORTIFY_SOURCE on gcc 2020-02-13 10:39:57 +05:30
Kovid Goyal
fdf055312c DRYer 2020-02-13 10:07:55 +05:30
Kovid Goyal
b0b8b06b56 Scrolling test 2020-02-13 10:02:44 +05:30
Kovid Goyal
9c1ffb1adf Test for rectangle select 2020-02-13 08:52:33 +05:30
Kovid Goyal
563bafea08 Merge options when testing 2020-02-13 08:33:57 +05:30
Kovid Goyal
efe4c32ffd Fix mock window not being zeroes on creation 2020-02-12 21:34:19 +05:30
Kovid Goyal
0f003a9a77 Remove unused code 2020-02-12 21:28:48 +05:30
Kovid Goyal
3eff929652 More mouse interaction tests 2020-02-12 21:19:25 +05:30
Kovid Goyal
3010ebfef5 More mouse interaction tests 2020-02-12 19:02:38 +05:30
Kovid Goyal
ff14f47781 First mouse interaction test 2020-02-12 15:21:59 +05:30
Kovid Goyal
0b99a5caae APIs for testing mouse interaction 2020-02-12 10:14:17 +05:30
Kovid Goyal
467b96f2f2 Ensure vao_idx is invalid when releasing gpu resources 2020-02-12 09:20:41 +05:30
Kovid Goyal
18751a05c0 Dont use splitlines() to replace \n with \r in pasted text
splitlines breaks on a whole bunch of characters besides \r and \n.
2020-02-11 08:16:20 +05:30
Kovid Goyal
9007623d0c macOS: Fix menubar title not updating on OS Window focus change
Fixes #2350
2020-02-10 07:27:40 +05:30
Kovid Goyal
c1abb7038d Fix border/margin/padding sizes not being recalculated on DPI change
Fixes #2346
Fixes #2347
2020-02-09 08:31:09 +05:30
Kovid Goyal
53f7eebc4d Add changelog entry 2020-02-09 08:04:18 +05:30
Kovid Goyal
d54d29122d Merge branch 'Nudin-patch-1' of https://github.com/Nudin/kitty 2020-02-09 08:03:06 +05:30
Michael F. Schönitzer
1d71791b3c Bugfix exception when executing marker functions
Fixes the exception below that happened for function-markers:
```
Traceback (most recent call last):
  File "/usr/bin/../lib/kitty/kitty/boss.py", line 540, in dispatch_special_key
    return self.dispatch_action(key_action)
  File "/usr/bin/../lib/kitty/kitty/boss.py", line 612, in dispatch_action
    passthrough = f(*key_action.args)
  File "/usr/bin/../lib/kitty/kitty/window.py", line 615, in toggle_marker
    self.screen.set_marker(marker_from_spec(ftype, spec, flags))
  File "/usr/bin/../lib/kitty/kitty/marks.py", line 92, in marker_from_spec
    return marker_from_function(runpy.run_path(path, run_name='__marker__').marker)
```
2020-02-08 19:28:53 +01:00
Kovid Goyal
0c6145d4f2 ... 2020-02-08 14:08:10 +05:30
Kovid Goyal
62e273c5bb unicode input kitten: Allow pressing :kbd:ctrl+tab to change the input mode
Fixes #2343
2020-02-08 13:29:50 +05:30
Kovid Goyal
d82f399be7 ... 2020-02-06 21:16:16 +05:30
Kovid Goyal
20a7050564 Merge branch 'underline_thickness_option' of https://github.com/noomly/kitty 2020-02-06 21:14:34 +05:30
Kovid Goyal
b235f411b0 X11: Fix arrow mouse cursor using right pointing instead of the default left pointing arrow
Fixes #2341
2020-02-06 21:11:09 +05:30
Eyal Chojnowski
99faeeacfc Add PR number to changelog 2020-02-06 16:24:51 +01:00
Eyal Chojnowski
08ad4f389d Fix linting 2020-02-06 16:21:32 +01:00
Eyal Chojnowski
edba63d0d9 Make underline cursor thickness configurable 2020-02-06 16:15:12 +01:00
Kovid Goyal
e33f882abc Changelog entry for cursor beam thickness option 2020-02-06 17:52:40 +05:30
Kovid Goyal
53e059f4f7 Merge branch 'beam_thickness_configurable' of https://github.com/noomly/kitty 2020-02-06 17:49:34 +05:30
Eyal Chojnowski
830364e026 Fix option_type 2020-02-06 13:05:10 +01:00
Eyal Chojnowski
332714a925 Make cursor beam thickness configurable 2020-02-06 12:54:42 +01:00
Kovid Goyal
1eee6deb22 Fix #2339 2020-02-06 16:21:40 +05:30
Kovid Goyal
547f138703 Bound width and height for render_curosr 2020-02-06 06:55:13 +05:30
Kovid Goyal
b6c345fc3c Merge branch 'patch-2' of https://github.com/ctrlcctrlv/kitty 2020-02-05 09:58:07 +05:30
Fredrick Brennan
29c40a4957 Update changelog.rst
This change was discussed privately, lest I appear presumptuous for thanking myself :-)
2020-02-05 12:22:54 +08:00
Kovid Goyal
72af821e1b Freeing bgimage should always null its pointer 2020-02-04 09:51:35 +05:30
Kovid Goyal
5fe4d10f38 Only do processing if pager is not an absolute path 2020-02-03 08:05:34 +05:30
Kovid Goyal
3b36470e84 When resolving scrollback pager if it is not present in system PATH try using shell PATH 2020-02-03 08:03:35 +05:30
Kovid Goyal
f9e8a4050c Allow leading and trailing spaces in tab_title_template by using quotes
Fixes #2332
2020-02-02 21:02:34 +05:30
Kovid Goyal
ce308286df Dont need to bind blit vertex array as cells vertex array is already bound 2020-02-02 20:56:42 +05:30
Kovid Goyal
b670973226 When unsetting bg image borders need to be redone to ensure blank rects are present 2020-02-02 20:51:31 +05:30
Kovid Goyal
01b11b8a53 Allow removing background image via @ set-background-image 2020-02-02 20:41:52 +05:30
Kovid Goyal
75c47a8659 Proper fix for not drawing blank rects when bg image is present 2020-02-02 20:20:45 +05:30
Kovid Goyal
5b4e0ed483 Fix #2331
Some leftover unused code from the bg image merge
2020-02-02 20:09:17 +05:30
Kovid Goyal
7432a7f346 Bind empty VAO when tinting 2020-02-02 14:48:47 +05:30
Kovid Goyal
0830fc3b5a Make background_image tint useable even without a background image in a transparent window 2020-02-02 12:40:29 +05:30
Kovid Goyal
ab2c901e85 Implement bg image tint for transparent windows 2020-02-02 12:34:35 +05:30
Kovid Goyal
3774cc54c7 Fix rendering of semi-transparent bg images in semi-transparent windows
Output colors must be premultiplied
2020-02-02 11:45:48 +05:30
Kovid Goyal
330ed8e4ae Add an option to tint background images using the current background color
Note still has to be implemented for transparent windows
2020-02-02 11:22:21 +05:30
Kovid Goyal
eddae44d6d Fix leak when changing background image using remote control 2020-02-02 09:27:58 +05:30
Kovid Goyal
226488717a Add completion for image filenames at command line
Sadly could not get it to work with the shell
2020-02-01 12:33:11 +05:30
Kovid Goyal
2f9dabd344 Fix unwanted scaling when tiling bg image 2020-02-01 11:41:06 +05:30
Kovid Goyal
cf1b7c0adb Allow set_background_image to work over SSH 2020-02-01 11:35:12 +05:30
Kovid Goyal
eb57d0d431 Remote control command to set background image 2020-02-01 10:50:56 +05:30
Kovid Goyal
8116ee015a API for changing the background image of OS windows
Uses reference counting
2020-02-01 09:17:41 +05:30
Kovid Goyal
0fa3cec61f Add support for specifying a background image
Fixes #163
2020-01-31 20:22:29 +05:30
Kovid Goyal
eb60464177 No need to zero background opacity
We anyway dont draw the default background color in
draw_interleaved(_premult)
2020-01-31 18:51:02 +05:30
Kovid Goyal
44b2651a0f Fix draw_cells_interleaved_premult() for drawing with and without a background image 2020-01-31 15:40:00 +05:30
Kovid Goyal
f2e91b5ed2 Remove incorrect setting of bgimage unit in graphics program 2020-01-31 15:28:21 +05:30
Kovid Goyal
e72b60c882 tiling->tiled 2020-01-31 15:11:30 +05:30
Kovid Goyal
5263babc9a Use a single program for drawing background images 2020-01-31 15:09:47 +05:30
Kovid Goyal
9034b50b3a Dont use a separate background image opacity setting 2020-01-31 14:05:25 +05:30
Kovid Goyal
fdd7fe1948 Properly release resources used by bgimage
Also allow per OS Window bg images in the future
2020-01-31 12:17:54 +05:30
Kovid Goyal
8e7b8b70dc A VAO is not needed to draw background images 2020-01-31 11:34:34 +05:30
Kovid Goyal
9bf24bdff5 Cleanup png_path_to_bitmap() 2020-01-31 09:46:16 +05:30
Kovid Goyal
ee53edd96d Fix conversion of background_image option to C
Should handle None and not rely on the python object's lifetime.
Also some miscellaneous cleanups.
2020-01-31 09:03:19 +05:30
Kovid Goyal
1bc5d7038d Merge branch 'bgimage' of https://github.com/ctrlcctrlv/kitty 2020-01-31 07:58:55 +05:30
Fredrick Brennan
8a6b8b415c More stylistic fixes 2020-01-31 09:48:28 +08:00
Kovid Goyal
86174c81c8 Some tests for splits layout 2020-01-30 20:30:52 +05:30
Kovid Goyal
374500d7b0 py3.5 compat 2020-01-30 18:55:58 +05:30
Kovid Goyal
319a141967 grammar 2020-01-30 18:52:40 +05:30
Kovid Goyal
c0d0062ef8 Add docs for individual layouts
Also changelog entry for the splits layout
Fixes #2308
2020-01-30 18:50:28 +05:30
Fredrick Brennan
aaaa34e119 Move a bunch of unneeded stuff 2020-01-30 18:08:25 +08:00
Fredrick Brennan
fba9502a9d Fix background_image_linear 2020-01-30 18:01:28 +08:00
Kovid Goyal
6670cc1534 Dont swap when removing overlay window in splits 2020-01-30 15:28:51 +05:30
Kovid Goyal
970729dca0 Work on expanding documentation for layouts 2020-01-30 15:06:23 +05:30
Fredrick Brennan
6627586d6e Fix pedantic compiler test 2020-01-30 17:31:37 +08:00
Fredrick Brennan
9f364209af Add background_image 2020-01-30 17:23:42 +08:00
Kovid Goyal
c31a39a052 Action to convert between vertical and horizontal splits 2020-01-30 14:34:40 +05:30
Kovid Goyal
36fda90814 Implement window movement for splits 2020-01-30 13:33:15 +05:30
Kovid Goyal
7ccfbc16e9 DRYer 2020-01-30 07:26:32 +05:30
Kovid Goyal
ad3b527bc4 Neighboring windows for splits 2020-01-30 07:09:33 +05:30
Kovid Goyal
f7eef3f456 Minimal borders for the splits layout 2020-01-30 06:12:45 +05:30
Kovid Goyal
1870364888 When laying out windows in splits shove them offscreen if their widths/heights become too small as too small values will cause crashes 2020-01-30 06:12:45 +05:30
Kovid Goyal
d7dfc85cf7 A __repr__ for Pairs 2020-01-30 06:12:45 +05:30
Kovid Goyal
c047e5f16a Implement perpendicular axis resizing for splits 2020-01-30 06:12:45 +05:30
Kovid Goyal
8d21f63ec2 Resizing of a single split 2020-01-30 06:12:45 +05:30
Kovid Goyal
85b6a91e5c Blank rects for splits layout 2020-01-30 06:12:45 +05:30
Kovid Goyal
c788e30b66 Implement adding of windows to splits layout 2020-01-30 06:12:45 +05:30
Kovid Goyal
a99caed693 Basic implementation of splits layout 2020-01-30 06:12:45 +05:30
Kovid Goyal
9589fb5275 Clarify docs for background_opacity 2020-01-30 05:59:52 +05:30
Kovid Goyal
1a6dc530a4 Improve create_marker docs 2020-01-29 14:41:01 +05:30
Kovid Goyal
60835871eb Better error message when user does not specify strategy for disabling ligatures 2020-01-28 15:23:08 +05:30
Kovid Goyal
644ee646a2 version 0.16.0 2020-01-28 08:48:00 +05:30
Kovid Goyal
8f1ec053ef ... 2020-01-27 08:50:29 +05:30
Kovid Goyal
2e3037ce3a Wayland: Fix window titles being set to very long strings on the order of 8KB causing a crash
Fixes #1526
2020-01-27 08:49:25 +05:30
Kovid Goyal
109a856b91 Fix #2313 2020-01-26 08:00:06 +05:30
Kovid Goyal
eaec854bfb ... 2020-01-25 11:51:17 +05:30
Kovid Goyal
2c6cc6f047 Remove unused slot 2020-01-25 11:22:22 +05:30
Kovid Goyal
f32ae10339 Use a global cache instead of a per window cache for grid size calculation 2020-01-25 11:21:05 +05:30
Kovid Goyal
c46317f96f Use typed layout data 2020-01-25 11:11:55 +05:30
Kovid Goyal
a67e4e550e Merge branch 'issue2310' of https://github.com/ctrlcctrlv/kitty 2020-01-24 13:43:15 +05:30
Fredrick Brennan
65a7b19f40 Make each OS window have its own framebuffer
This commit fixes graphics rendering when more than one OS window is
open, all OS windows are semi-transparent, and multiple windows contain
graphics.

This commit closes #2310.
2020-01-24 16:06:57 +08:00
Kovid Goyal
1b5daf930a Make the comment explaining wayland polling more detailed 2020-01-23 15:08:54 +05:30
Kovid Goyal
748ca81d4b Wayland: Fix a freeze in rare circumstances when having multiple OS Windows
Fixes #2307
Fixes #1722
2020-01-23 15:07:22 +05:30
Kovid Goyal
0ea7d24ba4 Fix incorrect offset when rendering images and there are +z-index, -z-index and --z-index images 2020-01-21 08:09:04 +05:30
Kovid Goyal
6c9861cb76 Fix incorrect blending of default bg color when using draw_cells_interleaved_premult with images but no below images 2020-01-21 07:59:44 +05:30
Kovid Goyal
a1125b5cc8 Move draw_bg multiplication into vertex shader 2020-01-21 07:58:34 +05:30
Kovid Goyal
b4e189d2bf Merge branch 'simplify' of https://github.com/Luflosi/kitty 2020-01-21 06:54:28 +05:30
Luflosi
dbc763fca0 Remove useless code from shader 2020-01-21 00:28:55 +01:00
Kovid Goyal
4c03ffeae2 Merge branch 'patch-1' of https://github.com/ctrlcctrlv/kitty 2020-01-18 15:11:03 +05:30
Fredrick Brennan
2719ac7d01 Add :pull:2248 to changelog.rst
It was missing
2020-01-18 17:34:27 +08:00
Kovid Goyal
219b81b5ee typo 2020-01-18 08:19:42 +05:30
Kovid Goyal
8e1443360f Merge branch 'force_ltr' of https://github.com/ctrlcctrlv/kitty 2020-01-18 08:07:56 +05:30
Kovid Goyal
d55242aa82 Merge branch 'master' of https://github.com/mfilenko/kitty 2020-01-17 21:40:10 +05:30
Max Filenko
ba531969ec List layouts in their default order 2020-01-17 16:28:44 +01:00
Max Filenko
c12e7587cb Document default configuration 2020-01-17 16:28:30 +01:00
Kovid Goyal
3aac0860a2 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-01-17 20:28:26 +05:30
Luflosi
e4fd12001c Cocoa: Add fully dynamic loading of Vulkan loader
From upstream: 7da87aaae7.
2020-01-17 14:18:28 +01:00
Luflosi
3581ffe04b Cocoa: Select Vulkan surface extension at runtime
From upstream: 15d91801b7.
2020-01-17 14:18:21 +01:00
Luflosi
f6901e4a3d Cocoa: Add support for VK_EXT_metal_surface
From upstream: c5cb4a253a.
2020-01-17 14:18:05 +01:00
Fredrick Brennan
5a2cc4578e force_ltr also makes FriBidi usable
Add above fact to documentation.
2020-01-17 17:57:26 +08:00
Fredrick Brennan
6b5acc4d3d Add force_ltr
Close #2252
2020-01-17 16:22:40 +08:00
Kovid Goyal
43326c9bd0 Fix URL detection not working for urls of the form scheme:///url
Fixes #2292
2020-01-17 07:49:01 +05:30
Kovid Goyal
96f3253e6d goto_tab now maps numbers larger than the last tab to the last tab
Fixes #2291
2020-01-16 20:17:17 +05:30
Kovid Goyal
f5090c951a Merge branch 'with_open' of https://github.com/Luflosi/kitty 2020-01-16 19:41:55 +05:30
Luflosi
edacdc5e25 Use python context manager to open file 2020-01-16 14:11:54 +01:00
Kovid Goyal
c67661af61 oops 2020-01-15 21:39:13 +05:30
Kovid Goyal
5e60329adf Changelog entry to titlebar-only 2020-01-15 21:37:20 +05:30
Kovid Goyal
6b4f8408de Merge branch 'macos_hide_titlebar' of https://github.com/Luflosi/kitty 2020-01-15 21:36:03 +05:30
Luflosi
ea1ef709c6 macOS: Allow hiding the titlebar only instead of all window decorations
Thanks to @ntruong for writing cb8279ec54 and  6807411365, the code was very helpful.
2020-01-15 16:35:36 +01:00
Kovid Goyal
bbf247c5c0 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-01-15 19:32:12 +05:30
Kovid Goyal
8243fd505f Make mark colors per window 2020-01-15 18:42:37 +05:30
Luflosi
ed9f9db1b0 X11: Fix parent window handle initialization
From upstream: 9372ba95fa.
2020-01-15 13:19:33 +01:00
Luflosi
74bed658e1 X11: Fix no window position events during resize
From upstream: fe57e3c292.
2020-01-15 13:19:32 +01:00
Kovid Goyal
2f7bdc274d Fix failing test 2020-01-15 11:48:13 +05:30
Kovid Goyal
1347ff27d9 Changelog entry for triple click change 2020-01-15 11:46:50 +05:30
Kovid Goyal
5bf4d520f5 Merge branch 'master' of https://github.com/copy/kitty 2020-01-15 11:43:20 +05:30
Kovid Goyal
cf8d665eb7 Allow having more than one full height window in the :code:tall layout
Fixes #2276
2020-01-15 11:28:58 +05:30
Fabian
b2eee6df5c Multiline triple-click selections: Don't ignore leading spaces in first line 2020-01-14 21:04:59 -06:00
Kovid Goyal
e8121b39ec Add newer layout classes to tests 2020-01-15 08:14:45 +05:30
Kovid Goyal
5359abab76 next version should be 0.16.0 2020-01-15 08:05:45 +05:30
Kovid Goyal
01644ac3f0 Changelog entry for marks 2020-01-15 08:05:12 +05:30
Kovid Goyal
8fbf552494 Allow opening new tabs/windows before the current tab/window as well as after it with the :option:launch --location option. 2020-01-15 08:02:05 +05:30
Kovid Goyal
9c3390c5e6 Allow specifying a marker when launching windows 2020-01-15 07:22:32 +05:30
Kovid Goyal
24d45b99e3 typo 2020-01-15 07:13:32 +05:30
Kovid Goyal
936f2186cc Allow scrolling to marks 2020-01-15 07:11:34 +05:30
Kovid Goyal
c68b302fa2 Merge branch 'wayland' of https://github.com/kennylevinsen/kitty 2020-01-15 06:51:24 +05:30
Kenny Levinsen
ca7cab1a2d wayland: Consistently use errno for errors 2020-01-14 20:06:13 +01:00
Kenny Levinsen
083b294659 wayland: Simplify dispatch_pending error handling
wl_display_dispatch_pending does not return EAGAIN, and always sets an
error when it fails. This allows us to handle errors in a simpler
manner.
2020-01-14 20:04:23 +01:00
Kenny Levinsen
bc24716476 wayland: errno does not have to be cleared
As long as errno is only read on error from an errno-setting function,
then there is no need to reset errno between uses.
2020-01-14 20:04:23 +01:00
Kenny Levinsen
4acab65016 wayland: Only cancel display read after prepare success
The display reader count only increments when wl_display_prepare_read
succeeds.  Calling wl_display_cancel_read when wl_display_prepare_read
has not succeeded results in a negative reader count, which does not
have well-defined behavior.
2020-01-14 20:00:47 +01:00
Kenny Levinsen
f6b03f106c wayland: Cancel display read before abortOnFatalError
Calling wl_display_cancel_read immediately ensures that other readers
waiting on us will have a chance to wake up and discover the error in a
timely manner.
2020-01-14 19:59:02 +01:00
Kovid Goyal
8f9bbeabd7 Fix reference to --debug-config 2020-01-14 19:50:18 +05:30
Kovid Goyal
ac72ac7af2 Wayland: On dispatch error cancel read before running fatal error handlers
Might help #1722
2020-01-14 19:48:28 +05:30
Kovid Goyal
68e00bc8e1 Proper fix for #2270
Fixes #2270
2020-01-14 18:50:06 +05:30
Kovid Goyal
922d6b3b32 Fix #2270 2020-01-14 17:20:35 +05:30
Kovid Goyal
4dde98305e Allow setting markers using remote control 2020-01-14 15:06:52 +05:30
Kovid Goyal
3593189a75 Add a link to the marks docs 2020-01-14 13:45:37 +05:30
Kovid Goyal
4f135be86c Allow creating markers dynamically 2020-01-13 20:05:50 +05:30
Kovid Goyal
605b32f78a Merge branch 'dryer' of https://github.com/Luflosi/kitty 2020-01-13 19:42:56 +05:30
Luflosi
476a8b1429 DRYer
Inspired by e0c66ea5ba.
2020-01-13 14:35:17 +01:00
Kovid Goyal
da9165aebf More marker docs 2020-01-13 12:54:29 +05:30
Kovid Goyal
455a1e9532 Basic docs for marking 2020-01-13 12:38:58 +05:30
Kovid Goyal
f12031e284 Make the run-program example a little fancier 2020-01-13 12:16:43 +05:30
Kovid Goyal
df551bc992 Change marker 1 color 2020-01-13 11:58:18 +05:30
Kovid Goyal
35fb702833 Use only a single marker function
Multipe colors/expressions can instead be combined at definition time
2020-01-13 11:57:19 +05:30
Kovid Goyal
072cd29e3c Make add_marker easier to use with combine 2020-01-13 09:56:39 +05:30
Kovid Goyal
624dd78460 Actually apply mark colors when rendering 2020-01-13 09:51:03 +05:30
Kovid Goyal
51c4737a29 Test function marking 2020-01-13 06:50:37 +05:30
Kovid Goyal
d63ea11cac Marking now works 2020-01-13 06:50:37 +05:30
Kovid Goyal
3d307794be Function to get marks for testing 2020-01-13 06:50:36 +05:30
Kovid Goyal
d32a05925f Code to add and remove markers using maps 2020-01-13 06:50:36 +05:30
Kovid Goyal
04006ea81e Wrapper functions to handle passing matching values to C code 2020-01-13 06:50:36 +05:30
Kovid Goyal
1723616968 Code to apply match colors based on match results 2020-01-13 06:50:36 +05:30
Kovid Goyal
23bc2171c9 Avoid a double call for mark functions 2020-01-13 06:50:36 +05:30
Kovid Goyal
0b3602f764 Code to add markers to Screen 2020-01-13 06:50:36 +05:30
Kovid Goyal
0e448347cd Fix #2279 2020-01-13 06:50:14 +05:30
Kovid Goyal
e0c66ea5ba DRYer 2020-01-12 21:42:12 +05:30
Kovid Goyal
268de9a9d5 Merge branch 'add_CIRCUMFLEX_to_control_codes' of https://github.com/Luflosi/kitty 2020-01-12 21:03:27 +05:30
Luflosi
74eb523178 Add GLFW_KEY_CIRCUMFLEX to control_codes
See https://github.com/kovidgoyal/kitty/issues/1990.
2020-01-12 16:27:40 +01:00
Kovid Goyal
8c540d5a46 Fix #2277 2020-01-12 20:00:08 +05:30
Kovid Goyal
2045055ae3 Use actual color value comparison when detecting default background color
This is very slightly more GPU intensive but means that even if
an application explicitly sets the color to be the same as the default
color, it will be transparent.
2020-01-12 18:14:03 +05:30
Kovid Goyal
d8ed135b46 Clean up rendering of cell backgrounds 2020-01-12 13:20:23 +05:30
Kovid Goyal
3a4ba7e834 Remove un-needed variable 2020-01-12 10:55:14 +05:30
Kovid Goyal
fab57fbdf1 Micro-optimization 2020-01-12 10:53:27 +05:30
Kovid Goyal
76a93b6cd6 DRYer 2020-01-12 10:52:42 +05:30
Kovid Goyal
f44c3a4606 Forgot to update comment describing render pipeline 2020-01-12 10:26:25 +05:30
Kovid Goyal
714bee7f45 Only use an extra draw call for the background when drawing interleaved cells if it is actually required 2020-01-12 09:37:16 +05:30
Kovid Goyal
91673642b3 icat: Allow easily specifying z-index values below background threshold 2020-01-12 09:36:11 +05:30
Kovid Goyal
fee08d746c Merge branch 'replace_exception_with_alias' of https://github.com/Luflosi/kitty 2020-01-11 21:21:52 +05:30
Luflosi
527ff0238a Replace all instances of EnvironmentError with OSError
According to the text just above https://docs.python.org/3/library/exceptions.html#EnvironmentError, `EnvironmentError` has been an alias of `OSError` since Python 3.3. Replacing it makes the code more consistent since `OSError` is used in other places in the code too.
2020-01-11 16:47:36 +01:00
Kovid Goyal
789d649b5c defaultbg should be a local variable 2020-01-11 16:59:50 +05:30
Fredrick Brennan
8020657d8c Allow drawing images below cells w/background 2020-01-11 16:56:59 +05:30
Kovid Goyal
a15d3ff12d ... 2020-01-10 10:19:02 +05:30
Kovid Goyal
fbce95aeda Add an example for open file hints 2020-01-10 10:18:18 +05:30
Kovid Goyal
9bc1b5a2d9 hints kitten: Allow pressing :sc:goto_file_line to quickly open the selected file at the selected line in vim
Fixes #2268
2020-01-10 10:01:03 +05:30
Kovid Goyal
6a8b7bf92f Merge branch 'with_suppress' of https://github.com/Luflosi/kitty 2020-01-09 20:58:37 +05:30
Luflosi
48728bdfdc Use "with suppress()" to suppress a python exception 2020-01-09 16:21:56 +01:00
Kovid Goyal
b6416cf8a9 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-01-09 06:58:30 +05:30
Luflosi
053de5763a X11: Fix BadMatch focusing a window on non-EWMH WM
From upstream: aa5e313561.
2020-01-08 19:50:17 +01:00
Kovid Goyal
fdb915d0c8 Merge branch 'zindex' of https://github.com/ctrlcctrlv/kitty 2020-01-08 18:20:34 +05:30
Fredrick Brennan
c2769c9aed Add --z-index to icat kitten
Meow.
2020-01-08 20:08:01 +08:00
Kovid Goyal
57deb19d0b typo 2020-01-07 10:45:05 +05:30
Kovid Goyal
321771b150 Merge branch 'resize-by-increments' of https://github.com/aes/kitty 2020-01-07 10:44:55 +05:30
Kovid Goyal
61dd2011f5 Dont rely on fontconfig to get postscript names 2020-01-07 09:30:41 +05:30
Kovid Goyal
8a5f189213 Ignore invalid font features when parsing config 2020-01-07 09:20:04 +05:30
Kovid Goyal
14560b008a Clean up font features merge 2020-01-07 08:54:32 +05:30
Kovid Goyal
db85e07d41 Merge branch 'master' of https://github.com/ctrlcctrlv/kitty 2020-01-07 07:18:31 +05:30
Kovid Goyal
07c838fe24 Merge branch 'round_printed_timeout' of https://github.com/Luflosi/kitty 2020-01-06 07:14:53 +05:30
Luflosi
1583b1b0c6 Print warning message timeout rounded to two digits after the dot
The timeout is 0.25 seconds. Printing 0.25 instead of 0.250000 looks a lot nicer and a resolution of 10 milliseconds should be enough for this warning message anyways.
2020-01-05 16:10:10 +01:00
Fredrick Brennan
d250555cd0 Make font_feature_settings respect disable_ligatures 2020-01-04 20:11:34 +08:00
Fredrick Brennan
dbd0dab154 Revert addition of ffs_set to Font struct
It was from an earlier stage of development and is not needed
2020-01-04 15:37:05 +08:00
Fredrick Brennan
b479ea410d Prevent leaks
Thanks @martinetd
2020-01-04 15:34:47 +08:00
Fredrick Brennan
1db613e95b Add font_feature_settings
Close #2247
2020-01-04 14:36:20 +08:00
Kovid Goyal
70071fe1f6 Merge branch 'simplify' of https://github.com/Luflosi/kitty 2020-01-03 07:46:58 +05:30
Luflosi
58688dda38 Remove duplicate code
The hints, once set with `glfwWindowHint()`, retain their values until changed again. This means, that the `GLFW_DECORATED` hint only needs to be set once, even on non-macOS.
2020-01-03 03:01:53 +01:00
Kovid Goyal
756d65c41e Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-01-03 07:18:25 +05:30
Luflosi
b9a08eacb0 X11: Cleanup
From upstream: 8149a5fc00.
2020-01-03 02:37:19 +01:00
Kovid Goyal
b653711446 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2020-01-03 06:48:30 +05:30
Luflosi
e725c647ef Cocoa: Only create per-monitor display link once
From upstream: b4a8eb9b19.
2020-01-02 18:05:38 +01:00
Kovid Goyal
003f77b257 Merge branch 'add_macos_help_menu_item' of https://github.com/Luflosi/kitty 2019-12-29 22:03:08 +05:30
Luflosi
10b578e6d2 Add help menu to macOS menu bar
Most macOS Apps have a Help menu as the last menu item in the menu bar. They usually have a menu item with the keyboard shortcut <kbd>⌘</kbd>+<kbd>?</kbd>, which shows some kind of help or documentation. I named the menu item "Visit kitty website" and let it open the kitty website as documentation.
macOS also magically adds a search feature to the help menu.
2019-12-29 17:24:12 +01:00
Kovid Goyal
151c6c2c70 Merge branch 'always_show_menu_item' of https://github.com/Luflosi/kitty 2019-12-29 20:53:22 +05:30
Luflosi
53e6de9bd9 Always show the macOS New OS Window menu item
When there is no keyboard shortcut for a new OS window, the macOS menu item should still exist, it should just not have a keyboard shortcut.
2019-12-29 15:27:52 +01:00
Kovid Goyal
66a455a079 Merge branch 'simplify' of https://github.com/Luflosi/kitty 2019-12-29 19:45:07 +05:30
Luflosi
f8855410e0 Simplify some code in kitty/cocoa_window.m
`addItemWithTitle:` can be used instead of `initWithTitle:`. It returns an `NSMenuItem`, which removes the need for allocating an `NSMenuItem` manually and releasing it again.
2019-12-29 14:33:19 +01:00
Kovid Goyal
93e8074325 ... 2019-12-28 08:49:53 +05:30
Kovid Goyal
296f512bfb Forgot you cant use sizeof on arrays passed as function parameters 2019-12-28 08:44:32 +05:30
Kovid Goyal
c8f20d0edf Ensure key name is null terminated 2019-12-28 08:33:13 +05:30
Kovid Goyal
286f3630d7 Merge branch 'macos_fix_keyboard_shortcut_encoding' of https://github.com/Luflosi/kitty 2019-12-28 08:26:03 +05:30
Luflosi
38423505b1 Remove numpad keys from macOS keyboard shortcuts
See previous commit message for the reason.
2019-12-27 15:12:26 +01:00
Luflosi
9a3c621eb6 Fix macOS keyboard shortcut encoding
`glfwGetCocoaKeyEquivalent()` in `glfw/cocoa_window.m` expects the returned characters to be of type `unichar`, which won't work for all unicode characters because it is defined as `unsigned short` according to https://developer.apple.com/documentation/foundation/unichar?language=objc, which is only guaranteed to be at least 16 bits in size. The code calling this function also expects the encoding to be UTF-16.
When I added the various keys in https://github.com/kovidgoyal/kitty/pull/1928, I missed these facts. This means, that `glfwGetCocoaKeyEquivalent()` will behave unexpectedly when called with any of the new-ish keys. Luckily this function is currently only used for determining the macOS shortcut for `new_os_window` but I plan on using it more in the future.
Some of the constants, e.g. `NSBackspaceCharacter` are UTF-16 constants, so we can't just use UTF-8 everywhere.
I fixed the problem by using either UTF-8 characters packed into a `uint32_t` or UTF-16 characters in a `unichar` and then converting them to a UTF-8 encoded char string.

`NSEventModifierFlagNumericPad` isn't guaranteed to fit in a `unichar`, which made this undefined behaviour. It also didn't work. I tried to make it work using `NSEventModifierFlagNumericPad` as a modifier instead, as can be seen in this commit, but couldn't get it to work either because the constants used are native key codes and not unicode characters. Therefore the numpad keys will be removed in the next commit.
2019-12-27 12:42:51 +01:00
Kovid Goyal
bcf847fe98 ... 2019-12-27 15:26:31 +05:30
Kovid Goyal
ee7a5eef99 Have read_shell_environment() not fail when no shell is present 2019-12-27 12:25:01 +05:30
Kovid Goyal
7bed66a458 Ensure ans is set in read_shell_environment
Fixes #2232
2019-12-27 12:20:06 +05:30
Kovid Goyal
b26229c44e Merge branch 'remove_release' of https://github.com/Luflosi/kitty 2019-12-26 08:48:20 +05:30
Luflosi
c497c0f96a Remove call to release on an automatically memory managed object
This call even reliably caused a crash for code I was trying to develop.
2019-12-25 20:29:07 +01:00
Kovid Goyal
6df64613f2 Merge branch 'replace_void_pointer' of https://github.com/Luflosi/kitty 2019-12-25 16:35:08 +05:30
Luflosi
46dd648380 Use the correct pointer type instead of void* 2019-12-25 11:51:40 +01:00
Kovid Goyal
4cd5de78c7 Merge branch 'generate_key_table' of https://github.com/Luflosi/kitty 2019-12-25 08:34:27 +05:30
Luflosi
32fa46d6eb Regenerate key table
Since `CIRCUMFLEX` and `^` were removed from `UN_SHIFTED_PRINTABLE` in b2d428618c by 3a2a16f54c and b5229ec73c, `generate_key_table()` wasn't yet run again.
2019-12-25 02:16:37 +01:00
Kovid Goyal
902c2f6c88 Merge branch 'update_comment' of https://github.com/Luflosi/kitty 2019-12-24 19:31:37 +05:30
Luflosi
2a5196873a Update comment to remove legacy way of starting kitty
Since 9135387cfa kitty should not be started with `python3 .` anymore.
2019-12-24 14:22:37 +01:00
Kovid Goyal
d2067141d3 Fix #2226 2019-12-24 17:10:33 +05:30
Kovid Goyal
b5229ec73c oops 2019-12-23 10:19:02 +05:30
Kovid Goyal
3a2a16f54c Merge branch 'add_circumflex_key' of https://github.com/Luflosi/kitty 2019-12-23 10:08:25 +05:30
Luflosi
b2d428618c Add circumflex (^) key 2019-12-22 18:41:07 +01:00
Kovid Goyal
97af84a063 version 0.15.1 2019-12-21 14:20:28 +05:30
Kovid Goyal
18faee6250 Merge branch 'glad2-regen' of https://github.com/Dav1dde/kitty 2019-12-20 20:19:54 +05:30
David Herberth
fd90a3ddc3 regenerates glad to fix missing APIENTRY 2019-12-20 15:04:23 +01:00
Kovid Goyal
a08931d84d Fix window not being rendered for the first time until some input has been received from child process
Fixes #2216
2019-12-20 08:46:50 +05:30
Kovid Goyal
2f0b6e24c9 Use pre-multiplied alpha when clearing windows
Apparently most systems expect this. See https://github.com/glfw/glfw/issues/1538
2019-12-20 08:16:10 +05:30
Kovid Goyal
33c5fc0fb6 typo 2019-12-20 07:59:55 +05:30
Kovid Goyal
71adb2dcf8 Merge branch 'new_os_window_key_macos' of https://github.com/Luflosi/kitty 2019-12-20 07:59:08 +05:30
Luflosi
1ae324691d Change keyboard shortcut selection algorithm for new_os_window on macOS
On macOS the keyboard shortcuts are visible in the menu bar. When the keyboard shortcut is used, the corresponding menu bar item flashes to indicate which action was just executed.
kitty allows defining multiple keyboard shortcuts for the same action but macOS allows only one, so kitty needs to decide which one should be handled by macOS. Currently it chooses the first keyboard shortcut with only the command key as a modifier key or the first shortcut when there are no shortcuts with only the command key as a modifier.
When a user tries to set their own keyboard shortcut (and doesn't use `clear_all_shortcuts yes`), this won't change the shortcut displayed in the menu bar since the first (default) shortcut with the command key is <kbd>⌘</kbd>+<kbd>n</kbd>.
I think simply choosing the last defined keyboard shortcut is better. This will even allow the user to specify modifier keys other than the command key while still changing the shortcut in the menu bar. This change will not change the default behaviour because all the macOS specific keyboard shortcuts are defined after the non-macOS specific ones.
2019-12-19 22:15:41 +01:00
Kovid Goyal
689d059517 Fix lines at the edge of the window at certain windows sizes when drawing images on a transparent window
Fixes #2079
Fixes #2214
2019-12-19 20:41:31 +05:30
Kovid Goyal
18f0ab9e02 Merge branch 'fix_typo' of https://github.com/Luflosi/kitty 2019-12-19 20:01:12 +05:30
Luflosi
088ab5f137 Fix typo 2019-12-19 13:40:08 +01:00
Kovid Goyal
3dd83975ba Dont cast double to monotonic_t for literals 2019-12-19 17:33:12 +05:30
Kovid Goyal
a796a6cbef Use exponential notation in monotonic.h 2019-12-19 17:22:33 +05:30
Kovid Goyal
4766d7de82 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-12-19 17:19:42 +05:30
Luflosi
4a3686c16c X11: Cleanup
From upstream: 73a8ebb691.
2019-12-19 12:38:56 +01:00
Kovid Goyal
b49105495c Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-12-19 17:07:42 +05:30
Luflosi
ca2eda2c5b X11: Cleanup
From upstream: 4e70c95aa3.
2019-12-19 12:35:44 +01:00
Kovid Goyal
4fc7c4aafc Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-12-19 17:05:10 +05:30
Luflosi
0981828493 X11: Fix updating GLFW_FLOATING on a hidden window
From upstream: 9db156421f.
2019-12-19 12:31:31 +01:00
Kovid Goyal
6bc4f18a59 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-12-19 16:59:26 +05:30
Luflosi
79532a315c X11: Fix invalid read when clearing GLFW_FLOATING
From upstream: 0b652a44d2.
2019-12-19 12:27:36 +01:00
Kovid Goyal
7472a992ed Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-12-19 16:56:48 +05:30
Luflosi
e40616a0db X11: Fix missing checks for EWMH attention atoms
From upstream: 9b6d68ec70.
2019-12-19 12:25:09 +01:00
Kovid Goyal
dd8b97a86c Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-12-19 16:53:38 +05:30
Luflosi
5eff3897de X11: Fix maximization of hidden windows
From upstream: 4837b78ffe.
2019-12-19 12:20:58 +01:00
Kovid Goyal
530cf2eb14 monotonic.h no longer depends on time.h 2019-12-19 16:48:35 +05:30
Kovid Goyal
2baa34beb8 Move a couple of functions to where they are actually needed 2019-12-19 16:43:51 +05:30
Kovid Goyal
87e2f7f86d Missed a couple of macOS timer calls 2019-12-19 16:34:47 +05:30
Kovid Goyal
e142083d53 Remove unused code
Strip out the GLFW timer code, since we use our own kitty based
monotonic clock.
2019-12-19 16:27:25 +05:30
Kovid Goyal
2e850a0d0d Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-12-19 07:56:04 +05:30
Luflosi
aec9c31bca Formatting
From upstream: 506a6aafde.
2019-12-18 18:34:55 +01:00
Kovid Goyal
598a147500 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-12-18 22:51:17 +05:30
Luflosi
ba201c4c92 Add curly braces
From upstream: 9486ec0c02.

The upstream commit mainly changes some cmake stuff, which we don't use and only really adds curly braces to `egl_context.c` (and changes some formatting).
2019-12-18 18:12:48 +01:00
Kovid Goyal
5bc7cfaa43 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-12-18 20:33:44 +05:30
Luflosi
2804e1ff81 Cocoa: Update outdated comment
From upstream: b3544ca43e.
2019-12-18 15:41:31 +01:00
Kovid Goyal
ae27d36902 Fix previous merge 2019-12-18 18:42:59 +05:30
Kovid Goyal
08182fbe4d Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-12-18 18:36:31 +05:30
Luflosi
778474f436 Wayland: Unset the cursor shape on border exit
From upstream: ef6189f348.
2019-12-18 14:01:29 +01:00
Kovid Goyal
c6698ce305 Merge branch 'comment' of https://github.com/Luflosi/kitty 2019-12-18 18:15:30 +05:30
Luflosi
21bc215313 Make comment more accurate
Since all the time values use `monotonic_t` now, `maximum_wait` is no longer measured in seconds. Instead of replacing seconds with nanoseconds, I removed it because the definition of `monotonic_t` is supposed to be changed easily, in which case this comment would not be accurate again.
2019-12-18 12:54:14 +01:00
Kovid Goyal
88a9cc42d2 Merge branch 'fix-panel' of https://github.com/natnat-mc/kitty 2019-12-18 07:32:25 +05:30
Kovid Goyal
28f33a67cf Merge branch 'fix_oserror' of https://github.com/Luflosi/kitty 2019-12-18 07:30:37 +05:30
Nathan DECHER
6742fabfba fix kitty +kitten panel -c <config> resulting in no config at all 2019-12-18 00:33:40 +01:00
Luflosi
b3806f4533 Fix OSError when failing to create config directory on read-only file system
When calling the completion code, kitty tries to access the config directory and create it if it does not exist. If kitty has no permission to create it, a temporary directory will be created instead. This will fail on a read-only file system because that raises an `OSError` and not a `PermissionError`.
In practice this happens when building kitty on macOS Catalina using Nix because `HOME` is set to `/homeless-shelter` for purity and `/` is a read-only filesystem.
2019-12-17 23:42:31 +01:00
Kovid Goyal
6d5fb4ccc6 Fix docs build warning 2019-12-17 20:44:32 +05:30
Kovid Goyal
2487f18f24 Add a new option active_tab_title_template to specify a different template for active tab titles
Fixes #2198
2019-12-17 20:39:46 +05:30
Kovid Goyal
f59afff1d1 Add a new option tab_bar_background to specify a different color for the tab bar
Fixes #2198
2019-12-17 20:08:33 +05:30
Kovid Goyal
b92f95b092 NSGL: Fix disabling of Retina resolution
From upstream: fa60269245
2019-12-15 20:54:21 +05:30
Kovid Goyal
d68ae01448 Make the active window history available when doing kitty @ ls
Fixes #2194
2019-12-13 18:17:13 +05:30
Kovid Goyal
87eda834d3 Use a token for github 2019-12-12 10:05:11 +05:30
Luflosi
c28ff5259a Finish implementing resize by increment 2019-12-09 08:38:41 +01:00
Anders Eurenius
4619259e26 Implement resize by increment 2019-12-09 08:33:32 +01:00
Kovid Goyal
7bf0afa621 Fix #2187 2019-12-08 22:37:47 +05:30
Kovid Goyal
e3e02c7271 Fix #2180 2019-12-01 22:34:56 +05:30
Kovid Goyal
24e17cb7d8 Fix background_opacity incorrectly applying to selected text and reverse video text
Fixes #2177
2019-12-01 15:14:15 +05:30
Kovid Goyal
769998adca Document valid values for pointer_shape_when_grabbed 2019-12-01 08:22:21 +05:30
Kovid Goyal
9b5d88e92d Fix choose item mapping 2019-11-30 17:18:02 +05:30
Kovid Goyal
6d7bebee3a Merge branch 'master' of https://github.com/l-yc/kitty 2019-11-30 16:58:28 +05:30
lyc
1c38654321 Fixed bug in loading libcanberra when falling back on alternative library names 2019-11-30 14:36:22 +08:00
Kovid Goyal
da7a78691f Merge branch 'simplify' of https://github.com/Luflosi/kitty 2019-11-29 09:21:32 +05:30
Luflosi
1eaf7083ef Simplify expression 2019-11-28 23:38:42 +01:00
Kovid Goyal
79a6fcdc5c Oops 2019-11-28 10:12:21 +05:30
Kovid Goyal
90bcbbf426 No need to add index to titles when using hits kitten to choose tab/os_window 2019-11-28 10:11:14 +05:30
Kovid Goyal
41049e2a40 Avoid traceback when cancelling tab selection 2019-11-28 09:42:55 +05:30
Kovid Goyal
c9b8510e9c Also use ascending order for os window selection 2019-11-28 09:23:08 +05:30
Kovid Goyal
d854fc1cd0 Better numbering when asking for tab to detach window to
Fixes #2174
2019-11-28 09:20:38 +05:30
Kovid Goyal
5f7bcae072 hints kitten: Add an option --ascending to control if the hints numbers increase or decrease from top to bottom 2019-11-28 09:20:02 +05:30
Kovid Goyal
652eec3033 Fix a crash/incorrect rendering when detaching a window in some circumstances
Fixes #2173

Ensure all cell related GPU data is resent
2019-11-28 09:01:40 +05:30
Kovid Goyal
a9928ec98a Merge branch 'format' of https://github.com/Luflosi/kitty 2019-11-28 07:24:06 +05:30
Luflosi
e1dfb608ca Format code in kitty/cocoa_window.m a little 2019-11-27 19:56:30 +01:00
Kovid Goyal
2cee3a8809 Better fix for getting clock_gettime() from time.h
Fixes #2169
2019-11-27 22:20:55 +05:30
Kovid Goyal
804f72b31a Get monotonic.h to build on older linux distros 2019-11-27 09:55:00 +05:30
Kovid Goyal
e106dcc83b Dont use -Wfloat-conversion on old compilers 2019-11-27 09:27:23 +05:30
Kovid Goyal
9347be639b version 0.15.0 2019-11-27 09:23:01 +05:30
Kovid Goyal
ffc0c42a63 Merge branch 'faq-font-clarification' of https://github.com/ricci/kitty 2019-11-27 07:31:51 +05:30
Robert Ricci
f5e855b3ad Direct user to rebuild fc-cache in font FAQ
The configuration file that's suggested to force a font to
show up as monospace is very helpful, but it appears you may
need to force fontconfig to rebuild the cache in order for the
change to take effect.
2019-11-26 12:02:23 -07:00
Kovid Goyal
9af4dc4bff Merge branch 'redirect' of https://github.com/Luflosi/kitty 2019-11-26 22:13:51 +05:30
Luflosi
6f6180c34a Change URL to avoid redirect
Since `https://sw.kovidgoyal.net/kitty` redirects to `https://sw.kovidgoyal.net/kitty/`, it would be better to directly use the second URL.
2019-11-26 17:23:21 +01:00
Kovid Goyal
6ddd751713 Merge branch 'simplify' of https://github.com/Luflosi/kitty 2019-11-26 21:09:40 +05:30
Luflosi
2c72b06012 Simplify conditions 2019-11-26 16:06:16 +01:00
Kovid Goyal
88854c1aa4 Merge branch 'fix_stdin_source' of https://github.com/miseran/kitty 2019-11-26 06:47:21 +05:30
Reto Schnyder
5ad704469f Fix condition in stdin selection for launch 2019-11-25 20:10:18 +01:00
Kovid Goyal
c140e17a6f Merge branch 'undo_commenting_out' of https://github.com/Luflosi/kitty 2019-11-24 18:08:14 +05:30
Luflosi
4fc733a9c8 Comment commented out code back in
This piece of code is not run when the `GLFW_COCOA_MENUBAR` init hint is set to `0`, which kitty does.
This reduces the difference to GLFW upstream a little.
2019-11-24 13:29:06 +01:00
Kovid Goyal
c5c59e4c55 Merge branch 'return_type' of https://github.com/Luflosi/kitty 2019-11-24 17:56:26 +05:30
Luflosi
e0edef6719 Change return type of two functions
`on_application_reopen()` and `intercept_cocoa_fullscreen()` both only have two possible return values and can therefore have a return type of `bool`.
2019-11-24 13:06:46 +01:00
Kovid Goyal
0f46ce49e2 Merge branch 'create_menu_bar_in_callback' of https://github.com/Luflosi/kitty 2019-11-24 13:27:35 +05:30
Luflosi
f9fd39b8c1 Create macOS menu bar where GLFW creates it
GLFW creates the menu bar in the applicationWillFinishLaunching method, while kitty creates it in `create_os_window()`. This patch changes the behaviour to match GLFW.
In practice, without this change, there can be a short time where the menu bar is not fully populated.
2019-11-24 08:43:01 +01:00
Kovid Goyal
bd75157428 macOS: Disable mouse hiding by default as getting it to work robustly on Cocoa is too much effort
See #2158
2019-11-24 11:29:23 +05:30
Kovid Goyal
f987f3ba77 Merge branch 'remove_obsolete_comment' of https://github.com/Luflosi/kitty 2019-11-24 08:09:14 +05:30
Luflosi
1c16806efd Remove obsolete comment
In bef9490fa8, `unjam_event_loop()` was removed but not the corresponding comment.
2019-11-23 17:51:38 +01:00
Kovid Goyal
29155fef23 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-11-23 18:59:07 +05:30
Luflosi
c05cbed5b2 Reduce difference to GLFW upstream 2019-11-23 13:19:06 +01:00
Kovid Goyal
4f85d4db71 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-11-22 20:16:22 +05:30
Luflosi
468468ab9f Wayland: Don’t update cursor position in the frame
From upstream: a80788c17f.
2019-11-22 12:38:56 +01:00
Kovid Goyal
1b4a6da577 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-11-22 07:11:14 +05:30
Luflosi
aed7a197c7 Wayland: Don’t reload the cursor on every pointer motion
From upstream: a9f674e719.
2019-11-22 02:35:14 +01:00
Kovid Goyal
c257b7ecfd Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-11-22 07:00:04 +05:30
Luflosi
d6072f6218 X11: Assume 96 DPI if RandR monitor size is zero
From upstream: e96dc5d219.
2019-11-22 02:07:34 +01:00
Kovid Goyal
4ea72a2892 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-11-22 06:34:42 +05:30
Luflosi
89b07a1c6b Cocoa: Fix full screen window iconification
From upstream: 2c519709be.
2019-11-22 01:56:55 +01:00
Kovid Goyal
db0cd61807 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-11-22 06:17:47 +05:30
Luflosi
6feb906953 Cocoa: Cleanup
From upstream: bd452016be.
2019-11-21 18:30:03 +01:00
Kovid Goyal
7cbf8c63bc Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-11-21 20:00:30 +05:30
Luflosi
fae51d4e00 Cocoa: Add comments for Cocoa symbol macros
From upstream: 94cb0347ab.
2019-11-21 14:40:34 +01:00
Kovid Goyal
c510584afd Dont hang trying to read shell environment if the shell never quits. Fixes #2143 2019-11-20 11:53:28 +05:30
Kovid Goyal
738878c2ff unicode input kitten: Add an option :option:kitty +kitten unicode_input --emoji-variation to control the presentation variant of selected emojis
Fixes #2139
2019-11-17 13:13:37 +05:30
Kovid Goyal
d5682fe49a Fix #2137 2019-11-17 08:35:23 +05:30
Kovid Goyal
d8dd22048a Wayland: Ensure that glfw window content scale and kitty window content scale are in sync after the window is placed on a monitor 2019-11-16 10:47:05 +05:30
Kovid Goyal
737d8b96b6 Wayland: Dont bother with creating a temporary window anyway, as it is useless 2019-11-16 10:27:01 +05:30
Kovid Goyal
c8627c9713 Expand user/env vars in csutomize processing path and note that absolute paths can be used in the docs for it. 2019-11-16 10:05:25 +05:30
Kovid Goyal
65fa7da24a Wayland: Use the primary monitor scale for windows on creation
This is needed because on creation the window may not have been assigned
to any monitors, so we fallback to using the scale of the primary
monitor. Fixes #2133. Fixes #2135
2019-11-16 10:00:41 +05:30
Kovid Goyal
c4c6ef799f Dont shadow data 2019-11-13 19:47:08 +05:30
Kovid Goyal
0d18b91895 Grammar 2019-11-13 19:45:48 +05:30
Kovid Goyal
42089aaadc typo 2019-11-13 19:45:28 +05:30
Kovid Goyal
432d0f3318 hints kitten: Allow passing extra CLI args when using --customize-procesing 2019-11-13 17:27:55 +05:30
Kovid Goyal
4ade6587e8 spelling 2019-11-13 16:57:11 +05:30
Kovid Goyal
1724f11429 Deprecate pipe in favor of launch 2019-11-13 16:08:48 +05:30
Kovid Goyal
75d66d1048 Changelog entry for launch 2019-11-13 15:44:57 +05:30
Kovid Goyal
feccef67b9 Document the new launch action 2019-11-13 15:43:38 +05:30
Kovid Goyal
a7d30a199d location should also apply to tab creation 2019-11-13 15:40:46 +05:30
Kovid Goyal
37bbfb11d3 Fix location=neighbor causing a hang on a new tab 2019-11-13 15:39:38 +05:30
Kovid Goyal
79c80b4043 Fix doc generation 2019-11-13 15:03:02 +05:30
Kovid Goyal
18a1402ae2 Remote control interface for launch 2019-11-13 15:00:13 +05:30
Kovid Goyal
5d639b91b0 Switch OS windows when focusing on platforms where it is supported 2019-11-13 14:59:49 +05:30
Kovid Goyal
080c09d22e DRYer 2019-11-13 14:41:45 +05:30
Kovid Goyal
00c2670039 Fix handing of --stdin-source and getting of active window 2019-11-13 14:39:44 +05:30
Kovid Goyal
f113184165 Micro-optimization 2019-11-13 14:39:06 +05:30
Kovid Goyal
d69f8af107 Add a --keep-focus option for launch 2019-11-13 11:48:30 +05:30
Kovid Goyal
ad2bd1bf63 Allow using @selection in the launch cmdline 2019-11-13 10:46:04 +05:30
Kovid Goyal
059786ab66 Implement piping for launch 2019-11-13 10:38:58 +05:30
Kovid Goyal
72dfa5e5e6 Allow creating overlays via launch 2019-11-13 10:14:32 +05:30
Kovid Goyal
d84da6b7b8 Documentation placeholder for the new launch interface 2019-11-13 10:09:43 +05:30
Kovid Goyal
6aa82d82ad Start work on a unified interface for launching processes 2019-11-13 09:58:28 +05:30
Kovid Goyal
a649eb2a48 Coalesce neighboring symbol maps for better lookup performance 2019-11-12 20:05:48 +05:30
Kovid Goyal
83932c8099 Add a remote control command for detach_tab 2019-11-12 15:03:58 +05:30
Kovid Goyal
95e36cece1 Add a detach_window remote control command 2019-11-12 13:04:28 +05:30
Kovid Goyal
7075a7f1c0 Only detach window after the ask overlay is removed 2019-11-12 10:59:36 +05:30
Kovid Goyal
3093610d26 Allow choosing new os window/tab during detach ask 2019-11-12 10:42:07 +05:30
Kovid Goyal
86eed7f895 Speed up taking over of tab 2019-11-12 10:38:57 +05:30
Kovid Goyal
5dc14c5861 Copy cwd when taking over tab 2019-11-12 10:24:37 +05:30
Kovid Goyal
cab87f6fb2 Ensure Tab has cwd even with no initial window 2019-11-12 10:18:42 +05:30
Kovid Goyal
fb3acd1f4a Add a detach_tab command 2019-11-12 10:07:44 +05:30
Kovid Goyal
b247cef85c ... 2019-11-12 08:46:41 +05:30
Kovid Goyal
70445f33e9 Another typo 2019-11-12 06:30:21 +05:30
Kovid Goyal
cadb4f1389 ... 2019-11-12 06:29:55 +05:30
Kovid Goyal
bf75a4de61 Also document debug() 2019-11-12 06:25:27 +05:30
Kovid Goyal
400ab584ac hints kitten: Allow completely customizing the matching and actions performed by the kitten using your own script
Fixes #2124
2019-11-11 21:26:42 +05:30
Kovid Goyal
9edad62144 hints kitten: Allow using named groups in the regular expression. The named groups are passed to the invoked program for further processing. 2019-11-11 17:34:19 +05:30
Kovid Goyal
e94205098f Fix link 2019-11-11 16:00:35 +05:30
Kovid Goyal
35ab7eb472 Add a new action :ref:detach_window that can be used to move the current window into a different tab
Fixes #1310
2019-11-11 15:47:48 +05:30
Kovid Goyal
18619b14ac Merge branch 'simplify' of https://github.com/Luflosi/kitty 2019-11-10 23:35:27 +05:30
Luflosi
97e0b9b65a Simplify code 2019-11-10 16:51:25 +01:00
Kovid Goyal
5175d9f4a6 Properly re-initialize GPU resources when detaching/attaching a window 2019-11-09 13:14:50 +05:30
Kovid Goyal
a5aed0f4ab Forgot to change tab_ref when attaching window 2019-11-09 11:23:04 +05:30
Kovid Goyal
14d693a8ff When attaching window make its parent tab active 2019-11-09 11:09:29 +05:30
Kovid Goyal
645963cc24 Cleanup tab after detaching window 2019-11-09 09:42:17 +05:30
Kovid Goyal
20751c2807 Start work on a detach_window command 2019-11-09 09:20:38 +05:30
Kovid Goyal
dda886b97c Merge branch 'caps_lock_modifier' of https://github.com/Luflosi/kitty 2019-11-09 08:31:59 +05:30
Luflosi
b796ceecdd Add Caps Lock to the list of modifier keys
When a key is pressed and `mouse_hide_wait` is less than zero, kitty will hide the mouse cursor. When a key is pressed, kitty will also scroll the history to the bottom. Both of these things don't happen if the key being pressed was a modifier key. Both of these things should not happen when Caps Lock is pressed, so this key should be added to the list of modifier keys.
`is_modifier_key()` is not used for anything else.
2019-11-09 00:41:12 +01:00
Kovid Goyal
4def89ebb5 Add a note on debugging custom kittens 2019-11-08 16:53:26 +05:30
Kovid Goyal
bd1c1839dd Add API to boss.py to move a window into a different tab 2019-11-08 16:18:52 +05:30
Kovid Goyal
8739f698f9 When attaching window and font sizes changes, resize Screen 2019-11-08 14:58:08 +05:30
Kovid Goyal
b8c8482f20 Better fix for Powerline lacking a space glyph
This does not require increasing the size of the cache key, thereby
improving cache lookup performance
2019-11-08 14:41:31 +05:30
Kovid Goyal
4348ca8cc5 Remove unused function 2019-11-08 14:29:41 +05:30
Kovid Goyal
d1aa59080f Add an API to attach and detach windows from tabs 2019-11-08 14:22:02 +05:30
Kovid Goyal
bf0ffa80be Merge branch 'feature-window-to-tab' of https://github.com/0x17de/kitty
Currently only merged the function to move internal window state.
Want to refactor the changes to tabs.py and boss.py to make them more
orthogonal.
2019-11-08 09:55:51 +05:30
Kovid Goyal
2a89a0c87e Merge branch 'master' of https://github.com/martinpelikan/kitty 2019-11-08 07:57:47 +05:30
Kovid Goyal
de84489a20 Fix a regression in 0.14.5 that caused rendering of private use glyphs with and without spaces to be identical
Fixes #2117
2019-11-08 07:55:41 +05:30
Martin Pelikan
40901778ad Update fish completion docs for fish 3.0.0
As of 3.0.0, fish sources `kitty +complete fish` by default.
2019-11-07 18:11:47 -08:00
Kovid Goyal
c1febea659 Merge branch 'restore_error_reporting' of https://github.com/Luflosi/kitty 2019-11-05 07:07:03 +05:30
Luflosi
b42f4ac288 Restore proper error reporting functionality
In 841c907efc, the `%m` format specifier was replaced by `%%m`, which just prints `%m`. To keep the functionality of `%m` without using `%m`, the error string can be printed manually.
2019-11-05 00:42:29 +01:00
Kovid Goyal
fae57a5868 Website: Add a scrollbar to the sidebar if needed 2019-11-04 18:05:08 +05:30
Kovid Goyal
7a02d09508 Merge branch 'master' of https://github.com/CD3/kitty 2019-11-01 23:23:22 +05:30
C.D. Clark III
8ec6fe960d docs: added '@selection' to pipe documentation. 2019-11-01 08:46:49 -05:00
Kovid Goyal
61a77e19ef X11: Fix content scale fallback value on KDE
From upstream: 75294462b3
2019-10-31 09:10:01 +05:30
Kovid Goyal
82e88b54c7 X11: Fix decoration enabling after window creation
From upstream: 5fc4c01302
2019-10-31 09:04:45 +05:30
Kovid Goyal
ab8975f4da Merge branch 'with_suppress' of https://github.com/Luflosi/kitty 2019-10-29 10:17:19 +05:30
Luflosi
5e7fd21c8d Use "with suppress()" to suppress a python exception 2019-10-28 18:35:21 +01:00
Kovid Goyal
30cd9b2ae4 Merge branch 'fix_two_linker_error' of https://github.com/Luflosi/kitty 2019-10-28 07:31:49 +05:30
Luflosi
4f7d12f3fd Fix error when two linker processes fail
When a linker process fails, `failed` will be set to a value other than `None`. When a second linker process fails, the `else` case will be taken because `failed is None`, which executes `compile_cmd.on_success()`. This function tries to rename or move the file generated by the linker but since the linker process failed, the file will most likely not exist. This will throw an error, which will prevent printing the actual error message from the linker.
2019-10-27 21:50:22 +01:00
Kovid Goyal
62da158823 Merge branch 'fix_potential_error' of https://github.com/Luflosi/kitty 2019-10-27 07:42:21 +05:30
Luflosi
2d19b87208 Fix potential error when $PATH is not defined
When `PATH` is not in `os.environ`, kitty could potentially throw a `KeyError`.
2019-10-27 00:10:55 +02:00
Kovid Goyal
54ca775006 Merge branch 'visual' of https://github.com/toonn/kitty 2019-10-26 09:10:15 +05:30
toonn
a64a0d64cb Prefer VISUAL to EDITOR
Fix #2096
2019-10-25 18:52:17 +02:00
Kovid Goyal
6634dc81fe Merge branch 'simplify' of https://github.com/Luflosi/kitty 2019-10-25 07:45:30 +05:30
Luflosi
a2d5eef398 Simplify access to os.environ
The `if` can be removed by using `get()` with a default parameter to access `os.environ`. This also reduces the number of accesses to `os.environ`.
2019-10-24 20:27:27 +02:00
Kovid Goyal
8184ba246a Load libcanberra dynamically at runtime, as needed
Fixes #2089
2019-10-24 09:03:52 +05:30
Kovid Goyal
54ad1d103a Fix #2087 2019-10-23 18:21:34 +05:30
Kovid Goyal
d92f8a90ef Allow changing colors by mapping a keyboard shortcut to read a kitty config file with color definitions.
Fixes #2083
2019-10-21 14:43:35 +05:30
Kovid Goyal
d33c287344 typo 2019-10-21 14:23:07 +05:30
Kovid Goyal
782eebf976 typo 2019-10-21 14:21:09 +05:30
Kovid Goyal
0fbf75b95a Allow specifying that remote control only works over a socket 2019-10-21 14:20:30 +05:30
Kovid Goyal
5781facf4b Merge branch 'fix_icat' of https://github.com/Luflosi/kitty 2019-10-21 07:32:40 +05:30
Luflosi
b710ffc403 Fix icat kitten
Fixes https://github.com/kovidgoyal/kitty/issues/2081.
This bug was introduced in 10e5fcc375.

One place in the code requires the actual `screen_size_function`, not just the result of it.
2019-10-20 21:37:14 +02:00
Kovid Goyal
7d8edccb04 Merge branch 'pending_scroll_pixels_per_screen' of https://github.com/Luflosi/kitty 2019-10-20 16:58:28 +05:30
Luflosi
3750d70173 Store pending_scroll_pixels for every screen
Scrolling in one screen shouldn't affect the `pending_scroll_pixels` for another screen in the same OS window.
2019-10-20 13:22:46 +02:00
Kovid Goyal
025e0bb546 Merge branch 'var-names-consistency-wrt-scancode' of https://github.com/bew/kitty 2019-10-20 08:08:48 +05:30
Kovid Goyal
033367de91 Merge branch 'fix_line_drawing' of https://github.com/Luflosi/kitty 2019-10-19 06:26:57 +05:30
Luflosi
f93b605b75 Fix line drawing algorithm 2019-10-18 21:26:11 +02:00
Kovid Goyal
7b4141b0c8 Add a changelog entry for powerline tabbar 2019-10-18 19:38:08 +05:30
Kovid Goyal
90acef72dc Merge branch 'add_powerline_style_tabs' of https://github.com/brujoand/kitty 2019-10-18 19:36:31 +05:30
Kovid Goyal
43f200be77 Add an entry for the new box character rendering functions 2019-10-18 17:24:33 +05:30
Kovid Goyal
2fbb167803 Merge branch 'fix-triangle-symbol-scaling' of https://github.com/bew/kitty 2019-10-18 17:13:50 +05:30
Benoit de Chezelles
2b396262f0 Update glyph ids 2019-10-18 11:48:55 +02:00
Benoit de Chezelles
74deca52b9 Remove trailing whitespace 2019-10-18 11:39:51 +02:00
Benoit de Chezelles
058d956464 Merge branch 'master' into fix-triangle-symbol-scaling 2019-10-18 11:30:46 +02:00
brujoand
0f38dc1bd1 Adding powerline style tabs 2019-10-18 11:18:28 +02:00
Kovid Goyal
576b03c047 Implement drawing thick anti-aliased lines
And actually use it for the unicode diagonal box drawing chars and also
the powerline angle separators
2019-10-18 13:19:04 +05:30
Kovid Goyal
59cb1ad1e0 Implement special rendering for the diagonal line box drawing chars 2019-10-18 11:01:51 +05:30
Benoit de Chezelles
f77acdce14 remove useless import in help msg for box drawing debug 2019-10-18 06:08:45 +02:00
Benoit de Chezelles
43a98a1df1 Add missing association between char & glyph id 2019-10-18 06:08:20 +02:00
Benoit de Chezelles
d1cf771c14 Add other corner triangles & enable in C side 2019-10-18 05:45:13 +02:00
Benoit de Chezelles
10e5fcc375 Fix usage of icat function show
The `screen_size` function was not initialized yet
2019-10-18 04:54:14 +02:00
Benoit de Chezelles
2112932d04 Add corner triangle glyphs drawing 2019-10-18 04:48:03 +02:00
Benoit de Chezelles
be505ce6e0 Fix test functions for setup_for_testing's new call syntax 2019-10-18 04:47:04 +02:00
Benoit de Chezelles
4d6472128c Rename scancode to keycode for cocoa implementation 2019-10-17 20:41:48 +02:00
Kovid Goyal
26b7b1ec63 Merge branch 'typo' of https://github.com/Luflosi/kitty 2019-10-17 18:32:42 +05:30
Luflosi
9a8f0a9b5a Fix typo 2019-10-17 13:56:46 +02:00
Kovid Goyal
16dbbf3a1e Make count-lines-of-code a little nicer 2019-10-17 15:19:13 +05:30
Kovid Goyal
8492d0a264 Merge branch 'dont_cloc_parse-graphics-command.h' of https://github.com/Luflosi/kitty 2019-10-17 14:36:53 +05:30
Luflosi
d8f8f1f590 Exclude kitty/parse-graphics-command.h from the line count
This file is automatically generated and should not count towards the total line count.
2019-10-17 10:38:55 +02:00
Kovid Goyal
b762e81da0 Merge branch 'python_encoding_header' of https://github.com/Luflosi/kitty 2019-10-17 06:28:16 +05:30
Luflosi
8b3b68ea69 Unify python encoding headers
All the other python encoding headers are of the form `vim:fileencoding=utf-8`.
2019-10-16 20:34:56 +02:00
Benoit de Chezelles
28525766a5 Final changes before 'ready for review' 2019-10-16 02:47:14 +02:00
Benoit de Chezelles
d8fc23c38f remove outdated 'fixme' 2019-10-16 02:41:26 +02:00
Benoit de Chezelles
8cae70fa36 Update doc 2019-10-16 02:36:55 +02:00
Benoit de Chezelles
7f2b98fad7 Rename all uses of 'scancode' to 'native_key' where relevant 2019-10-16 02:25:20 +02:00
Benoit de Chezelles
2b6dde2ac5 Wish: rename scancode → native_key in glfw codebase 2019-10-16 02:00:24 +02:00
Benoit de Chezelles
0c254fa7c7 GLFWkeyevent: rename scancode → native_key 2019-10-16 02:00:24 +02:00
Kovid Goyal
fe7375becc Merge branch 'grammar' of https://github.com/Luflosi/kitty 2019-10-16 04:19:54 +05:30
Luflosi
b6ee88056e Minor grammar correction 2019-10-16 00:46:52 +02:00
Kovid Goyal
96f691ad64 Merge branch 'mark_parse-graphics-command.h_as_generated' of https://github.com/Luflosi/kitty 2019-10-16 03:31:32 +05:30
Luflosi
8cf3380a77 Mark kitty/parse-graphics-command.h as being generated 2019-10-15 18:16:28 +02:00
Kovid Goyal
e8d7e3e98b Merge branch 'remove_khrplatform.h_references' of https://github.com/Luflosi/kitty 2019-10-15 20:58:16 +05:30
Luflosi
8af0a8476f Remove remaining references to kitty/khrplatform.h
`kitty/khrplatform.h` was removed in f872f955b0.
2019-10-15 17:25:47 +02:00
Kovid Goyal
2de4248f76 Merge branch 'regenerate_glfw-wrapper' of https://github.com/Luflosi/kitty 2019-10-15 20:42:49 +05:30
Luflosi
8c73ab6afb Regenerate kitty/glfw-wrapper.h 2019-10-15 17:10:02 +02:00
Kovid Goyal
ee9bd77dc4 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-10-15 19:10:50 +05:30
Luflosi
81f31ca215 Reduce difference of glfw/glfw3.h to GLFW upstream 2019-10-15 15:37:35 +02:00
Kovid Goyal
51eff372f8 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-10-15 18:16:22 +05:30
Luflosi
087376b44d GLFW: Documentation work
From upstream: a43d1a4937.
2019-10-15 14:37:41 +02:00
Kovid Goyal
e49047ef7d Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-10-15 18:02:17 +05:30
Luflosi
c117f36009 GLFW: Cleanup
From upstream: d5ab3e919a.
2019-10-15 14:25:46 +02:00
Kovid Goyal
5ec83ee759 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-10-15 16:17:49 +05:30
Luflosi
410165c14d GLFW: Improve (?) reference documentation for callbacks
From upstream: 51bb76c7c3.
2019-10-15 12:11:01 +02:00
Kovid Goyal
973ef9fcda Merge branch 'fix_nix_link' of https://github.com/Luflosi/kitty 2019-10-15 04:14:04 +05:30
Luflosi
396bfb8540 Fix link to Nix kitty package
Instead of a fragment identifier, the URL now needs a query parameter.
2019-10-14 18:48:21 +02:00
Kovid Goyal
aaf597bffd Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-10-13 09:08:15 +05:30
Luflosi
63c4f64bf5 Reduce difference to GLFW upstream
From upstream: 773f4495f0.
2019-10-12 15:19:44 +02:00
Kovid Goyal
5745dc34f7 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-10-12 17:58:50 +05:30
Luflosi
114b8cff93 Cleanup
From upstream: 62b7fe8311.
2019-10-11 20:26:27 +02:00
Kovid Goyal
261571bb69 Merge branch 'modern_objective-c' of https://github.com/Luflosi/kitty 2019-10-10 22:01:30 +05:30
Manuel Herrmann
497e2c9163 #1310 move windows into separate tabs 2019-10-10 17:13:34 +02:00
Luflosi
ac01ffaa54 Cocoa: Move slightly towards modern Objective-C 2019-10-10 14:36:52 +02:00
Kovid Goyal
eb9fe06d10 Merge branch 'correct_space' of https://github.com/Luflosi/kitty 2019-10-09 22:15:38 +05:30
Luflosi
506f2f7db7 Replace weird character with space
In 4c4c6ab0e6 you added a weird unicode character, which is apparently called an Object Replacement Character, instead of a space.
2019-10-09 18:32:49 +02:00
Kovid Goyal
f476c56f91 Drop support for the gtk_primary_selection wayland protocol
sway recently decided to start complaining when binding
wp_primary_selection_device_manager interface to gtk_primary_selection
name, which means we either have to maintain an in-tree version
of the gtk_primary_selection protocol or drop support for sway.

Sway has not quite annoyed me enough yet for the latter.

See #1977
2019-10-09 07:37:03 +05:30
Kovid Goyal
474688888d Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-10-08 17:16:51 +05:30
Luflosi
7ddbb613fe Cocoa: Fix window creation blocking after re-init
From 2fbb560eb7.
2019-10-08 13:41:10 +02:00
Kovid Goyal
adc1c06089 Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-10-08 12:12:00 +05:30
Luflosi
1f8631cc99 Cocoa: Move app delegate and menu creation to init
From ea7eb2ddab.
2019-10-07 21:24:58 +02:00
Kovid Goyal
f9e4e71285 Slightly better error message when opening controlling terminal fails 2019-10-07 20:48:31 +05:30
Kovid Goyal
5529194c8d Merge branch 'glfw_upstream' of https://github.com/Luflosi/kitty 2019-10-06 20:39:25 +05:30
Luflosi
5b008163af Cocoa: Add NSApplicationDelegate protocol
From c3ed70a4b7.
2019-10-06 16:58:06 +02:00
Kovid Goyal
802da7087c diff kitten: Allow diffing remote files easily via ssh
See #727
2019-10-04 09:08:22 +05:30
Kovid Goyal
53ab7617ca Dont use space ligatures for symbol_map fonts
space ligatures breaks in font ligatures when there is a trailing space.
So only use them for PUA and cells using a fallback font. Fixes #2019
2019-10-02 07:10:51 +05:30
Kovid Goyal
4369255a25 When drawing unicode symbols that are followed by spaces, use multiple cells to avoid resized or cut-off glyphs
Fixes #1452
2019-10-01 19:56:07 +05:30
Kovid Goyal
b709ee6842 Add a function to check if a codepoint is a symbol 2019-10-01 18:57:06 +05:30
Kovid Goyal
4a8f9efe79 Wayland: Resume key repeat on focus gained if the previously repeated key is pressed 2019-09-30 18:47:43 +05:30
Kovid Goyal
19d36fbe69 Wayland: Fix key repeat not being stopped when focus leaves window. This is expected behavior on Wayland, apparently
Fixes #2014
2019-09-30 16:45:39 +05:30
Kovid Goyal
d37e73db54 Merge branch 'fix_broken_paste' of https://github.com/Luflosi/kitty
Fixes #2008
2019-09-29 08:02:31 +05:30
Luflosi
a8f6615380 Fix broken paste on X11
Fixes https://github.com/kovidgoyal/kitty/issues/2008.
2019-09-29 02:48:09 +02:00
Kovid Goyal
97fe38fbbc monotonic_start_time needs to be a global symbol, not local to each translation unit 2019-09-28 08:18:21 +05:30
Kovid Goyal
3378175450 Hopefully the last macOS float conversion fix 2019-09-27 20:14:05 +05:30
Kovid Goyal
9f60d2aea3 More macOS float conversion fixes 2019-09-27 20:11:32 +05:30
Kovid Goyal
46d49e18c0 More macOS float fixes 2019-09-27 20:07:09 +05:30
Kovid Goyal
43fc335be2 more macOS float fixes 2019-09-27 20:05:11 +05:30
Kovid Goyal
f68339c571 float conversion fixes for macOS 2019-09-27 19:56:48 +05:30
Kovid Goyal
0d68b7078c Check for float conversion issues on build
Useful to catch any errors left over from the migration of times from
double to int64_t
2019-09-27 19:47:25 +05:30
Kovid Goyal
2e71dde780 Merge branch 'monotonic_t' of https://github.com/Luflosi/kitty 2019-09-27 19:23:27 +05:30
Kovid Goyal
51ddd584d6 Merge branch 'mark_unicode_data_as_generated' of https://github.com/Luflosi/kitty 2019-09-27 09:21:29 +05:30
Luflosi
4b090259cd Mark kitty/unicode-data.c as being generated 2019-09-26 21:54:42 +02:00
Luflosi
f3b9ff5f9f Use datatype monotonic_t instead of double to keep track of time
The time is stored in a signed 64 bit integer with nanosecond accuracy. This eliminates the possibility of floating-point inaccuracies.
`monotonic_t` can currently hold values large enough to work correctly for more than 200 years into the future.
Using a typedef instead of directly using `int64_t` everywhere will also allow easily changing the datatype in the future should the need arise for more precise or bigger time values.
2019-09-25 17:43:11 +02:00
Kovid Goyal
4ec1a8d9c3 Merge branch 'extract-glfw-key-event-data' of https://github.com/bew/kitty 2019-09-25 15:44:56 +05:30
Kovid Goyal
350cfeb7ef version 0.14.6 2019-09-25 11:28:55 +05:30
Kovid Goyal
97d379b13e Add changelog entry for DPI change PR 2019-09-25 06:34:55 +05:30
Kovid Goyal
2154d555e5 Merge branch 'update_check_interval_constant' of https://github.com/Luflosi/kitty 2019-09-25 06:23:05 +05:30
Luflosi
1389c36657 Use the update CHECK_INTERVAL constant 2019-09-25 02:46:19 +02:00
Kovid Goyal
bd1e7d6942 Merge branch 'master' of https://github.com/dcolascione/kitty 2019-09-25 05:56:17 +05:30
Benoit de Chezelles
aadab38487 Fix compilation for macos 2019-09-24 22:03:55 +02:00
Daniel Colascione
91299a279b Fix window resize on DPI change 2019-09-24 12:41:23 -07:00
Benoit de Chezelles
53275c9137 Extract key event data to struct 2019-09-24 19:15:35 +02:00
Kovid Goyal
fb1c318a09 macOS: Fix a regression in the previous release that caused a crash when pressing a unprintable key, such as the POWER key
Fixes #1997
2019-09-24 16:07:52 +05:30
Kovid Goyal
2a07b3f46a Fix #1995 2019-09-24 06:40:21 +05:30
Kovid Goyal
ffc4e99717 version 0.14.5 2019-09-23 08:41:38 +05:30
Kovid Goyal
fe807dd66f Fix missing parameter name in docs 2019-09-22 19:39:22 +05:30
Kovid Goyal
40ce5db812 Add completion for listen on 2019-09-22 16:08:37 +05:30
Kovid Goyal
649a9f4a6f oops 2019-09-22 16:01:33 +05:30
Kovid Goyal
e17ce875be Complete more CLI args 2019-09-22 16:01:12 +05:30
Kovid Goyal
415701c58a Add completion of filenames for --config 2019-09-22 15:52:45 +05:30
Kovid Goyal
f16f80b459 Merge branch 'glfw_null_unused_params' of https://github.com/Luflosi/kitty 2019-09-20 06:27:13 +05:30
Luflosi
628e6cc87f Mark unused parameters in glfw/null_*.c
kitty didn't compile on FreeBSD for me because of unused parameters in glfw/null_joystick.c, so I added the `UNUSED` attribute to them.
I also added `UNUSED` to the unused parameters in glfw/null_monitor.c and glfw/null_window.c as well even though they are probably not used.
2019-09-19 20:21:09 +02:00
Kovid Goyal
8f9a225c3a Use selection foreground color for underlines as well
Fixes #1982
2019-09-19 19:28:33 +05:30
Kovid Goyal
7b41bc95e1 Merge branch 'move_allocation_failure_check' of https://github.com/Luflosi/kitty 2019-09-19 18:45:42 +05:30
Luflosi
2d06ee5822 Move allocation failure check closer to allocation 2019-09-19 14:58:39 +02:00
Kovid Goyal
40b4fb966f Merge branch 'add_missing_key_name_aliases' of https://github.com/Luflosi/kitty 2019-09-19 05:53:42 +05:30
Luflosi
be696a9d76 Add missing keys to key_name_aliases 2019-09-18 19:36:56 +02:00
Luflosi
1ffe9bef35 Order key_name_aliases by their ASCII value 2019-09-18 16:23:38 +02:00
Luflosi
ed70d95c44 Move aliases for common key name variations to the end of key_name_aliases 2019-09-18 16:23:01 +02:00
Kovid Goyal
49bf876f73 Merge branch 'remove_plus_key_alias' of https://github.com/Luflosi/kitty 2019-09-18 19:45:19 +05:30
Luflosi
e512b4d3e3 Remove PLUS key from key_name_aliases 2019-09-18 16:07:55 +02:00
Kovid Goyal
e78b6c7c7c Merge branch 'faq' of https://github.com/jacwah/kitty 2019-09-18 09:49:09 +05:30
Jacob Wahlgren
a7403c0005 Update FAQ with FreeBSD termcap info
Thanks to amarshall's help:
https://github.com/kovidgoyal/kitty/issues/765#issuecomment-487381289
2019-09-17 22:19:51 +02:00
Kovid Goyal
5bed0dddaa typo 2019-09-15 06:19:27 +05:30
Kovid Goyal
bc302dad23 Linux: Allow using fonts with spacing=90 in addition to fonts with spacing=100
Fixes #1968
2019-09-15 06:08:40 +05:30
Kovid Goyal
41b0f8852f Only update config_key_map with those entries in key_name_aliases that exist in ENCODING 2019-09-15 04:24:32 +05:30
Kovid Goyal
2fadd3e7ba Add a note to the fontconfig FAQ about how to override spacing 2019-09-15 04:09:26 +05:30
Kovid Goyal
dcfd2b8d60 Fix incorrect rendering of some symbols when followed by a space while using the PowerLine font which does not have a space glyph
Fixes #1225
2019-09-14 17:56:52 +05:30
Kovid Goyal
7fe63a7aad Add changelog entry for key mapping PR 2019-09-14 10:20:18 +05:30
Kovid Goyal
67f2ec2421 Merge branch 'keyboard_improvement' of https://github.com/Luflosi/kitty 2019-09-14 10:17:35 +05:30
Kovid Goyal
8e7a23a7b9 Merge branch 'use_OPT' of https://github.com/Luflosi/kitty 2019-09-12 13:43:12 +05:30
Luflosi
8e96a27d51 Use the OPT() macro where possible 2019-09-12 10:02:53 +02:00
Kovid Goyal
b337d4d9d5 Merge branch 'master' of https://github.com/copy/kitty 2019-09-12 07:43:35 +05:30
Fabian
d9404c0362 Fix color index 232 (should be #080808, not black) 2019-09-11 20:01:52 +02:00
Kovid Goyal
e4ba5f449f When resetting the terminal, also reset parser state, this allows easy recovery from incomplete escape codes
Fixes #1961
2019-09-09 20:56:35 +05:30
Kovid Goyal
17fd749e8d Add some aliases when parsing config files for common key name variations 2019-09-08 19:28:41 +05:30
Luflosi
f3be5b5e57 Regenerate automatically generated key_encoding.py and keys.h 2019-09-08 12:32:20 +02:00
Luflosi
e619eb9cbb Add more keyboard keys 2019-09-08 12:32:19 +02:00
Luflosi
a65ee155c5 Indent lookup table in _glfwGetKeyName() to allow for longer keyboard key names 2019-09-08 12:32:19 +02:00
Luflosi
4037480d2b Allow for up to 256 keys instead of 128 2019-09-08 12:32:19 +02:00
Luflosi
97e6978ed8 Order keyboard keys by their ASCII value 2019-09-08 12:32:19 +02:00
Luflosi
f05eefcc20 Allow adding keys with Unicode names on macOS 2019-09-08 12:32:19 +02:00
Luflosi
3f926dfd8b Use keyboard key constants instead of hardcoded values 2019-09-08 12:32:18 +02:00
Luflosi
59f64c5e33 Blacklist GLFW_KEY_LAST_PRINTABLE in kitty/keys.py 2019-09-08 12:32:18 +02:00
Luflosi
87059a2004 Add GLFW_KEY_LAST_PRINTABLE as a GLFW constant 2019-09-08 12:32:18 +02:00
Luflosi
7c52dd2bd8 Fix update_encoding() not filtering GLFW_KEY_LAST_PRINTABLE
b3b830bb5f did not actually make `update_encoding()` filter `GLFW_KEY_LAST_PRINTABLE` because `name` contained the key name after applying `symbolic_name()`, which replaces underscores with spaces. Instead of replacing the underscore in `LAST_PRINTABLE` with a space, I moved the check above the call to `symbolic_name()`. This is more readable and future-proof in my opinion.
2019-09-08 12:32:18 +02:00
Kovid Goyal
70c2765a6e Allow reading session file from STDIN 2019-09-08 15:20:37 +05:30
Kovid Goyal
3618f4d642 Only try to wakeup talk thread if it has been started 2019-09-08 15:12:17 +05:30
Kovid Goyal
698569536d Output which loo could not be woken up 2019-09-08 14:58:11 +05:30
Kovid Goyal
c398d3d16e Cocoa: Fix glfwSetWindowSize anchor point
This makes glfwSetWindowSize use the top-left corner as anchor point
instead of the bottom-left corner.

Upstream: 7f02898264
2019-09-08 09:16:07 +05:30
Kovid Goyal
9dbc54aad6 Fix comparison of video modes of equal area
This fixes the bug of video modes being discarded if they had
a different resolution but the same area as another mode.

Upstream: 2777f6a754
2019-09-08 09:12:39 +05:30
Kovid Goyal
931cb223cd When all visible windows have the same background color, use that as the color for the global padding, instead of the configured background color
See #1957
2019-09-07 18:47:15 +05:30
Kovid Goyal
336ee53fea Merge branch 'joystick-platform' of https://github.com/jamessan/kitty 2019-09-04 08:43:16 +05:30
James McCoy
34350af61c Only use linux_joystick.c on Linux
Rather than using null_joystick.c when _plat is a bsd, use
linux_joystick.c when _plat is a linux.  This fixes a build issue with
other non-BSD, non-Linux platforms.
2019-09-03 23:02:16 -04:00
Kovid Goyal
72f7cb3b7d Merge branch 'format_key_encoding' of https://github.com/Luflosi/kitty 2019-09-02 07:49:30 +05:30
Luflosi
481047a446 Format kitty/key_encoding.py with yapf 2019-09-01 17:53:52 +02:00
Kovid Goyal
3bf1d73b07 Merge branch 'add_glfw_key_last_printable' of https://github.com/Luflosi/kitty 2019-09-01 17:52:39 +05:30
Luflosi
b3b830bb5f Make adding more printable keys slightly easier
When adding keys after `GLFW_KEY_UNDERSCORE`, one now needs to change a `#define` right below the last printable key instead of changing it elsewhere in the code.
This commit now also marks `GLFW_KEY_PLUS` and `GLFW_KEY_UNDERSCORE` as printable characters.
2019-09-01 11:24:14 +02:00
Kovid Goyal
def0c55df3 Merge branch 'add_missing_named_keys' of https://github.com/Luflosi/kitty 2019-09-01 05:43:27 +05:30
Luflosi
b995e00850 Add missing key to named_keys 2019-09-01 02:03:54 +02:00
Kovid Goyal
32dfc94909 Implement a hack to (mostly) preserve tabs when cat a file with them and then copying the text or passing screen contents to another program
It's a simple enough hack that it seems worth doing. If it causes any
issues, can always be reverted.

Fixes #1829
2019-08-31 12:37:05 +05:30
Kovid Goyal
20f7118432 version 0.14.4 2019-08-31 10:20:47 +05:30
Kovid Goyal
37e6c3f0cb Merge branch 'bool_indentation' of https://github.com/Luflosi/kitty 2019-08-30 19:08:46 +05:30
Luflosi
0459dda5c2 Fix bool indentation
The wrong indentation was caused by the removal of GLFWbool in fe62700825.
2019-08-30 15:32:20 +02:00
Kovid Goyal
a10c816c05 Merge branch 'fix_nslog_string_format' of https://github.com/Luflosi/kitty 2019-08-30 18:40:49 +05:30
Luflosi
c0c7cfacc2 Fix NSLog() printing of unicode format strings
See https://stackoverflow.com/questions/720052/nslog-incorrect-encoding.
The `%s` format placeholder for `NSLog()` expects an encoding other than UTF-8, which leads to garbled Unicode characters when trying to print a UTF-8 encoded string.
```Objective-C
NSLog(@"Ä %s %@", "Ä", @("Ä"));
```
prints `Ä √Ñ Ä`.

As can be seen in the example above, the workaround is to convert the UTF-8 encoded C-string to an `NSString` object and print that instead.
`debug_key()` calls `NSLog()`.
2019-08-30 15:03:51 +02:00
Kovid Goyal
8cdb6647ed Merge branch 'fix_update_encoding' of https://github.com/Luflosi/kitty 2019-08-30 16:20:42 +05:30
Luflosi
b68e3c85b9 Add missing MENU key to key_encoding.py 2019-08-30 12:37:23 +02:00
Luflosi
ef25d5bbd5 Fix update_encoding() not adding the last key 2019-08-30 12:36:37 +02:00
Kovid Goyal
278bf6e897 Fix #1937 2019-08-30 15:02:17 +05:30
Kovid Goyal
90a985b73a Make format_text() more secure 2019-08-28 05:41:20 +05:30
Kovid Goyal
b016353809 Some clarifications for the graphics protocol
See discussion on #33
2019-08-28 05:28:05 +05:30
Kovid Goyal
bc222af2e2 When dumping scrollback as ansi, reset SGR formatting at end of scrollback 2019-08-27 19:35:01 +05:30
Kovid Goyal
44599c9460 Merge branch 'simplify_compile_code' of https://github.com/Luflosi/kitty 2019-08-26 20:25:19 +05:30
Luflosi
902fc22670 Simplify GLFW compilation code
This commit removes the need for `is_macos` in `glfw/glfw.py` by moving a few lines of code. Instead of relying on the information that the compilation is or isn't happening on macOS, the code now does the right thing based on which `module` is being built.
This changes the order of the compilation flags slightly.
2019-08-26 16:47:19 +02:00
Kovid Goyal
d84e22fbf1 Merge branch 'fix_typos' of https://github.com/Luflosi/kitty 2019-08-26 16:34:54 +05:30
Luflosi
6cc720a350 Fix typos
Inspired by 4d3ee554b3.
Found using `codespell`.
2019-08-26 12:31:15 +02:00
Kovid Goyal
c905978874 Merge branch 'fix_issue_1924' of https://github.com/s1341/kitty
Fixes #1924
2019-08-26 10:19:50 +05:30
Kovid Goyal
bfe595a8e8 Merge branch '_glfwInputError_format' of https://github.com/Luflosi/kitty 2019-08-26 06:24:02 +05:30
Luflosi
94d56d1a9e Correct indentation for two _glfwInputError() messages
This commit changes the indentation of two error messages to match the indentation in the rest of the code.
2019-08-25 21:29:58 +02:00
s1341
bd3f0b5363 Properly handle all NULL cases 2019-08-25 17:22:06 +03:00
s1341
6fae3545c7 Fix null pointer deref 2019-08-25 16:39:39 +03:00
s1341
297963f6ab Fix issue #1924 by making prev_cell persistent across line_as_ansi calls 2019-08-25 16:25:36 +03:00
Kovid Goyal
a0ceba407e Merge branch 'drag_and_drop_text' of https://github.com/Luflosi/kitty 2019-08-24 08:39:27 +05:30
Kovid Goyal
35fa91fba2 When the OS returns a fallback font that does not actually contain glyphs for the text, do not exhaust the list of fallback fonts
Fixes #1918

Apparently fontconfig does this for Tangut components.
2019-08-24 08:27:54 +05:30
Kovid Goyal
a5d6cd169e Fix piping PNG images into the icat kitten not working
Fixes #1920
2019-08-24 08:04:04 +05:30
Luflosi
06c2263657 macOS: implement drag and drop of text into kitty
Closes #1368.
2019-08-24 01:29:33 +02:00
Kovid Goyal
472c6f6b8d When running kittens, use the colorscheme of the current window rather than the configured colorscheme
Fixes #1906
2019-08-18 18:27:44 +05:30
Kovid Goyal
afcaca85da Merge branch 'hints_regex_doc' of https://github.com/toonn/kitty 2019-08-18 07:41:14 +05:30
Toon Nolten
2575349ec2 Add expected regex syntax to hints kitten docs
The hints kitten's help documentation did not mention what syntax to use
for the regular expressions. I knew much of kitty was implemented in
python so I guessed correctly but not everyone might know this.

I also fixed some double-spaced sentences because most of them are
single-spaced.
2019-08-17 21:27:53 +02:00
Kovid Goyal
77054f688d Workaround for window managers like xmonad that in some circumstances set window size to zero. Fixes #1910 2019-08-17 18:04:08 +05:30
Kovid Goyal
c5cb24378f Merge branch 'fix_macos_show_window_title_in' of https://github.com/Luflosi/kitty 2019-08-14 06:36:25 +05:30
Luflosi
d66123dd14 Fix hiding the window title in macOS
In b5c2163238 I introduced a bug where only the window title of the first OS window would be hidden. This commit fixes that bug.
The bug was caused by the code hiding the window title being in an `if` statement that only executes once.
2019-08-13 21:02:28 +02:00
Kovid Goyal
4ef8f11f9e Merge branch 'add_frameworks_only_once' of https://github.com/Luflosi/kitty 2019-08-11 07:43:36 +05:30
Luflosi
599be7ddc9 Don't add Apple Frameworks twice
These Frameworks are added again a couple lines below in the check for `module == 'cocoa'`.
2019-08-11 02:26:12 +02:00
Kovid Goyal
685497fc8c Fix shaping test 2019-08-10 08:58:02 +05:30
Kovid Goyal
57542fc204 Only disable liga and dlig for nimbus mono 2019-08-10 08:22:36 +05:30
Kovid Goyal
8d9323aec6 Merge branch 'unnecessary_indentation' of https://github.com/Luflosi/kitty 2019-08-09 07:05:26 +05:30
Luflosi
4984a25b19 Remove unnecessary indentation 2019-08-09 03:27:22 +02:00
Kovid Goyal
3bdcb29e01 Merge branch 'trailing_whitespace' of https://github.com/Luflosi/kitty 2019-08-09 06:34:19 +05:30
Luflosi
b9ab8e6348 Remove trailing whitespace 2019-08-08 20:26:20 +02:00
Kovid Goyal
4a851701e9 Fix a regression that broke setting background_opacity via remote control
Fixes #1895
2019-08-07 15:09:04 +05:30
Kovid Goyal
eafd8af937 Merge branch 'glfw_3.4' of https://github.com/Luflosi/kitty 2019-08-03 07:38:14 +05:30
Luflosi
28bb123be8 Update the GLFW version number from 3.3 to 3.4
Closes https://github.com/kovidgoyal/kitty/issues/1884.
From a337c56848.
2019-08-02 11:00:16 -05:00
Kovid Goyal
8e1ed2f8c3 Update unicode data to 12.1 2019-08-02 14:48:18 +05:30
Kovid Goyal
4a0fcb3cff Merge branch 'macos_show_window_title_in' of https://github.com/Luflosi/kitty 2019-08-02 11:51:38 +05:30
Luflosi
b5c2163238 Add option to hide the window title on macOS
Deprecate `macos_show_window_title_in_menubar` and create a new option `macos_show_window_title_in`.
2019-08-02 00:20:43 -05:00
Kovid Goyal
d0ecdfb330 Add a :opt:kitten_alias option that can be used to alias kitten invocation for brevity and to change kitten option defaults globally
See #1879
2019-08-02 10:40:11 +05:30
Kovid Goyal
bdf7d98a36 hints kitten: Allow specifying :option:kitty +kitten hints --program multiple times to run multiple programs
See #1879
2019-08-02 10:03:04 +05:30
Kovid Goyal
e4b0980d15 DRYer 2019-08-02 07:18:42 +05:30
Kovid Goyal
d99c57aeae Merge branch 'open_context_manager' of https://github.com/Luflosi/kitty 2019-08-02 07:14:11 +05:30
Luflosi
5f855ce547 Use context managers to open files
Inspired by d50a6ddc1b.
2019-08-01 13:21:26 -05:00
Kovid Goyal
68f3b6fbeb Fix the decode_hint function to work with an arbitrary alphabet 2019-08-01 19:31:21 +05:30
Kovid Goyal
dc6d14943e Dont use a global variable for the hints alphabet 2019-08-01 19:24:09 +05:30
Kovid Goyal
05f7334db9 hints kitten: Add a :option:kitty +kitten hints --alphabet option to control what alphabets are used for hints
Fixes #1879
2019-08-01 16:25:54 +05:30
Kovid Goyal
cd707e9335 Merge branch 'wait_for_shell' of https://github.com/Luflosi/kitty 2019-08-01 12:56:12 +05:30
Luflosi
505ed5e43b Fix crash when the shell takes too long to start when reading the environment
According to https://docs.python.org/3/library/subprocess.html#subprocess.Popen.wait, `wait()` throws a `TimeoutExpired` exception when the process is not done after the timeout. I noticed this because kitty crashed for me.
The old code looks like it's trying to wait as long as it takes for the process to finish, which is what I implemented.
2019-08-01 02:03:08 -05:00
Kovid Goyal
9dc8bf5f62 Merge branch 'ignore_directories' of https://github.com/Luflosi/kitty 2019-08-01 06:38:34 +05:30
Luflosi
f8098662b6 Explicitly mark directories as such in .gitignore 2019-07-31 15:27:06 -05:00
Kovid Goyal
de7a0e86c4 Merge branch 'ignore_files_only_in_root' of https://github.com/Luflosi/kitty 2019-07-31 20:56:50 +05:30
Luflosi
ca55438fda Ignore several directories and files only in the root of the repo
These directories are always located in the root directory of the repository. Therefore it's better to only ignore these files in this location.
2019-07-31 10:16:19 -05:00
Kovid Goyal
a4b60e7eef Disable the `liga and dlig` OpenType features so that kitty works with "so-called" monospace fonts such as Nimbus Mono that have non-programming ligatures. 2019-07-31 20:02:48 +05:30
Kovid Goyal
5d22e07738 More details on login shell invocation 2019-07-31 12:20:02 +05:30
Kovid Goyal
bdade7e151 Use a new controlling terminal when reading shell environment
This is because some people do things in their rc files based
on checking the name of the controlling terminal.
2019-07-31 11:34:54 +05:30
Kovid Goyal
6958ded4c4 Dont fail to start if running the shell to read the EDITOR env var fails
Fixes #1869
2019-07-31 06:37:17 +05:30
Kovid Goyal
cc06104be6 Create FUNDING.yml
Add links to the various funding sources
2019-07-30 15:07:12 +05:30
Kovid Goyal
059c34c345 Add a version check to the installer on macOS 2019-07-30 15:01:07 +05:30
Kovid Goyal
9cbb726566 Fix #1865 2019-07-30 06:20:54 +05:30
Kovid Goyal
e8b4356a88 Merge branch 'ignore_build_only_in_root' of https://github.com/Luflosi/kitty 2019-07-29 11:37:36 +05:30
Kovid Goyal
634138cd3b Removed unused entry from .gitignore
Fixes #1859

tags is the file generated by ctags
2019-07-29 11:36:46 +05:30
Luflosi
3f6b07de81 Ignore the build directory only in the root of the repo
The `build` directory is always located at the root directory of the repository. Therefore it's better to only ignore `build` in this location.
2019-07-29 00:59:35 -05:00
Kovid Goyal
d218900b57 Remove unused header 2019-07-29 09:45:02 +05:30
Kovid Goyal
cab949a939 Fix building with compilers that dont support __has_include 2019-07-29 09:44:05 +05:30
Kovid Goyal
e350822f5e version 0.14.3 2019-07-29 09:29:50 +05:30
Kovid Goyal
3d6fe93297 DRYer 2019-07-29 09:23:29 +05:30
Kovid Goyal
3a5baf2722 Merge branch 'doc/mapping_shortcuts' of https://github.com/MagicDuck/kitty 2019-07-29 09:13:16 +05:30
Stephan Badragan
cdb472cb56 Adding documentation for how to map shortcuts 2019-07-28 15:53:44 -07:00
Kovid Goyal
e634350e77 Merge branch 'indentation' of https://github.com/Luflosi/kitty 2019-07-28 10:55:49 +05:30
Luflosi
464a6c1441 Fix indentation of bool variables in glfw/egl_context.h
Caused by fe62700825.
2019-07-28 00:23:17 -05:00
Kovid Goyal
d3750b2244 Merge branch 'glfw_reduce_difference' of https://github.com/Luflosi/kitty 2019-07-28 10:48:22 +05:30
Luflosi
b8d2b76ee4 Reduce the difference of glfw to upstream 2019-07-28 00:10:50 -05:00
Kovid Goyal
14fb7c3201 Merge branch 'glfw_fix_invalid_gamepad_axis_ranges' of https://github.com/Luflosi/kitty 2019-07-27 08:20:02 +05:30
Luflosi
922bc62e0e GLFW: Fix invalid ranges for gamepad axis sources
From 9420e6f0d0.
2019-07-26 13:30:38 -05:00
Kovid Goyal
00cae4ccd1 Merge branch 'indentation' of https://github.com/Luflosi/kitty 2019-07-26 23:00:25 +05:30
Luflosi
61df266df7 Fix indentation of bool variables in glfw/internal.h
Caused by fe62700825.
2019-07-26 11:45:32 -05:00
Kovid Goyal
17751666f2 Merge branch 'glfw_documentation_work' of https://github.com/Luflosi/kitty 2019-07-26 12:04:32 +05:30
Luflosi
961b2c9b65 GLFW: Documentation work
From 3cf7645b96.
2019-07-25 23:07:00 -05:00
Kovid Goyal
eaf6f06047 Merge branch 'remove_empty_line' of https://github.com/Luflosi/kitty 2019-07-26 08:27:57 +05:30
Luflosi
d0ac218c05 Remove empty line 2019-07-25 20:41:08 -05:00
Kovid Goyal
1a01bc15d8 Merge branch 'more_modern_objective-c' of https://github.com/Luflosi/kitty 2019-07-26 06:06:58 +05:30
Luflosi
cdbe2f13ca Cocoa: Move slightly towards modern Objective-C
Inspired by 9a9568212c.
2019-07-25 17:14:32 -05:00
Kovid Goyal
4f5264277e Merge branch 'remove_space' of https://github.com/Luflosi/kitty 2019-07-25 22:12:28 +05:30
Luflosi
bed3adcc95 Remove space from cast in kitty/cocoa_window.m
All the other casts to `NSWindow` in this file have the same formatting.
2019-07-25 11:01:16 -05:00
Kovid Goyal
0c5d59bcf6 Merge branch 'move_dict_iter_define' of https://github.com/Luflosi/kitty 2019-07-25 10:13:58 +05:30
Luflosi
ff20acd8b8 Move #define dict_iter() closer to where it is used 2019-07-24 23:30:40 -05:00
Kovid Goyal
d1cffcde68 Merge branch 'one_less_monotonic' of https://github.com/Luflosi/kitty 2019-07-25 09:45:39 +05:30
Luflosi
546dd9b225 Remove unnecessary call to monotonic()
Assuming the call to `update_drag()` returns basically instantly, this call to `monotonic()` can be safely removed.
2019-07-24 23:12:50 -05:00
Kovid Goyal
2a666620c8 Merge branch 'autoreleasepool_comments' of https://github.com/Luflosi/kitty 2019-07-25 06:04:26 +05:30
Luflosi
db50985040 Format the @autoreleasepool blocks in kitty/cocoa_window.m like in GLFW 2019-07-24 18:03:40 -05:00
Kovid Goyal
8c6d593c41 Merge branch 'rename_cocoa_update_title' of https://github.com/Luflosi/kitty 2019-07-24 11:59:23 +05:30
Luflosi
40086c8d1c Rename cocoa_update_title() -> cocoa_update_menu_bar_title()
I renamed `cocoa_update_title()` to `cocoa_update_menu_bar_title()` since that more accurately reflects what this function actually does.
2019-07-23 15:06:18 -05:00
Kovid Goyal
38f73b9f5e Fix #1832 2019-07-23 13:31:09 +05:30
Kovid Goyal
49429b5f49 When zeroing memory, use type independent code
Reduces the potential for bugs
2019-07-23 10:54:10 +05:30
Kovid Goyal
d9f90ef077 Make qsort invocations type independent 2019-07-23 10:20:41 +05:30
Kovid Goyal
6a126fa18e Fix a crash when displaying very large number of images
Fixes #1825
2019-07-23 10:18:09 +05:30
Kovid Goyal
14d703f5cc Cleanup 2019-07-23 09:44:58 +05:30
Kovid Goyal
9850025f3a Use image ids instead of pointers when removing images since pointer values are changed by the remove operation 2019-07-23 09:40:41 +05:30
Kovid Goyal
8daab0ba41 Change image internal_id type to id_type 2019-07-23 09:34:04 +05:30
Kovid Goyal
88f25ccc76 Also handle non-absolute paths being used for $EDITOR 2019-07-22 10:30:11 +05:30
Kovid Goyal
50e7351c73 When detecting the EDITOR from the environment, if the EDITOR env var is not present, try to read it from the shell's rc files by executing a login shell and dumping its environment
macOS makes it unreasonably hard to set system-wide environment
variables, so this hack might be useful there.
2019-07-22 09:29:55 +05:30
Kovid Goyal
51453a54e4 Merge branch 'remove_wgl_context' of https://github.com/Luflosi/kitty 2019-07-22 06:31:32 +05:30
Luflosi
c02ba03f39 Remove glfw/wgl_context.c and glfw/wgl_context.h 2019-07-21 15:03:39 -05:00
Kovid Goyal
78dec3d698 Merge branch 'fix_assertion' of https://github.com/Luflosi/kitty 2019-07-21 09:54:15 +05:30
Luflosi
1590c59131 Fix assertion for glfwSetGamma value
From 751c6f9a27.
2019-07-20 23:17:58 -05:00
Kovid Goyal
b26f79998a Merge branch 'glfw_c_dialect_reminders' of https://github.com/Luflosi/kitty 2019-07-21 08:33:19 +05:30
Luflosi
489f3e6c9d Add C dialect reminders to each glfw source file
Reduces the difference to upstream.
From 56aad76b16.
2019-07-20 21:07:27 -05:00
Kovid Goyal
5fef4726a7 Cocoa: Fix file-local function not declared static
From upstream: 062a1c22b5
2019-07-20 19:12:21 +05:30
Kovid Goyal
51fdb8200a X11: Fix focus events not being filtered
From upstream: c6b95e3b07
2019-07-20 19:11:00 +05:30
Kovid Goyal
fb0d98ead1 Add more debugs to Wayland handleEvents() 2019-07-20 14:48:28 +05:30
Kovid Goyal
4096caba64 Cancel read if dispatch_pending fails 2019-07-20 14:32:57 +05:30
Kovid Goyal
38f77144fa Wayland: dont abort the event handler early if there are no pending events from the compositor. This ensures that the tick callback and other event sources are dispatched. 2019-07-20 14:09:09 +05:30
Kovid Goyal
b8041ce17f Wayland: Fix infinite loop if the compositor dies 2019-07-20 13:55:38 +05:30
Kovid Goyal
00575733c8 Merge branch 'current_move_events_modifiers' of https://github.com/Luflosi/kitty 2019-07-20 11:33:12 +05:30
Luflosi
621c92780c Get more up-to-date modifiers for mouse move events 2019-07-20 01:00:02 -05:00
Kovid Goyal
37f03af4b7 Merge branch 'glfw_copyright_years' of https://github.com/Luflosi/kitty 2019-07-20 11:14:11 +05:30
Luflosi
bdc4558a43 Update GLFW copyright years
Reduces the difference to upstream.
From ab118b2529.
2019-07-20 00:30:13 -05:00
Kovid Goyal
46d483e8b2 Merge branch 'add_kakoune_editor' of https://github.com/Luflosi/kitty 2019-07-20 08:53:35 +05:30
Luflosi
5143b62a07 Add kakoune to the list of editors 2019-07-20 01:07:10 +02:00
Kovid Goyal
87ed774cb4 Add a new option :opt:pointer_shape_when_grabbed that allows you to control the mouse pointer shape when the terminal programs grabs the pointer
Fixes #1808
2019-07-19 19:34:32 +05:30
Kovid Goyal
4e427d05b7 Fix mouse move events not having modifiers
The lack of modifiers meant that detect of whether the event should be
tracked in kitty was not working
2019-07-19 19:02:09 +05:30
Kovid Goyal
195d987331 Make handle_in_kitty consistent between the button and motion handlers 2019-07-19 18:58:46 +05:30
Kovid Goyal
9b58317fb1 Better fix for kitty not getting key events when launched via a symlink on macOS
Avoids the overhead of checking for a symlink and re-execing.
Apparently all that was needed was setting the correct activation
policy, glfw is supposed to do this but does it only if the menubar hint
is on, which we turn off as we create our own menubar.
2019-07-18 16:00:16 +05:30
Kovid Goyal
1cb15dedac Simplify the event loop code
Also reduce input latency by ignoring repaint_delay when
there is actual pending input.

Gets rid of request_tick_callback(). Now empty events
result in the tick callback being called so there is only a
single mechanism for waking up the main loop and getting
the tick callback called.
2019-07-18 15:51:54 +05:30
Kovid Goyal
5521d6b623 Reset the sigprocmask and signal handlers when launching child processes. Fixes #1806 2019-07-18 09:26:31 +05:30
Kovid Goyal
f5cf6c1dcb Also make the loop flags volatile 2019-07-17 19:55:19 +05:30
Kovid Goyal
89307727e7 Use atomic variables for main loop flags 2019-07-17 19:45:52 +05:30
Kovid Goyal
c30c21b250 Dont sort on mtime
Files are built in order by size anyway and mtime sort makes link order
mtime dependent which breaks reproducible builds on openSUSE as they
modify mtimes randomnly. See #1804
2019-07-16 20:10:14 +05:30
Kovid Goyal
b6fb087d7e sub-sort by filename in find_c_files() 2019-07-16 16:46:48 +05:30
Kovid Goyal
97c2b7c1fe Fix #1804 2019-07-16 07:22:31 +05:30
Kovid Goyal
81506640c8 Run instructions for empty event test 2019-07-15 21:31:31 +05:30
Kovid Goyal
8244f7cd58 Linux: Only process global state when something interesting happens
This matches behavior on macOS. Had initially set the code to process
on every loop tick in an attmept to workaround the issue of the event
loop freezing on X11 until an X event is delivered. However, in light
of #1782 that workaround was incorrect anyway. Better to have similar
behavior across platforms. This also has the advantage of reducing CPU
consumption.

Also add a simple program to test event loop wakeups.
2019-07-15 21:30:00 +05:30
Kovid Goyal
63573d6e26 DRYer 2019-07-15 18:23:17 +05:30
Kovid Goyal
9368f7f670 When using :opt:strip_trailing_spaces do not remove empty lines
Fixes #1802
2019-07-15 17:17:40 +05:30
Kovid Goyal
b7a11035d5 Merge branch 'master' of https://github.com/sterpe/kitty 2019-07-15 09:44:20 +05:30
Steven Richard Terpe
2e1b5e2fa7 Update docs on kitty completion for bash v3.2, etc
See kovidgoyal/kitty#1520
2019-07-14 13:59:03 -07:00
Kovid Goyal
8e5cbafe63 Fix kitty @focus-tab not reporting errors
Fixes #1799
2019-07-14 10:08:44 +05:30
Kovid Goyal
eb006a6688 Indicate if set_active_tab() worked or not 2019-07-14 10:02:33 +05:30
Kovid Goyal
40b9049deb Move the kitty OpenGL API into its own compilation unit 2019-07-12 15:29:48 +05:30
Kovid Goyal
64ffca2d0a Merge branch 'reword_changelog_entry' of https://github.com/Luflosi/kitty 2019-07-12 04:48:04 +05:30
Luflosi
1f4b6d4e9a Update a changelog entry to be more descriptive
I think it is not clear what this entry actually means without the additional explanation.
2019-07-11 19:30:19 +02:00
Kovid Goyal
eb30ba7722 Cocoa: Fix code to shutdown display link for inactive monitors 2019-07-11 22:34:28 +05:30
Kovid Goyal
3e0f4d36bc DRYer 2019-07-11 21:48:45 +05:30
Kovid Goyal
1fb118edee Merge branch 'relative_path_compile' of https://github.com/Luflosi/kitty 2019-07-11 21:45:22 +05:30
Luflosi
ca39634880 Use relative paths when compiling 2019-07-11 16:51:50 +02:00
Kovid Goyal
f8418d68a6 Fully drain the wakeupfd 2019-07-09 18:49:46 +05:30
Kovid Goyal
c0000fb24e Should use an unsigned int for eventfd 2019-07-09 18:42:17 +05:30
Kovid Goyal
c169f7ae83 Retry writing to wakeupfd on EAGAIN as well 2019-07-09 18:40:51 +05:30
Kovid Goyal
7ab5244bf5 ssh kitten: Make argument parsing more like ssh
Fixes #1787
2019-07-09 17:48:43 +05:30
Kovid Goyal
7e36489034 Dont call detect joysticks if support for them has been disabled 2019-07-08 11:18:00 +05:30
Kovid Goyal
d259b12ae7 Micro-optimization: Avoid repeated calls to XQLength 2019-07-08 11:05:04 +05:30
Kovid Goyal
8f8138d9bd Have monotic() return numbers offset from init time 2019-07-08 10:30:06 +05:30
Kovid Goyal
a8668f5fbf Add a separate CI job for linux-package
Should catch issues like #1786 in the future
2019-07-08 07:44:01 +05:30
Kovid Goyal
e00e6bd1c2 Dont print "done" when doing nothing 2019-07-08 07:36:30 +05:30
Kovid Goyal
0fc6c47556 Merge branch 'glad2' of https://github.com/Dav1dde/kitty 2019-07-08 07:31:38 +05:30
Kovid Goyal
d530dccb96 Move docs generation into create_linux_bundle_gunk 2019-07-08 07:26:07 +05:30
Kovid Goyal
37bf0e81d2 Fix #1786 2019-07-08 06:46:16 +05:30
David Herberth
f872f955b0 Replace glad with glad2 2019-07-07 21:10:15 +02:00
Kovid Goyal
003cd0a203 Add a little more event loop debug output 2019-07-07 06:10:59 +05:30
Kovid Goyal
e7173f8145 Linux: Fix a regression in 0.14.0 that caused the event loop to tick continuously, wasting CPU even when idle
Fixes #1782
2019-07-07 05:57:18 +05:30
Kovid Goyal
93af102bec Clean link_commands.json 2019-07-07 04:52:24 +05:30
Kovid Goyal
67f23664c9 Generate Wayland protocol definitions in parallel as well 2019-07-05 20:57:56 +05:30
Kovid Goyal
39f6071c68 macOS: Fix a deadlock with CVDisplayLink
I had added an optimization to not pass messages to
main thread every time the CVDisplayLink timer fired, unless
a render frame for that monitor was actually requested.

However, this optimization is impossible to implement wihtout a deadlock
since CVDisplayLink has its own internal lock that it does not expose.

So I guess macOS users with multiple monitors will simply have to take
the performance hit of useless wakeups sixty times a second for every
extra monitor.

Fixes #1779
2019-07-05 20:16:32 +05:30
Kovid Goyal
edc8878632 Use relative paths for object files 2019-07-05 19:13:34 +05:30
Kovid Goyal
93b62c4dfd Also redo linking if the link command changes 2019-07-05 19:09:10 +05:30
Kovid Goyal
c3e210c80f Less output when building 2019-07-05 18:34:01 +05:30
Kovid Goyal
9a5cc8f650 Mark source names with glfw backend prefix 2019-07-05 18:27:13 +05:30
Kovid Goyal
5e7fbfefe9 Refactor the compilation code
Makes it a bit more efficient. All compiling is done in parallel,
followed by all linking.
2019-07-05 18:13:21 +05:30
Kovid Goyal
29ad6fba22 Linux: Use eventfd rather than a pipe for loop wakeup 2019-07-05 14:54:54 +05:30
Kovid Goyal
c848c3ee0d Use an interrupt-safe close() 2019-07-05 14:39:07 +05:30
Kovid Goyal
547132131a Linux: use signalfd rather than a pipe to handle signals 2019-07-05 14:33:22 +05:30
Kovid Goyal
40186fb54b Restore accidentally removed signal.h include 2019-07-05 12:22:38 +05:30
Kovid Goyal
5dc4e79c8d Move code to handle loop wakeup and signals into its own module 2019-07-05 12:19:37 +05:30
Kovid Goyal
556992a117 Forgot to make the eventfd cloexec and non-blocking 2019-07-05 10:08:15 +05:30
Kovid Goyal
a41ef8d513 Abort if addWatch during initialization of poll data fails 2019-07-05 10:00:39 +05:30
Kovid Goyal
6d96a89328 Linux: Use the more efficient eventfd mechanism to wakeup the event loop 2019-07-05 09:54:24 +05:30
Kovid Goyal
0fb1481038 Move event loop wakeup code into backend_utils 2019-07-05 09:34:51 +05:30
Kovid Goyal
4b77530c65 Store a reference to the glfw window pointer in the NSWindow class as well 2019-07-04 09:56:59 +05:30
Kovid Goyal
cdb493cf50 Couple more MIN/MAX type fixes 2019-07-04 09:15:13 +05:30
Kovid Goyal
c9a574a764 Cocoa: Ensure no callbacks are called on the view even if it is retained after being released
Fixes #1761 (I hope)
2019-07-04 09:03:13 +05:30
Kovid Goyal
bdb633a882 Merge branch 'tabs_to_spaces' of https://github.com/Luflosi/kitty 2019-07-04 08:19:01 +05:30
Luflosi
37aee7133d Convert tabs to spaces 2019-07-03 20:28:40 +02:00
Kovid Goyal
2cfd55f3ce Linux: Use the system "bell" for the terminal bell
Adds libcanberra as a new dependency to play the system sound.
2019-07-03 22:06:47 +05:30
Kovid Goyal
2e8188e89d Add libcanberra to the CI linux image 2019-07-03 20:30:12 +05:30
Kovid Goyal
1e172caea3 - Add an option :opt:terminal_select_modifiers to control which modifiers are used to override mouse selection
Fixes #1774
2019-07-03 10:50:07 +05:30
Kovid Goyal
6866cd0fb8 Document shift selection override behavior 2019-07-03 10:46:16 +05:30
Kovid Goyal
2719926870 Add some documentation on how to get regexes in the hints kitten to match over multiple lines. 2019-07-03 10:45:37 +05:30
Kovid Goyal
406891abcc Merge branch 'move_so_tmp_location' of https://github.com/Luflosi/kitty 2019-07-02 07:04:12 +05:30
Luflosi
4be6e9009a Move temporary location for shared objects into build directory 2019-07-02 01:49:35 +02:00
Kovid Goyal
6a31909557 Make the MIN and MAX macros typesafe 2019-07-01 17:03:47 +05:30
Kovid Goyal
f49f0d19f9 oops 2019-07-01 16:39:02 +05:30
Kovid Goyal
a2407f94e4 Remove unnecessary call to monotonic() 2019-07-01 16:36:29 +05:30
Kovid Goyal
62a0be4a11 Fix #1771 2019-07-01 16:35:35 +05:30
Kovid Goyal
b9029f6c67 Remove unnecessary extra copy 2019-07-01 13:57:16 +05:30
Kovid Goyal
92496f42c9 Try a couple of different header files for the BTN_ includes 2019-07-01 10:48:35 +05:30
Kovid Goyal
841c907efc Build glfw with all warnings enabled 2019-07-01 10:42:07 +05:30
Kovid Goyal
9bc288cd8e ... 2019-07-01 08:49:18 +05:30
Kovid Goyal
2ef0391b08 Convert some declarations to C99 style
From upstream: 0c6b505619
2019-07-01 08:32:47 +05:30
Kovid Goyal
6db768d1a3 Remove unneeded header
Fixes #1768
2019-07-01 06:07:55 +05:30
Kovid Goyal
9b080950a9 Cocoa: Cleanup
This makes the Cocoa _glfwPlatformSetWindowMonitor consistent with its
X11 and Win32 counterparts.

From upstream: 3262c29440
2019-07-01 05:59:32 +05:30
Kovid Goyal
3cd1fef4cb X11: Clean up EWMH feature detection
From upstream: fad9896d38
2019-07-01 05:57:17 +05:30
Kovid Goyal
a491a801bf X11: Let the language initialize XEvent structs
From upstream: 1f508530f0
2019-07-01 05:47:04 +05:30
Kovid Goyal
41ebb72276 Merge branch 'clean_kitty_launcher' of https://github.com/Luflosi/kitty 2019-07-01 05:28:08 +05:30
Luflosi
e4c0e9073e Clean "kitty/launcher" 2019-07-01 01:15:33 +02:00
Kovid Goyal
efad733cc5 DRYer 2019-06-30 18:42:20 +05:30
Kovid Goyal
1fcd6e1811 macOS: Fix finding fallback font for private use unicode symbols not working reliably
Fixes #1650
2019-06-30 18:11:58 +05:30
Kovid Goyal
75d697fa97 Fix #1766 2019-06-30 16:07:45 +05:30
Kovid Goyal
cde69670ba Linux: Fix incorrect scaling for fallback fonts when the font has an underscore that renders out of bounds
The calc_cell_height() function should not use underscore heights when
called in contexts other than cell metrics calculation.

Fixes #1713
2019-06-30 08:51:35 +05:30
Kovid Goyal
0be6c9cb97 Allow passing a `!neighbor` argument to the new_window mapping to open a new window next to the active window
Fixes #1746
2019-06-29 15:13:54 +05:30
Kovid Goyal
8c9d2d3ca2 macOS: Reduce energy consumption when idle by shutting down Apple's display link thread after 30 second of inactivity
Fixes #1763
2019-06-29 14:21:47 +05:30
Kovid Goyal
c84e73d8e6 Add some docs for how the completion system can be extended for a new shell 2019-06-29 07:56:24 +05:30
Kovid Goyal
3fb00f6c70 Re-request render frames if we dont hear back in a quarter of a second
Fixes #1748 (I hope)
2019-06-28 18:26:11 +05:30
Kovid Goyal
86305fdeb3 Use CVDisplayLinkIsRunning() rather than tracking started state since the OS can apparently shutdown the thread on its own in some scenarios 2019-06-28 17:46:59 +05:30
Kovid Goyal
710e146d22 Remove Makefile rule for logo building as the logo is now in git 2019-06-28 17:36:06 +05:30
Kovid Goyal
d5abc84bea Remote control: Add a command kitty @ scroll-window to scroll windows 2019-06-28 17:07:31 +05:30
Kovid Goyal
6f8214c15c Add the generated macOS icons to git
Removes the need for optipng/librsvg when building kitty.
2019-06-28 13:48:09 +05:30
Kovid Goyal
a56475e32f Dont use chdir() in logo/make.py 2019-06-28 13:44:42 +05:30
Kovid Goyal
9dadd91887 Build the kitty logo on CircleCI 2019-06-28 12:07:52 +05:30
Kovid Goyal
df5a73bb35 Dont change dirs when packaging 2019-06-28 12:00:12 +05:30
Kovid Goyal
a50bf59a2c macOS: Use a minimal bundle for the in-source kitty launcher
This should allow the Cocoa UI integration to work when running
kitty as kitty/launcher/kitty

Fixes #1756
2019-06-28 11:20:59 +05:30
Kovid Goyal
241354ae52 Move generation of Info.plist into its own function 2019-06-28 10:47:00 +05:30
Kovid Goyal
c863116011 Merge branch 'strip_once' of https://github.com/Luflosi/kitty 2019-06-27 05:18:04 +05:30
Luflosi
5cbd591a1e .strip() only once
`ans.append('KITTY_VCS_REV="{}"'.format(rev.strip()))` strips the
whitespace again later.
2019-06-26 19:48:58 +02:00
Kovid Goyal
6bb78c9499 Merge branch 'empty_lines' of https://github.com/Luflosi/kitty 2019-06-26 22:34:38 +05:30
Luflosi
893f406a99 Remove empty lines 2019-06-26 17:50:14 +02:00
Kovid Goyal
f722b898b0 Remove hard-coded restriction on drawing borders when only a single window is present
Instead this is controlled by the active layout. Fixes #1750
2019-06-26 19:35:49 +05:30
Kovid Goyal
18335b3eac Merge branch 'unify_compilation_database_access' of https://github.com/Luflosi/kitty 2019-06-26 19:30:30 +05:30
Luflosi
4708b592e2 Unify compilation_database access
`file` and `arguments` are accessed using the square bracket syntax, while `output` is accessed using `.get()`. This commit uses square brackets for all three. This will throw a `KeyError` if `compilation_database` does not have the key, which is the correct behaviour IMO.
2019-06-26 15:16:14 +02:00
Kovid Goyal
7598a2965c Merge branch 'sys_stat.h_macos_only' of https://github.com/Luflosi/kitty 2019-06-26 18:01:04 +05:30
Luflosi
1b59761a19 Only #include <sys/stat.h> on macOS
The `<sys/stat.h>` include in `launcher.c` is only used to check if the executable is a symlink on macOS. Therefore it is not needed on other platforms.
2019-06-26 14:05:35 +02:00
Kovid Goyal
7fd1053e0f Merge branch 'clean_more' of https://github.com/Luflosi/kitty 2019-06-26 08:18:45 +05:30
Luflosi
e178e7f6a5 Clean asan-launcher and kitty-profile 2019-06-25 20:22:23 +02:00
Kovid Goyal
d0bf21ab16 ... 2019-06-25 20:00:58 +05:30
Kovid Goyal
c826965833 Use libdir_name when bundle gunking on linux 2019-06-25 18:47:09 +05:30
Kovid Goyal
a76db39c19 Use a symlink for the in src launcher in a package 2019-06-25 18:37:11 +05:30
Kovid Goyal
323a538bdd Fix #1744 2019-06-25 18:16:00 +05:30
Kovid Goyal
2435feca3b oops 2019-06-25 08:26:19 +05:30
Kovid Goyal
29d059680c Merge branch 'fix_kitty.app_incremental_build' of https://github.com/Luflosi/kitty 2019-06-25 08:14:23 +05:30
Luflosi
aaaf7f9d8b Fix incremental compilation
The macOS specific `package()` code changes the directory. This didn't cause any problems before 9135387cfa since `compile_commands.json` was written to the filesystem before `package()` was called. This is not the case anymore, which results in `compile_commands.json` being written into the `kitty.app` bundle. I fixed the problem by using a context manager to change the direcctory back after `kitty.app` was created.
2019-06-25 02:55:13 +02:00
Kovid Goyal
bc90ce569a Build kitty.app on CI 2019-06-24 18:17:26 +05:30
Kovid Goyal
27f9f1756b Test doc building on macOS 2019-06-24 18:09:06 +05:30
Kovid Goyal
9135387cfa Get rid of the various different launchers
Now there is only one launcher. Which means it can be used to start
kitty with profiling and ASAN in the natural way. The recommended
way to run kitty from source is now:

./kitty/launcher/kitty

The launcher also automatically re-execs to resolve symlinks on macOS.
2019-06-24 17:21:30 +05:30
Kovid Goyal
af3504e05c Ensure that ensure_space() does not leave a NULL pointer 2019-06-24 16:00:45 +05:30
Kovid Goyal
9c9eac9d46 Merge branch 'delete_.dSYM' of https://github.com/Luflosi/kitty 2019-06-24 15:59:30 +05:30
Luflosi
f28383206a Delete *.dSYM directories when cleaning 2019-06-24 10:48:33 +02:00
Kovid Goyal
ba1c093d18 Merge branch 'manual_cleaning' of https://github.com/Luflosi/kitty 2019-06-24 08:36:52 +05:30
Luflosi
3ea3a85694 Never delete any files in the .git directory when cleaning manually
This is how results can be removed from os.walk(), according to https://docs.python.org/3/library/os.html#os.walk.
2019-06-23 21:08:46 +02:00
Luflosi
0e1a423889 Always clean files manually instead of using git
I see a couple problems with using git to determine the files to delete:
- git needs to be installed
- The manual cleaning code is supposed to function correctly, so why not always use it? That way bugs in the manual cleaning code are also more likely to get discovered
- If some files ignored by git should not be deleted, they need to be added to a sort of blacklist. If some files should be deleted by the manual cleanup code, they need to be added to a sort of whitelist. If someone forgets to add files to one of these lists, then not deleting files that should be deleted is better than deleting files that should not be deleted.
2019-06-23 21:08:16 +02:00
Kovid Goyal
3ce68ed53f Merge branch 'dSYM' of https://github.com/Luflosi/kitty 2019-06-23 20:03:07 +05:30
Luflosi
90c10da398 Ignore all *.dSYM directories
Building `kitty-profile` on macOS creates a `kitty-profile.dSYM` directory, that should be ignored, just like `asan-launcher.dSYM`.
2019-06-23 14:18:45 +02:00
Kovid Goyal
630bf28c22 Add examples for how to use OSC codes to change colors 2019-06-23 08:05:19 +05:30
Kovid Goyal
ff89c1d8e4 oops 2019-06-23 07:36:21 +05:30
Kovid Goyal
96703c23c8 Deal with .git being a file when getting the VCS commit hash during building 2019-06-23 07:36:03 +05:30
Kovid Goyal
2b78f5adad Merge branch 'copy_and_paste_error' of https://github.com/Luflosi/kitty 2019-06-23 07:27:22 +05:30
Luflosi
ab7df777eb Fix copy & paste error 2019-06-22 17:52:26 +02:00
Kovid Goyal
adbc694ff8 Merge branch 'non-mutable_default_argument' of https://github.com/Luflosi/kitty 2019-06-22 20:45:12 +05:30
Luflosi
7709cdb12b Make default argument non-mutable
Calling `Env()` without the `ldpaths` parameter after a call with the `ldpaths` parameter, keeps the list from the first call because the argument is mutable. This is probably not what was intended. This commit fixes this issue and also reverts a change to two lines introduced in 091e74d618, which was probably a workaround for this issue.
2019-06-22 16:57:38 +02:00
Kovid Goyal
f6051f73f5 Use SPECIAL_SOURCES for KITTY_VCS_REV
Fixes #1734
2019-06-22 18:54:58 +05:30
Kovid Goyal
d5c2a21cdf Merge branch 'diff_glfw_upstream' of https://github.com/Luflosi/kitty 2019-06-21 19:52:53 +05:30
Luflosi
8ffc841a3a Reduce the difference of glfw/cocoa_* to upstream
This only changes some formatting, whitespace, etc.. There are no
changes to the functionality.
Let me know if you don't like some of those changes.
2019-06-21 15:53:26 +02:00
Kovid Goyal
6c478977bb Merge branch 'missing_space' of https://github.com/Luflosi/kitty 2019-06-21 15:58:59 +05:30
Luflosi
07beb53b37 Add space after "if" 2019-06-21 12:12:13 +02:00
Kovid Goyal
59df1a8647 Merge branch 'diff_glfw_upstream' of https://github.com/Luflosi/kitty 2019-06-21 08:25:34 +05:30
Luflosi
fb98aa650d Reduce the difference of glfw to upstream
This only changes some formatting, whitespace, etc.. There are no
changes to the functionality.
Let me know if you don't like some of those changes.
2019-06-20 21:40:59 +02:00
Kovid Goyal
9981b5a9c6 Update xcode version in macos brew CI build 2019-06-20 06:28:49 +05:30
Kovid Goyal
603533e632 Fix a regression that caused closing an overlay window to focus the previously focused window rather than the underlying window
Fixes #1720
2019-06-17 09:00:47 +05:30
Kovid Goyal
38bc90f724 unicode_input kitten: Fix a regression that broke using indices to select recently used symbols. 2019-06-17 07:11:07 +05:30
Kovid Goyal
721beb9202 More docs for the cell fragment shader 2019-06-14 11:11:43 +05:30
Kovid Goyal
2e99259589 Make it possible to run custom kittens via kitty +kitten
Should help reduce confusion about how kittens work. Fixes #1712
2019-06-14 09:05:03 +05:30
Kovid Goyal
83e6b75872 More helpful error message if user tries to run a custom kitten via kitty +kitten 2019-06-14 08:23:25 +05:30
Kovid Goyal
cf70946f50 ... 2019-06-13 05:08:13 +05:30
Luflosi
f1c36aba83 Reduce the difference of glfw/null_* to upstream
This only changes some formatting, whitespace, etc.. There are no
changes to the functionality.
Let me know if you don't like some of those changes.
2019-06-12 20:45:21 +02:00
Kovid Goyal
2973cf15a4 Dont leak a file descriptor if pthread_create() fails 2019-06-12 21:51:32 +05:30
Kovid Goyal
55969bc3c5 Also set cwd when piping to none 2019-06-12 21:43:13 +05:30
Kovid Goyal
a8504c971a Also set special env for piped child with no input 2019-06-12 21:36:13 +05:30
Kovid Goyal
1644de2083 Use an explicit pipe instead of relying on subprocess.PIPE
Not sure what the lifetime semantics for fds created by subprocess.PIPE
are
2019-06-12 21:31:06 +05:30
Kovid Goyal
dd1fb85f60 When piping data to a child in the pipe command do it in a thread so as not to block the UI
See #1708
2019-06-12 21:03:18 +05:30
Kovid Goyal
b945b19865 Make thread_write() more robust 2019-06-12 20:58:47 +05:30
Kovid Goyal
91bf9f2ec8 Ensure fd is blocking in thread_write() 2019-06-12 20:42:17 +05:30
Kovid Goyal
f151f4c165 Detach the stdin write thread so that it is auto-cleaned up 2019-06-12 20:36:53 +05:30
Kovid Goyal
95b9b2d373 Merge branch 'diff_glfw_upstream' of https://github.com/Luflosi/kitty 2019-06-12 19:40:07 +05:30
Luflosi
8be698681c Reduce the difference of glfw/wl_* to upstream
This only changes some formatting, whitespace, etc.. There are no
changes to the functionality.
Let me know if you don't like some of those changes.
2019-06-12 14:55:56 +02:00
Kovid Goyal
da3e1a3730 Finish documenting commands 2019-06-12 15:30:26 +05:30
Kovid Goyal
29f637c19a Document a couple more commands 2019-06-12 15:14:15 +05:30
Kovid Goyal
3d01565ba7 Document more commands 2019-06-12 15:01:14 +05:30
Kovid Goyal
962291cc8e Document another command 2019-06-12 13:41:46 +05:30
Kovid Goyal
a662dace9c Document a couple more commands 2019-06-12 13:33:12 +05:30
Kovid Goyal
d34e0b325e Document a couple more commands 2019-06-12 13:20:54 +05:30
Kovid Goyal
4c242ec528 Document a couple more commands 2019-06-12 13:17:28 +05:30
Kovid Goyal
658be9405f Document the kitty remote control protocol
Fixes #1646
2019-06-12 13:12:53 +05:30
Kovid Goyal
15e8f6ad8a Another fix to the scissor for rendering the cell area
With a cyan background it becomes apparent that the width/height are one
pixel too small
2019-06-12 10:37:20 +05:30
Kovid Goyal
a5aca35f1c Simplify and document the operation of the cell fragment shader
Also get rid of the unneccessary double bg_alpha followed by divide by
alpha step when rendering interleaved and premult
2019-06-12 10:22:47 +05:30
Kovid Goyal
ae9df1ffac oops 2019-06-12 08:03:10 +05:30
Kovid Goyal
8bf2e098f5 Fix an out of bounds read causing a crash when selecting text with the mouse in the alternate screen mode
Fixes #1578
2019-06-12 07:52:37 +05:30
Kovid Goyal
7091d554b5 Merge branch 'diff_glfw_upstream' of https://github.com/Luflosi/kitty 2019-06-12 05:17:15 +05:30
Luflosi
bada795320 Reduce the difference of glfw/x11_* to glfw upstream
This only changes some formatting, whitespace, etc.. There are no
changes to the functionality.
Let me know if you don't like some of those changes.
2019-06-11 17:57:39 +02:00
Kovid Goyal
7d385849fb Merge branch 'simplify_code' of https://github.com/Luflosi/kitty 2019-06-11 19:42:59 +05:30
Luflosi
78775b7f6b Use "with suppress()" to suppress a python exception 2019-06-11 15:48:27 +02:00
Kovid Goyal
8d21a5b6b3 Fallback on ctypes' find_library to load libxkbcommon 2019-06-11 16:58:57 +05:30
Kovid Goyal
9da095ca50 Fix #1703 2019-06-11 16:54:55 +05:30
Kovid Goyal
0fafc07db0 Fix #1702 2019-06-11 15:30:50 +05:30
Kovid Goyal
65b95999c1 version 0.14.2 2019-06-09 13:40:02 +05:30
Kovid Goyal
056012871f Merge branch 'bash_shebang' of https://github.com/Luflosi/kitty 2019-06-09 08:44:06 +05:30
Luflosi
c7b377080c Use "#!/usr/bin/env bash" shebang instead of "#!/bin/bash"
All python scripts start with `#!/usr/bin/env python3` so I did the same
for a bash script.
2019-06-08 12:57:46 +02:00
Kovid Goyal
47acc9ff2f Get rid of GLFW_(TRUE|FALSE) 2019-06-08 08:14:30 +05:30
Kovid Goyal
fe62700825 Get rid of GLFWbool 2019-06-08 08:12:42 +05:30
Kovid Goyal
6bcab56988 Merge branch 'whitespace' of https://github.com/Luflosi/kitty 2019-06-08 07:18:18 +05:30
Luflosi
fbc4d3e1be Remove extra spaces 2019-06-08 00:48:09 +02:00
Kovid Goyal
c89d1643f4 Merge branch 'typo' of https://github.com/Luflosi/kitty 2019-06-07 16:30:39 +05:30
Luflosi
e2226a1509 Fix typo 2019-06-07 12:26:52 +02:00
Kovid Goyal
656916e0fa Use remove_i_from_array in a few more places
Also simplify the REMOVER macro
2019-06-07 14:25:33 +05:30
Kovid Goyal
4a55eb9e7f typo 2019-06-07 13:53:35 +05:30
Kovid Goyal
9c8cf04a80 Wayland: Don't insert the same monitor twice if the done event for an output is sent twice 2019-06-07 13:38:44 +05:30
Kovid Goyal
e846bc9308 Wayland: Fix crash when enabling disabling monitors on sway
When an output is unregistered, the corresponding monitor object should
be removed from every windows' monitor list

Proper fix for #1696
2019-06-07 12:40:02 +05:30
Kovid Goyal
3c7a71772c Wrap memmove in glfw with a nice safe macro 2019-06-07 10:01:10 +05:30
Kovid Goyal
857a53e80f Dont crash if GLFW gives us obviously erroneous framebuffer sizes
Fixes #1696
2019-06-07 09:28:30 +05:30
Kovid Goyal
84fcabe5cf Allow using the pipe command to send screen and scrollback contents directly to the clipboard
See #1693
2019-06-07 07:47:34 +05:30
Kovid Goyal
9dc410c9fd oops 2019-06-07 07:20:08 +05:30
Kovid Goyal
8ebad06e7e clipboard kitten: Add a --wait-for-completion option to have the kitten wait till copying to clipboard is complete
Fixes #1693
2019-06-07 07:13:15 +05:30
Kovid Goyal
5db1a07f81 Merge branch 'simplify_code' of https://github.com/Luflosi/kitty 2019-06-07 06:21:00 +05:30
Luflosi
48e5c8edb3 Remove unused code
As far as I can tell, these attributes are not used anywhere.
2019-06-06 18:03:48 +02:00
Kovid Goyal
eefc21920e Merge branch 'simplify_code' of https://github.com/Luflosi/kitty 2019-06-06 21:26:24 +05:30
Luflosi
d7dd9c295b Use more specific exception
I think it's better to use `ImportError` here instead of the much more generic `Exception`.
2019-06-06 17:45:37 +02:00
Kovid Goyal
4faf71bd03 Merge branch 'simplify_code' of https://github.com/Luflosi/kitty 2019-06-06 06:22:52 +05:30
Luflosi
2751dbdb94 Fix test_url_at
`lspace_test()` has a parameter called scheme with the default value `http`. It
is called in a nested for loop, but the scheme from the inner for loop is
just ignored.
2019-06-05 18:32:23 +02:00
Kovid Goyal
fe329cb4ab Merge branch 'simplify_code' of https://github.com/Luflosi/kitty 2019-06-05 21:40:15 +05:30
Luflosi
741e719ff8 Remove unused function
Searching for `color_as_vec3` yielded no results in the entire project
but I encourage you to verify that this function is really not used
anywhere.
2019-06-05 18:01:19 +02:00
Kovid Goyal
866bb32046 Merge branch 'simplify_code' of https://github.com/Luflosi/kitty 2019-06-05 21:14:16 +05:30
Luflosi
7f01e758b3 Simplify code
The result from `self.add_os_window()` is overwritten later and not used
between the two assignments, so I removed the first assignment and moved the second
assignment to the line after the call to `self.add_os_window()`.
2019-06-05 17:33:04 +02:00
Kovid Goyal
03003d270e Merge branch 'simplify_code' of https://github.com/Luflosi/kitty 2019-06-05 20:47:11 +05:30
Luflosi
3d313016ba Remove double assignment
The `payload` variable is assigned twice.
Static program analysis FTW!
2019-06-05 17:12:21 +02:00
Kovid Goyal
1292c752a8 Merge branch 'simplify_code' of https://github.com/Luflosi/kitty 2019-06-05 20:35:29 +05:30
Luflosi
4783947135 Remove useless code
As far as I can tell, `.active_window` does absolutely nothing, so I
removed it.
2019-06-05 16:53:32 +02:00
Kovid Goyal
c9045788f5 Merge branch 'chained_comparisons' of https://github.com/Luflosi/kitty 2019-06-05 19:38:24 +05:30
Luflosi
4eed8463b3 Simplify chained comparisions 2019-06-05 15:24:36 +02:00
Kovid Goyal
303711ab8d Wayland: Detect SSD by querying compositor
Much more reliable than checking environment variables. Does
add ~1ms to startup time on Wayland.
2019-06-05 10:37:57 +05:30
Kovid Goyal
98d7fc9f39 Simplify code 2019-06-05 08:26:25 +05:30
Kovid Goyal
c0a96f2087 icat kitten: Fix a regression that broke passing directories to icat
Fixes #1683
2019-06-05 07:36:47 +05:30
Kovid Goyal
c509ecca52 Wayland: Fix resizing the window on a compositor that does not provide server side window decorations, such a GNOME or Weston not working correctly
See #1659
2019-06-04 19:40:00 +05:30
Kovid Goyal
e5d8eb7845 Micro-optimization 2019-06-04 19:28:46 +05:30
Kovid Goyal
277f43aed6 Linux: Disable the Wayland backend on GNOME
GNOME has no support for server side decorations.
Can be controlled by new option linux_display_server.
2019-06-04 19:10:13 +05:30
Kovid Goyal
f1494b64e5 Do not depend on glfw just to parse the config file 2019-06-04 18:02:56 +05:30
Kovid Goyal
6b9c71ec62 ... 2019-06-04 17:24:42 +05:30
Kovid Goyal
d12a4b0a1a Test changing of update_check_interval on the CI server 2019-06-04 14:32:37 +05:30
Kovid Goyal
a75d075dd1 Add an option to control the default update_check_interval when building kitty packages
Fixes #1675
2019-06-04 14:27:28 +05:30
Kovid Goyal
8f8a37bf94 Fix #1678 2019-06-04 14:14:12 +05:30
Kovid Goyal
03f692fed8 Make it clear what pass_selection_to_program does 2019-06-04 13:48:34 +05:30
Kovid Goyal
614416d4b0 Fix positioning of text in the panel kitten 2019-06-03 20:37:36 +05:30
Kovid Goyal
feb851716e Merge branch 'python_beautify' of https://github.com/Luflosi/kitty 2019-06-03 16:18:42 +05:30
Luflosi
2b095f720e Use "with suppress()" to suppress python exceptions
Using
```Python
with suppress(OSError):
    os.remove('somefile.tmp')
```
instead of
```Python
try:
    os.remove('somefile.tmp')
except OSError:
    pass
```
makes the code more compact and more readable IMO.

This pattern was recommended by Raymond Hettinger, a Python Core
Developer in his talk "Transforming Code into Beautiful, Idiomatic Python" at https://www.youtube.com/watch?v=OSGv2VnC0go. The transcript is available at https://github.com/JeffPaine/beautiful_idiomatic_python
2019-06-03 12:27:43 +02:00
Kovid Goyal
d6e750727f Merge branch 'master' of https://github.com/copy/kitty 2019-06-03 08:46:47 +05:30
Fabian
961ff8633d Add align_top_left option to avoid a padding on the top/left 2019-06-02 11:08:09 -05:00
Kovid Goyal
8406d4a8f1 Forgot another print statement
Really should not code when I am busy :)
2019-06-02 20:23:56 +05:30
Kovid Goyal
e25b64ae15 ... 2019-06-02 18:01:32 +05:30
Kovid Goyal
59205a4caf macOS: Fix a regression in the previous release that broke using :kbd:ctrl+shift+tab
Fixes #1671
2019-06-02 17:36:16 +05:30
Kovid Goyal
5001797179 Merge branch 'fix_typo' of https://github.com/Luflosi/kitty 2019-06-02 16:50:02 +05:30
Luflosi
b24dd69067 Fix typo 2019-06-02 11:54:20 +02:00
Kovid Goyal
4f163338dd Allow controlling how multiple selections are handled in the hints kitten
Fixes #1665
2019-06-02 09:23:20 +05:30
Kovid Goyal
1e8f1f8cc6 Ensure trailing space is drawn around tab separator when title is too long to fit
Fix #1668
2019-05-31 17:51:56 +05:30
Kovid Goyal
5c3e2e6877 Add a note for packagers if they want to turn off the update check mechanism 2019-05-31 17:47:53 +05:30
425 changed files with 106719 additions and 74788 deletions

View File

@@ -1,94 +0,0 @@
version: 2
jobs:
lin-sys:
docker:
- image: kovidgoyal/kitty-test:latest
steps:
- checkout
- run: if grep -Inr '\s$' kitty kitty_tests kittens docs *.py *.asciidoc *.rst .gitattributes .gitignore; then echo Trailing whitespace found, aborting.; exit 1; fi
- run: python3 -m flake8 --count .
- run: python3 setup.py build --debug --verbose
- run: python3 test.py
- run: make FAIL_WARN=-W man
- run: make FAIL_WARN=-W html
- run: python3 setup.py linux-package
lin-35:
docker:
- image: kovidgoyal/kitty-test:latest
environment:
CC: gcc
CFLAGS: -funsigned-char
LD_LIBRARY_PATH: /opt/py3.5/lib
ASAN_OPTIONS: leak_check_at_exit=0
steps:
- checkout
- run: /opt/py3.5/bin/python3 setup.py build --debug --verbose --sanitize
- run: ./asan-launcher test.py
lin-37:
docker:
- image: kovidgoyal/kitty-test:latest
environment:
CC: clang
LD_LIBRARY_PATH: /opt/py3.7/lib
ASAN_OPTIONS: leak_check_at_exit=0
steps:
- checkout
- run: /opt/py3.7/bin/python3 setup.py build --debug --verbose --sanitize
- run: ./asan-launcher test.py
lin-bundle:
docker:
- image: kovidgoyal/kitty-test:latest
environment:
ASAN_OPTIONS: leak_check_at_exit=0
steps:
- checkout
- run: echo "export LD_LIBRARY_PATH=$SW/lib" >> $BASH_ENV
- run: echo "export PKG_CONFIG_PATH=$SW/lib/pkgconfig" >> $BASH_ENV
- run: $SW/bin/python3 setup.py build --debug --verbose
- run: $SW/bin/python3 test.py
mac-bundle:
macos:
xcode: "10.1.0"
environment:
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
SW: /Users/Shared/buildbot/sw/sw
steps:
- checkout
- run: mkdir -p $SW
- run: curl https://download.calibre-ebook.com/travis/kitty/osx.tar.xz | tar xJ -C $SW
- run: echo "export PATH=$SW/bin:$PATH" >> $BASH_ENV
- run: python3 setup.py build --debug --verbose
- run: python3 test.py
mac-brew:
macos:
xcode: "10.1.0"
environment:
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
steps:
- checkout
- run: brew bundle
- run: python3 logo/make.py
- run: python3 setup.py build --debug --verbose
- run: python3 test.py
- run: python3 setup.py macos-bundle
workflows:
version: 2
all_jobs:
jobs:
- mac-bundle
- lin-sys
- lin-35
- lin-37
- lin-bundle
- mac-brew

View File

@@ -1,55 +0,0 @@
# When changing this file, go to
# https://cloud.docker.com/repository/docker/kovidgoyal/kitty-test/builds and
# click the "Trigger" button under Automated builds to rebuild
FROM ubuntu:latest
# make Apt non-interactive
ENV DEBIAN_FRONTEND=noninteractive
RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90circleci \
&& echo 'DPkg::Options "--force-confnew";' >> /etc/apt/apt.conf.d/90circleci \
&& echo 'Acquire::Languages "none";' >> /etc/apt/apt.conf.d/90circleci
# System setup
RUN apt-get update && mkdir -p /usr/share/man/man1 && apt-get install -y python3-flake8 python3-pip python3-pil clang git apt locales sudo openssh-client ca-certificates tar gzip parallel net-tools netcat unzip zip bzip2 gnupg curl wget build-essential apt-utils
# Setup circleci user
RUN groupadd --gid 3434 circleci \
&& useradd --uid 3434 --gid circleci --shell /bin/bash --create-home circleci \
&& echo 'circleci ALL=NOPASSWD: ALL' >> /etc/sudoers.d/50-circleci \
&& echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep \
&& echo 'Defaults env_keep += "SW"' >> /etc/sudoers.d/env_keep \
&& echo 'Defaults env_keep += "LANG"' >> /etc/sudoers.d/env_keep
# Set timezone to UTC by default
RUN ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime
# Use unicode
RUN locale-gen en_US.UTF-8 || true
ENV LANG=en_US.UTF-8
# Deps needed for building python
RUN apt-get install -y libreadline-dev zlib1g-dev libssl-dev libbz2-dev libsqlite3-dev libffi-dev
# kitty deps
RUN apt-get install -y libgl1-mesa-dev libxi-dev libxrandr-dev libxinerama-dev libxcursor-dev libxcb-xkb-dev libdbus-1-dev libxkbcommon-dev libharfbuzz-dev libpng-dev libfontconfig-dev libpython3-dev libxkbcommon-x11-dev python3-pygments
# Needed to build kitty docs
RUN pip3 install sphinx
# Install multiple pythons
ADD install-python.py /tmp/install-python.py
RUN python3 /tmp/install-python.py py3.5 https://www.python.org/ftp/python/3.5.6/Python-3.5.6.tar.xz
RUN python3 /tmp/install-python.py py3.7 https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
# Install kitty bundle
ENV SW=/home/circleci/sw
RUN python3 /tmp/install-python.py bundle https://download.calibre-ebook.com/travis/kitty/linux-64.tar.xz
RUN echo SW=$SW >> /etc/environment
# Clean unused files
RUN apt-get clean -y
USER circleci
LABEL com.circleci.preserve-entrypoint=true
ENTRYPOINT sleep 2h

View File

@@ -1,60 +0,0 @@
#!/usr/bin/env python3
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2019, Kovid Goyal <kovid at kovidgoyal.net>
import io
import os
import shlex
import shutil
import subprocess
import sys
import tarfile
from urllib.request import urlopen
PY, URL = sys.argv[1], sys.argv[2]
if PY == 'bundle':
SW = os.environ['SW']
os.mkdir(SW)
os.chdir(SW)
else:
os.chdir('/usr/src')
def run(cmd):
cmd = shlex.split(cmd)
p = subprocess.Popen(cmd)
if p.wait() != 0:
raise SystemExit(p.returncode)
with urlopen(URL) as f:
data = f.read()
with tarfile.open(fileobj=io.BytesIO(data), mode='r:xz') as tf:
tf.extractall()
def replace_in_file(path, src, dest):
with open(path, 'r+') as f:
n = f.read().replace(src, dest)
f.seek(0), f.truncate()
f.write(n)
if PY == 'bundle':
replaced = 0
for dirpath, dirnames, filenames in os.walk(SW):
for f in filenames:
if f.endswith('.pc') or (f.endswith('.py') and f.startswith('_sysconfig')):
replace_in_file(os.path.join(dirpath, f), '/sw/sw', SW)
replaced += 1
if replaced < 2:
raise SystemExit('Failed to replace path to SW in bundle')
else:
src = os.path.abspath(tuple(os.listdir('.'))[0])
os.chdir(src)
run(f'./configure --prefix=/opt/{PY} --enable-shared --with-system-expat --without-ensurepip')
run(f'make -j {os.cpu_count()}')
run('make install')
os.chdir('/')
shutil.rmtree(src)

21
.editorconfig Normal file
View File

@@ -0,0 +1,21 @@
root = true
[*]
indent_style = spaces
indent_size = 4
end_of_line = lf
trim_trailing_whitespace = true
[{Makefile,*.terminfo}]
indent_style = tab
# Autogenerated files with tabs below this line.
[kitty/{unicode-data.c,emoji.h,wcwidth-std.h}]
indent_style = tab
[kittens/unicode_input/names.h]
indent_style = tab
[glfw/wayland-*-protocol.{c,h}]
indent_style = tab

13
.gitattributes vendored
View File

@@ -1,13 +1,20 @@
kitty/wcwidth-std.h linguist-generated=true
kitty/emoji.h linguist-generated=true
kitty/keys.h linguist-generated=true
kitty/charsets.c linguist-generated=true
kitty/key_encoding.py linguist-generated=true
kitty/unicode-data.c
kitty/unicode-data.c linguist-generated=true
kitty/rgb.py linguist-generated=true
kitty/gl-wrapper.* linguist-generated=true
kitty/khrplatform.h linguist-generated=true
kitty/glfw-wrapper.* linguist-generated=true
kitty/parse-graphics-command.h linguist-generated=true
kitty/options/types.py linguist-generated=true
kitty/options/parse.py linguist-generated=true
kitty/options/to-c-generated.h linguist-generated=true
kittens/diff/options/types.py linguist-generated=true
kittens/diff/options/parse.py linguist-generated=true
glfw/*.c linguist-vendored=true
glfw/*.h linguist-vendored=true
kittens/unicode_input/names.h linguist-generated=true
*.py text diff=python
*.m text diff=objc

3
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,3 @@
patreon: kovidgoyal
liberapay: kovidgoyal
custom: https://sw.kovidgoyal.net/kitty/support.html

32
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,32 @@
---
name: Bug report
about: Create a bug report
title: ''
labels: bug
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. XXX
2. YYY
3. ZZZ
4. See error
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Environment details**
```
Press Ctrl+Shift+F6 (cmd+option+, on macOS) in kitty, to copy debug output about kitty and its
configuration to the clipboard and paste it here.
On older versions of kitty, run kitty --debug-config instead
```
**Additional context**
Try to reproduce the problem with `kitty --config NONE` if you cannot then post a minimal kitty.conf that reproduces the problem. If the problem involves interaction with some other terminal program post a minimal config for that program to reproduce the problem as well.

View File

@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

132
.github/workflows/ci.py vendored Normal file
View File

@@ -0,0 +1,132 @@
#!/usr/bin/env python
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
import io
import os
import shlex
import shutil
import subprocess
import sys
import tarfile
from urllib.request import urlopen
is_bundle = os.environ.get('KITTY_BUNDLE') == '1'
is_macos = 'darwin' in sys.platform.lower()
SW = None
def run(*a):
if len(a) == 1:
a = shlex.split(a[0])
print(' '.join(map(shlex.quote, a)))
sys.stdout.flush()
ret = subprocess.Popen(a).wait()
if ret != 0:
raise SystemExit(ret)
def install_deps():
print('Installing kitty dependencies...')
sys.stdout.flush()
if is_macos:
items = (x.strip() for x in open('Brewfile').readlines() if not x.startswith('#'))
run('brew', 'install', *items)
else:
run('sudo apt-get update')
run('sudo apt-get install -y libgl1-mesa-dev libxi-dev libxrandr-dev libxinerama-dev'
' libxcursor-dev libxcb-xkb-dev libdbus-1-dev libxkbcommon-dev libharfbuzz-dev libx11-xcb-dev'
' libpng-dev liblcms2-dev libfontconfig-dev libxkbcommon-x11-dev libcanberra-dev uuid-dev')
if is_bundle:
install_bundle()
else:
if is_macos:
# needed for zlib for pillow, should not be needed after pillow 8.0
os.environ['PKG_CONFIG_PATH'] = '/usr/local/opt/zlib/lib/pkgconfig'
cmd = 'pip3 install Pillow pygments'
if sys.version_info[:2] < (3, 7):
cmd += ' importlib-resources'
run(cmd)
def build_kitty():
python = shutil.which('python3') if is_bundle else sys.executable
cmd = '{} setup.py build --verbose'.format(python)
if os.environ.get('KITTY_SANITIZE') == '1':
cmd += ' --debug --sanitize'
run(cmd)
def test_kitty():
run('./kitty/launcher/kitty +launch test.py')
def package_kitty():
py = 'python3' if is_macos else 'python'
run(py + ' setup.py linux-package --update-check-interval=0 --verbose')
if is_macos:
run('python3 setup.py kitty.app --update-check-interval=0 --verbose')
run('kitty.app/Contents/MacOS/kitty +runpy "from kitty.constants import *; print(kitty_exe())"')
def replace_in_file(path, src, dest):
with open(path, 'r+') as f:
n = f.read().replace(src, dest)
f.seek(0), f.truncate()
f.write(n)
def setup_bundle_env():
global SW
os.environ['SW'] = SW = '/Users/Shared/kitty-build/sw/sw' if is_macos else os.path.join(os.environ['GITHUB_WORKSPACE'], 'sw')
os.environ['PKG_CONFIG_PATH'] = SW + '/lib/pkgconfig'
if is_macos:
os.environ['PATH'] = '{}:{}'.format('/usr/local/opt/sphinx-doc/bin', os.environ['PATH'])
else:
os.environ['LD_LIBRARY_PATH'] = SW + '/lib'
os.environ['PYTHONHOME'] = SW
os.environ['PATH'] = '{}:{}'.format(os.path.join(SW, 'bin'), os.environ['PATH'])
def install_bundle():
cwd = os.getcwd()
os.makedirs(SW)
os.chdir(SW)
with urlopen('https://download.calibre-ebook.com/ci/kitty/{}-64.tar.xz'.format(
'macos' if is_macos else 'linux')) as f:
data = f.read()
with tarfile.open(fileobj=io.BytesIO(data), mode='r:xz') as tf:
tf.extractall()
if not is_macos:
replaced = 0
for dirpath, dirnames, filenames in os.walk('.'):
for f in filenames:
if f.endswith('.pc') or (f.endswith('.py') and f.startswith('_sysconfig')):
replace_in_file(os.path.join(dirpath, f), '/sw/sw', SW)
replaced += 1
if replaced < 2:
raise SystemExit('Failed to replace path to SW in bundle')
os.chdir(cwd)
def main():
if is_bundle:
setup_bundle_env()
else:
if not is_macos and 'pythonLocation' in os.environ:
os.environ['LD_LIBRARY_PATH'] = '{}/lib'.format(os.environ['pythonLocation'])
action = sys.argv[-1]
if action in ('build', 'package'):
install_deps()
if action == 'build':
build_kitty()
elif action == 'package':
package_kitty()
elif action == 'test':
test_kitty()
else:
raise SystemExit('Unknown action: ' + action)
if __name__ == '__main__':
main()

132
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,132 @@
name: CI
on: [push, pull_request]
env:
CI: 'true'
ASAN_OPTIONS: leak_check_at_exit=0
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
jobs:
linux:
name: Linux (python=${{ matrix.pyver }} cc=${{ matrix.cc }} sanitize=${{ matrix.sanitize }})
runs-on: ubuntu-latest
env:
CC: ${{ matrix.cc }}
KITTY_SANITIZE: ${{ matrix.sanitize }}
strategy:
matrix:
python: [a, b, c]
cc: [gcc, clang]
include:
- python: a
pyver: 3.6
sanitize: 0
- python: b
pyver: 3.7
sanitize: 1
- python: c
pyver: 3.8
sanitize: 1
exclude:
- python: a
cc: clang
- python: b
cc: clang
- python: c
cc: gcc
steps:
- name: Checkout source code
uses: actions/checkout@master
with:
fetch-depth: 10
- name: Set up Python ${{ matrix.pyver }}
uses: actions/setup-python@master
with:
python-version: ${{ matrix.pyver }}
- name: Build kitty
run: python .github/workflows/ci.py build
- name: Test kitty
run: python .github/workflows/ci.py test
linux-package:
name: Linux package
runs-on: ubuntu-latest
env:
CFLAGS: -funsigned-char
steps:
- name: Checkout source code
uses: actions/checkout@master
with:
fetch-depth: 10
- name: Test for trailing whitespace
run: if grep -Inr '\s$' kitty kitty_tests kittens docs *.py *.asciidoc *.rst .gitattributes .gitignore; then echo Trailing whitespace found, aborting.; exit 1; fi
- name: Set up Python
uses: actions/setup-python@master
with:
python-version: 3.8
- name: Install build-only deps
run: pip install flake8 mypy types-requests types-docutils sphinx
- name: Run pyflakes
run: python -m flake8 --count .
- name: Build kitty package
run: python .github/workflows/ci.py package
- name: Run mypy
run: python test.py mypy
- name: Build man page
run: make FAIL_WARN=-W man
- name: Build HTML docs
run: make FAIL_WARN=-W html
bundle:
name: Bundle test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
env:
KITTY_BUNDLE: 1
steps:
- name: Checkout source code
uses: actions/checkout@master
with:
fetch-depth: 10
- name: Build kitty
run: which python3 && python3 .github/workflows/ci.py build
- name: Test kitty
run: python3 .github/workflows/ci.py test
brew:
name: macOS Brew
runs-on: macos-latest
steps:
- name: Checkout source code
uses: actions/checkout@master
with:
fetch-depth: 10
- name: Build kitty
run: python3 .github/workflows/ci.py build
- name: Test kitty
run: python3 .github/workflows/ci.py test
- name: Build kitty package
run: python3 .github/workflows/ci.py package

41
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@@ -0,0 +1,41 @@
name: "Code scanning - action"
on:
push:
branches: [master, ]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: '0 22 * * 5'
jobs:
CodeQL-Build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java
- name: Build kitty
run: python3 .github/workflows/ci.py build
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

32
.gitignore vendored
View File

@@ -1,19 +1,21 @@
*.so
*.pyc
*.pyo
tags
build
linux-package
kitty.app
logo/*.iconset
compile_commands.json
glad/out
asan-launcher
asan-launcher.dSYM
kitty-profile
dev
__pycache__
glfw/wayland-*-client-protocol.[ch]
docs/_build
docs/generated
*_stub.pyi
/.dmypy.json
/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/
/.mypy_cache
.DS_Store
bypy/b

View File

@@ -1,6 +1,6 @@
brew 'pkg-config'
brew 'imagemagick'
brew 'optipng'
brew 'librsvg'
brew 'harfbuzz'
brew 'python'
pkg-config
zlib
python
imagemagick
harfbuzz
sphinx-doc

View File

@@ -1,7 +1,7 @@
### Reporting bugs
Please first search existing bug reports (especially closed ones) for a report
that matches your issue.
that matches your issue.
When reporting a bug, provide full details of your environment, that means, at
a minimum, kitty version, OS and OS version, kitty config (ideally a minimal

View File

@@ -1,7 +1,3 @@
To build from source:
To build from source: <https://sw.kovidgoyal.net/kitty/build.html>
https://sw.kovidgoyal.net/kitty/build.html
Pre-built binaries:
https://sw.kovidgoyal.net/kitty/binary.html
Pre-built binaries: <https://sw.kovidgoyal.net/kitty/binary.html>

View File

@@ -1,8 +1,8 @@
ifdef V
VVAL=--verbose
VVAL=--verbose
endif
ifdef VERBOSE
VVAL=--verbose
VVAL=--verbose
endif
all:
@@ -28,12 +28,7 @@ asan:
profile:
python3 setup.py build $(VVAL) --profile
logo/kitty.iconset/icon_256x256.png: logo/kitty.svg logo/make.py
logo/make.py
rendered_logo: logo/kitty.iconset/icon_256x256.png
app: rendered_logo
app:
python3 setup.py kitty.app $(VVAL)
man:

View File

@@ -1,5 +1,14 @@
= kitty - the fast, featureful, GPU based, terminal emulator
= kitty - the fast, feature-rich, cross-platform, GPU based terminal
See https://sw.kovidgoyal.net/kitty
See https://sw.kovidgoyal.net/kitty/[the kitty website].
image:https://circleci.com/gh/kovidgoyal/kitty.svg?style=svg["Build status", link="https://circleci.com/gh/kovidgoyal/kitty"]
image:https://github.com/kovidgoyal/kitty/workflows/CI/badge.svg["Build status", link="https://github.com/kovidgoyal/kitty/actions?query=workflow%3ACI"]
https://sw.kovidgoyal.net/kitty/faq.html[Frequently Asked Questions]
To ask other questions about kitty usage, use either the https://github.com/kovidgoyal/kitty/discussions/[discussions on GitHub] or the
https://www.reddit.com/r/KittyTerminal[Reddit community]
Packaging status in various repositories:
image:https://repology.org/badge/vertical-allrepos/kitty.svg[https://repology.org/project/kitty/versions]

12
SECURITY.md Normal file
View File

@@ -0,0 +1,12 @@
# Security Policy
## Supported Versions
There are no security specific releases of kitty. Security bugs are fixed
and released just like all other bugs.
## Reporting a vulnerability
Preferably send an email to kovid at kovidgoyal.net or open an issue in the
GitHub repository, though the latter means you are disclosing the vulnerability
publicly before it can be fixed.

View File

@@ -2,56 +2,64 @@
# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
import sys
import os
import sys
from typing import List
def icat(args):
from kittens.runner import run_kitten
def icat(args: List[str]) -> None:
from kittens.runner import run_kitten as rk
sys.argv = args
run_kitten('icat')
rk('icat')
def list_fonts(args):
from kitty.fonts.list import main
main(args)
def list_fonts(args: List[str]) -> None:
from kitty.fonts.list import main as list_main
list_main(args)
def remote_control(args):
from kitty.remote_control import main
main(args)
def remote_control(args: List[str]) -> None:
from kitty.remote_control import main as rc_main
rc_main(args)
def runpy(args):
def runpy(args: List[str]) -> None:
sys.argv = ['kitty'] + args[2:]
exec(args[1])
def hold(args):
def hold(args: List[str]) -> None:
import subprocess
import tty
from contextlib import suppress
ret = subprocess.Popen(args[1:]).wait()
sys.stdin.read()
with suppress(BaseException):
print('\n\x1b[1;32mPress any key to exit', end='', flush=True)
with suppress(BaseException):
tty.setraw(sys.stdin.fileno())
sys.stdin.buffer.read(1)
raise SystemExit(ret)
def complete(args):
from kitty.complete import main
main(args[1:], entry_points, namespaced_entry_points)
def complete(args: List[str]) -> None:
from kitty.complete import main as complete_main
complete_main(args[1:], entry_points, namespaced_entry_points)
def launch(args):
def launch(args: List[str]) -> None:
import runpy
sys.argv = args[1:]
exe = args[1]
if exe.startswith(':'):
import shutil
exe = shutil.which(exe[1:])
if not exe:
q = shutil.which(exe[1:])
if not q:
raise SystemExit('{} not found in PATH'.format(args[1][1:]))
exe = q
runpy.run_path(exe, run_name='__main__')
def run_kitten(args):
def run_kitten(args: List[str]) -> None:
try:
kitten = args[1]
except IndexError:
@@ -59,11 +67,19 @@ def run_kitten(args):
list_kittens()
raise SystemExit(1)
sys.argv = args[1:]
from kittens.runner import run_kitten
run_kitten(kitten)
from kittens.runner import run_kitten as rk
rk(kitten)
def namespaced(args):
def edit_config_file(args: List[str]) -> None:
from kitty.cli import create_default_opts
from kitty.fast_data_types import set_options
from kitty.utils import edit_config_file as f
set_options(create_default_opts())
f()
def namespaced(args: List[str]) -> None:
func = namespaced_entry_points[args[1]]
func(args[1:])
@@ -75,6 +91,7 @@ entry_points = {
'runpy': runpy,
'launch': launch,
'kitten': run_kitten,
'edit-config': edit_config_file,
'@': remote_control,
'+': namespaced,
@@ -84,7 +101,7 @@ namespaced_entry_points['hold'] = hold
namespaced_entry_points['complete'] = complete
def setup_openssl_environment():
def setup_openssl_environment() -> None:
# Workaround for Linux distros that have still failed to get their heads
# out of their asses and implement a common location for SSL certificates.
# It's not that hard people, there exists a wonderful tool called the symlink
@@ -92,11 +109,13 @@ def setup_openssl_environment():
if 'SSL_CERT_FILE' not in os.environ and 'SSL_CERT_DIR' not in os.environ:
if os.access('/etc/pki/tls/certs/ca-bundle.crt', os.R_OK):
os.environ['SSL_CERT_FILE'] = '/etc/pki/tls/certs/ca-bundle.crt'
setattr(sys, 'kitty_ssl_env_var', 'SSL_CERT_FILE')
elif os.path.isdir('/etc/ssl/certs'):
os.environ['SSL_CERT_DIR'] = '/etc/ssl/certs'
setattr(sys, 'kitty_ssl_env_var', 'SSL_CERT_DIR')
def main():
def main() -> None:
if getattr(sys, 'frozen', False) and 'darwin' not in sys.platform.lower():
setup_openssl_environment()
first_arg = '' if len(sys.argv) < 2 else sys.argv[1]
@@ -107,8 +126,8 @@ def main():
elif first_arg.startswith('+'):
namespaced(['+', first_arg[1:]] + sys.argv[2:])
else:
from kitty.main import main
main()
from kitty.main import main as kitty_main
kitty_main()
else:
func(sys.argv[1:])

View File

@@ -1,19 +0,0 @@
/*
* asan-launcher.c
* Copyright (C) 2017 Kovid Goyal <kovid at kovidgoyal.net>
*
* Distributed under terms of the GPL3 license.
*/
#include <Python.h>
#define MAX_ARGC 1024
int main(int argc, char *argv[]) {
wchar_t *argvw[MAX_ARGC + 1] = {0};
argvw[0] = L"kitty";
for (int i = 1; i < argc; i++) argvw[i] = Py_DecodeLocale(argv[i], NULL);
int ret = Py_Main(argc, argvw);
for (int i = 1; i < argc; i++) PyMem_RawFree(argvw[i]);
return ret;
}

110
bypy/init_env.py Normal file
View File

@@ -0,0 +1,110 @@
#!/usr/bin/env python
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
import os
import re
import shlex
import shutil
import subprocess
import sys
import tempfile
from contextlib import suppress
from bypy.constants import (
LIBDIR, PREFIX, PYTHON, SRC as KITTY_DIR, ismacos, worker_env
)
from bypy.utils import run_shell, walk
def read_src_file(name):
with open(os.path.join(KITTY_DIR, 'kitty', name), 'rb') as f:
return f.read().decode('utf-8')
def initialize_constants():
kitty_constants = {}
src = read_src_file('constants.py')
nv = re.search(r'Version\((\d+), (\d+), (\d+)\)', src)
kitty_constants['version'] = '%s.%s.%s' % (nv.group(1), nv.group(2), nv.group(3))
kitty_constants['appname'] = re.search(
r'appname: str\s+=\s+(u{0,1})[\'"]([^\'"]+)[\'"]', src
).group(2)
return kitty_constants
def run(*args, **extra_env):
env = os.environ.copy()
env.update(worker_env)
env.update(extra_env)
env['SW'] = PREFIX
env['LD_LIBRARY_PATH'] = LIBDIR
if ismacos:
env['PKGCONFIG_EXE'] = os.path.join(PREFIX, 'bin', 'pkg-config')
cwd = env.pop('cwd', KITTY_DIR)
print(' '.join(map(shlex.quote, args)), flush=True)
return subprocess.call(list(args), env=env, cwd=cwd)
SETUP_CMD = [PYTHON, 'setup.py', '--build-universal-binary']
def build_frozen_launcher(extra_include_dirs):
inc_dirs = [f'--extra-include-dirs={x}' for x in extra_include_dirs]
cmd = SETUP_CMD + ['--prefix', build_frozen_launcher.prefix] + inc_dirs + ['build-frozen-launcher']
if run(*cmd, cwd=build_frozen_launcher.writeable_src_dir) != 0:
print('Building of frozen kitty launcher failed', file=sys.stderr)
os.chdir(KITTY_DIR)
run_shell()
raise SystemExit('Building of kitty launcher failed')
return build_frozen_launcher.writeable_src_dir
def run_tests(kitty_exe):
with tempfile.TemporaryDirectory() as tdir:
env = {
'KITTY_CONFIG_DIRECTORY': os.path.join(tdir, 'conf'),
'KITTY_CACHE_DIRECTORY': os.path.join(tdir, 'cache')
}
[os.mkdir(x) for x in env.values()]
cmd = [kitty_exe, '+runpy', 'from kitty_tests.main import run_tests; run_tests()']
print(*map(shlex.quote, cmd), flush=True)
if subprocess.call(cmd, env=env) != 0:
print('Checking of kitty build failed', file=sys.stderr)
os.chdir(os.path.dirname(kitty_exe))
run_shell()
raise SystemExit('Checking of kitty build failed')
def sanitize_source_folder(path: str) -> None:
for q in walk(path):
if os.path.splitext(q)[1] not in ('.py', '.glsl', '.ttf', '.otf'):
os.unlink(q)
def build_c_extensions(ext_dir, args):
writeable_src_dir = os.path.join(ext_dir, 'src')
build_frozen_launcher.writeable_src_dir = writeable_src_dir
shutil.copytree(
KITTY_DIR, writeable_src_dir, symlinks=True,
ignore=shutil.ignore_patterns('b', 'build', 'dist', '*_commands.json', '*.o', '*.so', '*.dylib', '*.pyd'))
with suppress(FileNotFoundError):
os.unlink(os.path.join(writeable_src_dir, 'kitty', 'launcher', 'kitty'))
cmd = SETUP_CMD + ['macos-freeze' if ismacos else 'linux-freeze']
if args.dont_strip:
cmd.append('--debug')
dest = kitty_constants['appname'] + ('.app' if ismacos else '')
dest = build_frozen_launcher.prefix = os.path.join(ext_dir, dest)
cmd += ['--prefix', dest, '--full']
if run(*cmd, cwd=writeable_src_dir) != 0:
print('Building of kitty package failed', file=sys.stderr)
os.chdir(writeable_src_dir)
run_shell()
raise SystemExit('Building of kitty package failed')
return ext_dir
if __name__ == 'program':
kitty_constants = initialize_constants()

3
bypy/linux.conf Normal file
View File

@@ -0,0 +1,3 @@
image 'https://partner-images.canonical.com/core/xenial/current/ubuntu-xenial-core-cloudimg-{}-root.tar.gz'
deps 'bison flex libxcursor-dev libxrandr-dev libxi-dev libxinerama-dev libgl1-mesa-dev libxcb-xkb-dev libfontconfig1-dev libdbus-1-dev'

229
bypy/linux/__main__.py Normal file
View File

@@ -0,0 +1,229 @@
#!/usr/bin/env python
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
import errno
import os
import shutil
import stat
import subprocess
import tarfile
import time
from bypy.constants import (
OUTPUT_DIR, PREFIX, is64bit, python_major_minor_version
)
from bypy.freeze import (
extract_extension_modules, freeze_python, path_to_freeze_dir
)
from bypy.utils import get_dll_path, mkdtemp, py_compile, walk
j = os.path.join
arch = 'x86_64' if is64bit else 'i686'
self_dir = os.path.dirname(os.path.abspath(__file__))
py_ver = '.'.join(map(str, python_major_minor_version()))
iv = globals()['init_env']
kitty_constants = iv['kitty_constants']
def binary_includes():
return tuple(map(get_dll_path, (
'expat', 'sqlite3', 'ffi', 'z', 'lzma', 'png16', 'lcms2', 'crypt',
'iconv', 'pcre', 'graphite2', 'glib-2.0', 'freetype',
'harfbuzz', 'xkbcommon', 'xkbcommon-x11',
'ncursesw', 'readline', 'brotlicommon', 'brotlienc', 'brotlidec'
))) + (
get_dll_path('bz2', 2), get_dll_path('ssl', 2), get_dll_path('crypto', 2),
get_dll_path('python' + py_ver, 2),
)
class Env:
def __init__(self, package_dir):
self.base = package_dir
self.lib_dir = j(self.base, 'lib')
self.py_dir = j(self.lib_dir, 'python' + py_ver)
os.makedirs(self.py_dir)
self.bin_dir = j(self.base, 'bin')
self.obj_dir = mkdtemp('launchers-')
def ignore_in_lib(base, items, ignored_dirs=None):
ans = []
if ignored_dirs is None:
ignored_dirs = {'.svn', '.bzr', '.git', 'test', 'tests', 'testing'}
for name in items:
path = j(base, name)
if os.path.isdir(path):
if name in ignored_dirs or not os.path.exists(j(path, '__init__.py')):
if name != 'plugins':
ans.append(name)
else:
if name.rpartition('.')[-1] not in ('so', 'py'):
ans.append(name)
return ans
def import_site_packages(srcdir, dest):
if not os.path.exists(dest):
os.mkdir(dest)
for x in os.listdir(srcdir):
ext = x.rpartition('.')[-1]
f = j(srcdir, x)
if ext in ('py', 'so'):
shutil.copy2(f, dest)
elif ext == 'pth' and x != 'setuptools.pth':
for line in open(f):
src = os.path.abspath(j(srcdir, line))
if os.path.exists(src) and os.path.isdir(src):
import_site_packages(src, dest)
elif os.path.exists(j(f, '__init__.py')):
shutil.copytree(f, j(dest, x), ignore=ignore_in_lib)
def copy_libs(env):
print('Copying libs...')
for x in binary_includes():
dest = env.bin_dir if '/bin/' in x else env.lib_dir
shutil.copy2(x, dest)
def copy_python(env):
print('Copying python...')
srcdir = j(PREFIX, 'lib/python' + py_ver)
for x in os.listdir(srcdir):
y = j(srcdir, x)
ext = os.path.splitext(x)[1]
if os.path.isdir(y) and x not in ('test', 'hotshot', 'distutils', 'tkinter', 'turtledemo',
'site-packages', 'idlelib', 'lib2to3', 'dist-packages'):
shutil.copytree(y, j(env.py_dir, x), ignore=ignore_in_lib)
if os.path.isfile(y) and ext in ('.py', '.so'):
shutil.copy2(y, env.py_dir)
srcdir = j(srcdir, 'site-packages')
site_packages_dir = j(env.py_dir, 'site-packages')
import_site_packages(srcdir, site_packages_dir)
pdir = os.path.join(env.lib_dir, 'kitty-extensions')
os.makedirs(pdir, exist_ok=True)
kitty_dir = os.path.join(env.lib_dir, 'kitty')
bases = ('kitty', 'kittens', 'kitty_tests')
for x in bases:
dest = os.path.join(env.py_dir, x)
os.rename(os.path.join(kitty_dir, x), dest)
if x == 'kitty':
shutil.rmtree(os.path.join(dest, 'launcher'))
os.rename(os.path.join(kitty_dir, '__main__.py'), os.path.join(env.py_dir, 'kitty_main.py'))
shutil.rmtree(os.path.join(kitty_dir, '__pycache__'))
print('Extracting extension modules from', env.py_dir, 'to', pdir)
ext_map = extract_extension_modules(env.py_dir, pdir)
shutil.copy(os.path.join(os.path.dirname(self_dir), 'site.py'), os.path.join(env.py_dir, 'site.py'))
for x in bases:
iv['sanitize_source_folder'](os.path.join(env.py_dir, x))
py_compile(env.py_dir)
freeze_python(env.py_dir, pdir, env.obj_dir, ext_map, develop_mode_env_var='KITTY_DEVELOP_FROM', remove_pyc_files=True)
def build_launcher(env):
iv['build_frozen_launcher']([path_to_freeze_dir(), env.obj_dir])
def is_elf(path):
with open(path, 'rb') as f:
return f.read(4) == b'\x7fELF'
def fix_permissions(files):
for path in files:
os.chmod(path, 0o755)
STRIPCMD = ['strip']
def find_binaries(env):
files = {j(env.bin_dir, x) for x in os.listdir(env.bin_dir)} | {
x for x in {
j(os.path.dirname(env.bin_dir), x) for x in os.listdir(env.bin_dir)} if os.path.exists(x)}
for x in walk(env.lib_dir):
x = os.path.realpath(x)
if x not in files and is_elf(x):
files.add(x)
return files
def strip_files(files, argv_max=(256 * 1024)):
""" Strip a list of files """
while files:
cmd = list(STRIPCMD)
pathlen = sum(len(s) + 1 for s in cmd)
while pathlen < argv_max and files:
f = files.pop()
cmd.append(f)
pathlen += len(f) + 1
if len(cmd) > len(STRIPCMD):
all_files = cmd[len(STRIPCMD):]
unwritable_files = tuple(filter(None, (None if os.access(x, os.W_OK) else (x, os.stat(x).st_mode) for x in all_files)))
[os.chmod(x, stat.S_IWRITE | old_mode) for x, old_mode in unwritable_files]
subprocess.check_call(cmd)
[os.chmod(x, old_mode) for x, old_mode in unwritable_files]
def strip_binaries(files):
print('Stripping %d files...' % len(files))
before = sum(os.path.getsize(x) for x in files)
strip_files(files)
after = sum(os.path.getsize(x) for x in files)
print('Stripped %.1f MB' % ((before - after) / (1024 * 1024.)))
def create_tarfile(env, compression_level='9'):
print('Creating archive...')
base = OUTPUT_DIR
try:
shutil.rmtree(base)
except OSError as err:
if err.errno != errno.ENOENT:
raise
os.mkdir(base)
dist = os.path.join(base, '%s-%s-%s.tar' % (kitty_constants['appname'], kitty_constants['version'], arch))
with tarfile.open(dist, mode='w', format=tarfile.PAX_FORMAT) as tf:
cwd = os.getcwd()
os.chdir(env.base)
try:
for x in os.listdir('.'):
tf.add(x)
finally:
os.chdir(cwd)
print('Compressing archive...')
ans = dist.rpartition('.')[0] + '.txz'
start_time = time.time()
subprocess.check_call(['xz', '--threads=0', '-f', '-' + compression_level, dist])
secs = time.time() - start_time
print('Compressed in %d minutes %d seconds' % (secs // 60, secs % 60))
os.rename(dist + '.xz', ans)
print('Archive %s created: %.2f MB' % (
os.path.basename(ans), os.stat(ans).st_size / (1024.**2)))
def main():
args = globals()['args']
ext_dir = globals()['ext_dir']
env = Env(os.path.join(ext_dir, kitty_constants['appname']))
copy_libs(env)
copy_python(env)
build_launcher(env)
files = find_binaries(env)
fix_permissions(files)
if not args.dont_strip:
strip_binaries(files)
if not args.skip_tests:
iv['run_tests'](os.path.join(env.base, 'bin', 'kitty'))
create_tarfile(env, args.compression_level)
if __name__ == '__main__':
main()

8
bypy/macos.conf Normal file
View File

@@ -0,0 +1,8 @@
# Requires installation of XCode 10.3 and Python 3 and
# python3 -m pip install certifi
vm_name 'macos-kitty'
root '/Users/Shared/kitty-build'
python '/usr/local/bin/python3'
universal 'true'
deploy_target '10.14'

478
bypy/macos/__main__.py Normal file
View File

@@ -0,0 +1,478 @@
#!/usr/bin/env python
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
import glob
import json
import os
import shutil
import stat
import subprocess
import sys
import tempfile
import zipfile
from bypy.constants import PREFIX, PYTHON, SW, python_major_minor_version
from bypy.freeze import (
extract_extension_modules, freeze_python, path_to_freeze_dir
)
from bypy.macos_sign import (
codesign, create_entitlements_file, make_certificate_useable, notarize_app,
verify_signature
)
from bypy.utils import (
current_dir, mkdtemp, py_compile, run_shell, timeit, walk
)
iv = globals()['init_env']
kitty_constants = iv['kitty_constants']
self_dir = os.path.dirname(os.path.abspath(__file__))
join = os.path.join
basename = os.path.basename
dirname = os.path.dirname
abspath = os.path.abspath
APPNAME = kitty_constants['appname']
VERSION = kitty_constants['version']
py_ver = '.'.join(map(str, python_major_minor_version()))
def flush(func):
def ff(*args, **kwargs):
sys.stdout.flush()
sys.stderr.flush()
ret = func(*args, **kwargs)
sys.stdout.flush()
sys.stderr.flush()
return ret
return ff
def flipwritable(fn, mode=None):
"""
Flip the writability of a file and return the old mode. Returns None
if the file is already writable.
"""
if os.access(fn, os.W_OK):
return None
old_mode = os.stat(fn).st_mode
os.chmod(fn, stat.S_IWRITE | old_mode)
return old_mode
STRIPCMD = ('/usr/bin/strip', '-x', '-S', '-')
def strip_files(files, argv_max=(256 * 1024)):
"""
Strip a list of files
"""
tostrip = [(fn, flipwritable(fn)) for fn in files if os.path.exists(fn)]
while tostrip:
cmd = list(STRIPCMD)
flips = []
pathlen = sum(len(s) + 1 for s in cmd)
while pathlen < argv_max:
if not tostrip:
break
added, flip = tostrip.pop()
pathlen += len(added) + 1
cmd.append(added)
flips.append((added, flip))
else:
cmd.pop()
tostrip.append(flips.pop())
os.spawnv(os.P_WAIT, cmd[0], cmd)
for args in flips:
flipwritable(*args)
def files_in(folder):
for record in os.walk(folder):
for f in record[-1]:
yield os.path.join(record[0], f)
def expand_dirs(items, exclude=lambda x: x.endswith('.so')):
items = set(items)
dirs = set(x for x in items if os.path.isdir(x))
items.difference_update(dirs)
for x in dirs:
items.update({y for y in files_in(x) if not exclude(y)})
return items
def do_sign(app_dir):
with current_dir(os.path.join(app_dir, 'Contents')):
# Sign all .so files
so_files = {x for x in files_in('.') if x.endswith('.so')}
codesign(so_files)
# Sign everything else in Frameworks
with current_dir('Frameworks'):
fw = set(glob.glob('*.framework'))
codesign(fw)
items = set(os.listdir('.')) - fw
codesign(expand_dirs(items))
# Now sign the main app
codesign(app_dir)
verify_signature(app_dir)
def sign_app(app_dir, notarize):
# Copied from iTerm2: https://github.com/gnachman/iTerm2/blob/master/iTerm2.entitlements
create_entitlements_file({
'com.apple.security.automation.apple-events': True,
'com.apple.security.cs.allow-jit': True,
'com.apple.security.device.audio-input': True,
'com.apple.security.device.camera': True,
'com.apple.security.personal-information.addressbook': True,
'com.apple.security.personal-information.calendars': True,
'com.apple.security.personal-information.location': True,
'com.apple.security.personal-information.photos-library': True,
})
with make_certificate_useable():
do_sign(app_dir)
if notarize:
notarize_app(app_dir)
class Freeze(object):
FID = '@executable_path/../Frameworks'
def __init__(self, build_dir, dont_strip=False, sign_installers=False, notarize=False, skip_tests=False):
self.build_dir = build_dir
self.skip_tests = skip_tests
self.sign_installers = sign_installers
self.notarize = notarize
self.dont_strip = dont_strip
self.contents_dir = join(self.build_dir, 'Contents')
self.resources_dir = join(self.contents_dir, 'Resources')
self.frameworks_dir = join(self.contents_dir, 'Frameworks')
self.to_strip = []
self.warnings = []
self.py_ver = py_ver
self.python_stdlib = join(self.resources_dir, 'Python', 'lib', 'python' + self.py_ver)
self.site_packages = self.python_stdlib # hack to avoid needing to add site-packages to path
self.obj_dir = mkdtemp('launchers-')
self.run()
def run_shell(self):
with current_dir(self.contents_dir):
run_shell()
def run(self):
ret = 0
self.add_python_framework()
self.add_site_packages()
self.add_stdlib()
self.add_misc_libraries()
self.freeze_python()
if not self.dont_strip:
self.strip_files()
if not self.skip_tests:
self.run_tests()
# self.run_shell()
ret = self.makedmg(self.build_dir, APPNAME + '-' + VERSION)
return ret
@flush
def strip_files(self):
print('\nStripping files...')
strip_files(self.to_strip)
@flush
def run_tests(self):
iv['run_tests'](os.path.join(self.contents_dir, 'MacOS', 'kitty'))
@flush
def set_id(self, path_to_lib, new_id):
old_mode = flipwritable(path_to_lib)
subprocess.check_call(
['install_name_tool', '-id', new_id, path_to_lib])
if old_mode is not None:
flipwritable(path_to_lib, old_mode)
@flush
def get_dependencies(self, path_to_lib):
install_name = subprocess.check_output(
['otool', '-D', path_to_lib]).decode('utf-8').splitlines()[-1].strip()
raw = subprocess.check_output(['otool', '-L', path_to_lib]).decode('utf-8')
for line in raw.splitlines():
if 'compatibility' not in line or line.strip().endswith(':'):
continue
idx = line.find('(')
path = line[:idx].strip()
yield path, path == install_name
@flush
def get_local_dependencies(self, path_to_lib):
for x, is_id in self.get_dependencies(path_to_lib):
for y in (PREFIX + '/lib/', PREFIX + '/python/Python.framework/'):
if x.startswith(y):
if y == PREFIX + '/python/Python.framework/':
y = PREFIX + '/python/'
yield x, x[len(y):], is_id
break
@flush
def change_dep(self, old_dep, new_dep, is_id, path_to_lib):
cmd = ['-id', new_dep] if is_id else ['-change', old_dep, new_dep]
subprocess.check_call(['install_name_tool'] + cmd + [path_to_lib])
@flush
def fix_dependencies_in_lib(self, path_to_lib):
self.to_strip.append(path_to_lib)
old_mode = flipwritable(path_to_lib)
for dep, bname, is_id in self.get_local_dependencies(path_to_lib):
ndep = self.FID + '/' + bname
self.change_dep(dep, ndep, is_id, path_to_lib)
ldeps = list(self.get_local_dependencies(path_to_lib))
if ldeps:
print('\nFailed to fix dependencies in', path_to_lib)
print('Remaining local dependencies:', ldeps)
raise SystemExit(1)
if old_mode is not None:
flipwritable(path_to_lib, old_mode)
@flush
def add_python_framework(self):
print('\nAdding Python framework')
src = join(PREFIX + '/python', 'Python.framework')
x = join(self.frameworks_dir, 'Python.framework')
curr = os.path.realpath(join(src, 'Versions', 'Current'))
currd = join(x, 'Versions', basename(curr))
rd = join(currd, 'Resources')
os.makedirs(rd)
shutil.copy2(join(curr, 'Resources', 'Info.plist'), rd)
shutil.copy2(join(curr, 'Python'), currd)
self.set_id(
join(currd, 'Python'),
self.FID + '/Python.framework/Versions/%s/Python' % basename(curr))
# The following is needed for codesign
with current_dir(x):
os.symlink(basename(curr), 'Versions/Current')
for y in ('Python', 'Resources'):
os.symlink('Versions/Current/%s' % y, y)
@flush
def install_dylib(self, path, set_id=True):
shutil.copy2(path, self.frameworks_dir)
if set_id:
self.set_id(
join(self.frameworks_dir, basename(path)),
self.FID + '/' + basename(path))
self.fix_dependencies_in_lib(join(self.frameworks_dir, basename(path)))
@flush
def add_misc_libraries(self):
for x in (
'sqlite3.0',
'z.1',
'harfbuzz.0',
'png16.16',
'lcms2.2',
'crypto.1.1',
'ssl.1.1',
):
print('\nAdding', x)
x = 'lib%s.dylib' % x
src = join(PREFIX, 'lib', x)
shutil.copy2(src, self.frameworks_dir)
dest = join(self.frameworks_dir, x)
self.set_id(dest, self.FID + '/' + x)
self.fix_dependencies_in_lib(dest)
@flush
def add_package_dir(self, x, dest=None):
def ignore(root, files):
ans = []
for y in files:
ext = os.path.splitext(y)[1]
if ext not in ('', '.py', '.so') or \
(not ext and not os.path.isdir(join(root, y))):
ans.append(y)
return ans
if dest is None:
dest = self.site_packages
dest = join(dest, basename(x))
shutil.copytree(x, dest, symlinks=True, ignore=ignore)
for f in walk(dest):
if f.endswith('.so'):
self.fix_dependencies_in_lib(f)
@flush
def add_stdlib(self):
print('\nAdding python stdlib')
src = PREFIX + '/python/Python.framework/Versions/Current/lib/python' + self.py_ver
dest = self.python_stdlib
if not os.path.exists(dest):
os.makedirs(dest)
for x in os.listdir(src):
if x in ('site-packages', 'config', 'test', 'lib2to3', 'lib-tk',
'lib-old', 'idlelib', 'plat-mac', 'plat-darwin',
'site.py', 'distutils', 'turtledemo', 'tkinter'):
continue
x = join(src, x)
if os.path.isdir(x):
self.add_package_dir(x, dest)
elif os.path.splitext(x)[1] in ('.so', '.py'):
shutil.copy2(x, dest)
dest2 = join(dest, basename(x))
if dest2.endswith('.so'):
self.fix_dependencies_in_lib(dest2)
@flush
def freeze_python(self):
print('\nFreezing python')
kitty_dir = join(self.resources_dir, 'kitty')
bases = ('kitty', 'kittens', 'kitty_tests')
for x in bases:
dest = os.path.join(self.python_stdlib, x)
os.rename(os.path.join(kitty_dir, x), dest)
if x == 'kitty':
shutil.rmtree(os.path.join(dest, 'launcher'))
os.rename(os.path.join(kitty_dir, '__main__.py'), os.path.join(self.python_stdlib, 'kitty_main.py'))
shutil.rmtree(os.path.join(kitty_dir, '__pycache__'))
pdir = os.path.join(dirname(self.python_stdlib), 'kitty-extensions')
os.mkdir(pdir)
print('Extracting extension modules from', self.python_stdlib, 'to', pdir)
ext_map = extract_extension_modules(self.python_stdlib, pdir)
shutil.copy(os.path.join(os.path.dirname(self_dir), 'site.py'), os.path.join(self.python_stdlib, 'site.py'))
for x in bases:
iv['sanitize_source_folder'](os.path.join(self.python_stdlib, x))
self.compile_py_modules()
freeze_python(self.python_stdlib, pdir, self.obj_dir, ext_map, develop_mode_env_var='KITTY_DEVELOP_FROM', remove_pyc_files=True)
iv['build_frozen_launcher']([path_to_freeze_dir(), self.obj_dir])
os.rename(join(dirname(self.contents_dir), 'bin', 'kitty'), join(self.contents_dir, 'MacOS', 'kitty'))
shutil.rmtree(join(dirname(self.contents_dir), 'bin'))
self.fix_dependencies_in_lib(join(self.contents_dir, 'MacOS', 'kitty'))
for f in walk(pdir):
if f.endswith('.so') or f.endswith('.dylib'):
self.fix_dependencies_in_lib(f)
@flush
def add_site_packages(self):
print('\nAdding site-packages')
os.makedirs(self.site_packages)
sys_path = json.loads(subprocess.check_output([
PYTHON, '-c', 'import sys, json; json.dump(sys.path, sys.stdout)']))
paths = reversed(tuple(map(abspath, [x for x in sys_path if x.startswith('/') and not x.startswith('/Library/')])))
upaths = []
for x in paths:
if x not in upaths and (x.endswith('.egg') or x.endswith('/site-packages')):
upaths.append(x)
for x in upaths:
print('\t', x)
tdir = None
try:
if not os.path.isdir(x):
zf = zipfile.ZipFile(x)
tdir = tempfile.mkdtemp()
zf.extractall(tdir)
x = tdir
self.add_modules_from_dir(x)
self.add_packages_from_dir(x)
finally:
if tdir is not None:
shutil.rmtree(tdir)
self.remove_bytecode(self.site_packages)
@flush
def add_modules_from_dir(self, src):
for x in glob.glob(join(src, '*.py')) + glob.glob(join(src, '*.so')):
shutil.copy2(x, self.site_packages)
if x.endswith('.so'):
self.fix_dependencies_in_lib(x)
@flush
def add_packages_from_dir(self, src):
for x in os.listdir(src):
x = join(src, x)
if os.path.isdir(x) and os.path.exists(join(x, '__init__.py')):
if self.filter_package(basename(x)):
continue
self.add_package_dir(x)
@flush
def filter_package(self, name):
return name in ('Cython', 'modulegraph', 'macholib', 'py2app',
'bdist_mpkg', 'altgraph')
@flush
def remove_bytecode(self, dest):
for x in os.walk(dest):
root = x[0]
for f in x[-1]:
if os.path.splitext(f) == '.pyc':
os.remove(join(root, f))
@flush
def compile_py_modules(self):
self.remove_bytecode(join(self.resources_dir, 'Python'))
py_compile(join(self.resources_dir, 'Python'))
@flush
def makedmg(self, d, volname, format='ULFO'):
''' Copy a directory d into a dmg named volname '''
print('\nMaking dmg...')
sys.stdout.flush()
destdir = os.path.join(SW, 'dist')
try:
shutil.rmtree(destdir)
except FileNotFoundError:
pass
os.mkdir(destdir)
dmg = os.path.join(destdir, volname + '.dmg')
if os.path.exists(dmg):
os.unlink(dmg)
tdir = tempfile.mkdtemp()
appdir = os.path.join(tdir, os.path.basename(d))
shutil.copytree(d, appdir, symlinks=True)
if self.sign_installers:
with timeit() as times:
sign_app(appdir, self.notarize)
print('Signing completed in %d minutes %d seconds' % tuple(times))
os.symlink('/Applications', os.path.join(tdir, 'Applications'))
size_in_mb = int(
subprocess.check_output(['du', '-s', '-k', tdir]).decode('utf-8')
.split()[0]) / 1024.
cmd = [
'/usr/bin/hdiutil', 'create', '-srcfolder', tdir, '-volname',
volname, '-format', format
]
if 190 < size_in_mb < 250:
# We need -size 255m because of a bug in hdiutil. When the size of
# srcfolder is close to 200MB hdiutil fails with
# diskimages-helper: resize request is above maximum size allowed.
cmd += ['-size', '255m']
print('\nCreating dmg...')
with timeit() as times:
subprocess.check_call(cmd + [dmg])
print('dmg created in %d minutes and %d seconds' % tuple(times))
shutil.rmtree(tdir)
size = os.stat(dmg).st_size / (1024 * 1024.)
print('\nInstaller size: %.2fMB\n' % size)
return dmg
def main():
args = globals()['args']
ext_dir = globals()['ext_dir']
Freeze(
os.path.join(ext_dir, kitty_constants['appname'] + '.app'),
dont_strip=args.dont_strip,
sign_installers=args.sign_installers,
notarize=args.notarize,
skip_tests=args.skip_tests
)
if __name__ == '__main__':
main()

1
bypy/rsync.conf Normal file
View File

@@ -0,0 +1 @@
to_vm_excludes '/build /dist /kitty/launcher/kitty /.build-cache /tags __pycache__ /*_commands.json *.so *.pyd *.pyc'

31
bypy/site.py Normal file
View File

@@ -0,0 +1,31 @@
#!/usr/bin/env python
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
import builtins
import sys
import _sitebuiltins
def set_quit():
eof = 'Ctrl-D (i.e. EOF)'
builtins.quit = _sitebuiltins.Quitter('quit', eof)
builtins.exit = _sitebuiltins.Quitter('exit', eof)
def set_helper():
builtins.help = _sitebuiltins._Helper()
def main():
sys.argv[0] = sys.calibre_basename
set_helper()
set_quit()
mod = __import__(sys.calibre_module, fromlist=[1])
func = getattr(mod, sys.calibre_function)
return func()
if __name__ == '__main__':
main()

285
bypy/sources.json Normal file
View File

@@ -0,0 +1,285 @@
[
{
"name": "zlib",
"unix": {
"filename": "zlib-1.2.11.tar.xz",
"hash": "sha256:4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066",
"urls": ["https://zlib.net/{filename}"]
}
},
{
"name": "bzip2",
"os": "linux",
"unix": {
"filename": "bzip2-1.0.8.tar.gz",
"hash": "sha256:ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269",
"urls": ["https://www.sourceware.org/pub/bzip2/bzip2-latest.tar.gz"]
}
},
{
"name": "pkg-config",
"os": "macos",
"unix": {
"filename": "pkg-config-0.29.2.tar.gz",
"hash": "sha256:6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591",
"urls": ["https://pkg-config.freedesktop.org/releases/{filename}"]
}
},
{
"name": "cmake",
"os": "macos",
"unix": {
"filename": "cmake-3.19.4.tar.gz",
"hash": "sha256:7d0232b9f1c57e8de81f38071ef8203e6820fe7eec8ae46a1df125d88dbcc2e1",
"urls": ["https://cmake.org/files/v3.19/{filename}"]
}
},
{
"name": "expat",
"unix": {
"filename": "expat-2.2.10.tar.bz2",
"hash": "sha256:b2c160f1b60e92da69de8e12333096aeb0c3bf692d41c60794de278af72135a5",
"urls": ["https://github.com/libexpat/libexpat/releases/download/R_2_2_10/{filename}"]
}
},
{
"name": "libxml2",
"os": "linux",
"unix": {
"filename": "libxml2-2.9.10.tar.gz",
"hash": "sha256:aafee193ffb8fe0c82d4afef6ef91972cbaf5feea100edc2f262750611b4be1f",
"urls": ["ftp://xmlsoft.org/libxml2/{filename}"]
}
},
{
"name": "xkbcommon",
"os": "linux",
"unix": {
"filename": "libxkbcommon-1.0.3.tar.xz",
"hash": "sha256:a2202f851e072b84e64a395212cbd976ee18a8ee602008b0bad02a13247dbc52",
"urls": ["http://xkbcommon.org/download/{filename}"]
}
},
{
"name": "sqlite",
"unix": {
"filename": "sqlite-autoconf-3340100.tar.gz",
"hash": "sha256:2a3bca581117b3b88e5361d0ef3803ba6d8da604b1c1a47d902ef785c1b53e89",
"urls": ["https://www.sqlite.org/2021/{filename}"]
}
},
{
"name": "libffi",
"os": "linux",
"unix": {
"filename": "libffi-3.3.0.tar.gz",
"hash": "sha256:72fba7922703ddfa7a028d513ac15a85c8d54c8d67f55fa5a4802885dc652056",
"urls": ["https://github.com/libffi/libffi/releases/download/v3.3/libffi-3.3.tar.gz"]
}
},
{
"name": "openssl",
"unix": {
"filename": "openssl-1.1.1i.tar.gz",
"hash": "sha256:e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242",
"urls": ["https://www.openssl.org/source/{filename}"]
}
},
{
"name": "ncurses",
"os": "linux",
"unix": {
"filename": "ncurses-6.2.tar.gz",
"hash": "sha256:30306e0c76e0f9f1f0de987cf1c82a5c21e1ce6568b9227f7da5b71cbea86c9d",
"urls": ["https://invisible-mirror.net/archives/ncurses/{filename}"]
}
},
{
"name": "readline",
"os": "linux",
"unix": {
"filename": "readline-8.1.tar.gz",
"hash": "sha256:f8ceb4ee131e3232226a17f51b164afc46cd0b9e6cef344be87c65962cb82b02",
"urls": ["http://ftp.gnu.org/gnu/readline/{filename}"]
}
},
{
"name": "xz",
"unix": {
"filename": "xz-5.2.5.tar.gz",
"hash": "sha256:f6f4910fd033078738bd82bfba4f49219d03b17eb0794eb91efbae419f4aba10",
"urls": ["https://tukaani.org/xz/{filename}"]
}
},
{
"name": "xcrypt",
"os": "linux",
"unix": {
"filename": "xcrypt-4.4.17.tar.gz",
"hash": "sha256:7665168d0409574a03f7b484682e68334764c29c21ca5df438955a381384ca07",
"urls": ["https://github.com/besser82/libxcrypt/archive/v4.4.17.tar.gz"]
}
},
{
"name": "python",
"unix": {
"filename": "Python-3.9.4.tar.xz",
"hash": "sha256:4b0e6644a76f8df864ae24ac500a51bbf68bd098f6a173e27d3b61cdca9aa134",
"urls": ["https://www.python.org/ftp/python/3.9.4/{filename}"]
}
},
{
"name": "setuptools",
"unix": {
"filename": "setuptools-53.0.0.tar.gz",
"hash": "sha256:1b18ef17d74ba97ac9c0e4b4265f123f07a8ae85d9cd093949fa056d3eeeead5",
"urls": ["pypi"]
}
},
{
"name": "pygments",
"unix": {
"filename": "Pygments-2.7.4.tar.gz",
"hash": "sha256:df49d09b498e83c1a73128295860250b0b7edd4c723a32e9bc0d295c7c2ec337",
"urls": ["pypi"]
}
},
{
"name": "libpng",
"unix": {
"filename": "libpng-1.6.37.tar.xz",
"hash": "sha256:505e70834d35383537b6491e7ae8641f1a4bed1876dbfe361201fc80868d88ca",
"urls": ["http://downloads.sourceforge.net/sourceforge/libpng/{filename}"]
}
},
{
"name": "lcms2",
"unix": {
"filename": "lcms2-2.12.tar.gz",
"hash": "sha256:e501f1482fc424550ef3abbf86bf1c66090e1661249e89552d39ed5bf935df66",
"urls": ["https://github.com/mm2/Little-CMS/archive/2.12/{filename}"]
}
},
{
"name": "graphite",
"os": "linux",
"unix": {
"filename": "graphite2-1.3.14.tgz",
"hash": "sha256:f99d1c13aa5fa296898a181dff9b82fb25f6cc0933dbaa7a475d8109bd54209d",
"urls": ["http://downloads.sourceforge.net/silgraphite/{filename}"]
}
},
{
"name": "pcre",
"os": "linux",
"unix": {
"filename": "pcre-8.44.tar.bz2",
"hash": "sha256:19108658b23b3ec5058edc9f66ac545ea19f9537234be1ec62b714c84399366d",
"urls": ["https://ftp.pcre.org/pub/pcre/{filename}"]
}
},
{
"name": "iconv",
"os": "linux",
"unix": {
"filename": "libiconv-1.16.tar.gz",
"hash": "sha256:e6a1b1b589654277ee790cce3734f07876ac4ccfaecbee8afa0b649cf529cc04",
"urls": ["https://ftp.gnu.org/pub/gnu/libiconv/{filename}"]
}
},
{
"name": "glib",
"os": "linux",
"unix": {
"filename": "glib-2.66.6.tar.xz",
"hash": "sha256:80fff9c63d2725834328071c42003c311f77f91caf2285195c587c62f5638329",
"urls": ["https://ftp.gnome.org/pub/GNOME/sources/glib/2.66/{filename}"]
}
},
{
"name": "brotli",
"os": "linux",
"unix": {
"filename": "brotli-1.0.9.tar.gz",
"hash": "sha256:f9e8d81d0405ba66d181529af42a3354f838c939095ff99930da6aa9cdf6fe46",
"urls": ["https://github.com/google/brotli/archive/v1.0.9/{filename}"]
}
},
{
"name": "freetype",
"os": "linux",
"unix": {
"filename": "freetype-2.10.4.tar.xz",
"hash": "sha256:86a854d8905b19698bbc8f23b860bc104246ce4854dcea8e3b0fb21284f75784",
"urls": ["https://download.savannah.gnu.org/releases/freetype/{filename}"]
}
},
{
"name": "fontconfig",
"os": "linux",
"unix": {
"filename": "fontconfig-2.13.1.tar.bz2",
"hash": "sha256:f655dd2a986d7aa97e052261b36aa67b0a64989496361eca8d604e6414006741",
"urls": ["http://www.fontconfig.org/release/{filename}"]
}
},
{
"name": "harfbuzz",
"unix": {
"filename": "harfbuzz-2.7.4.tar.xz",
"hash": "sha256:6ad11d653347bd25d8317589df4e431a2de372c0cf9be3543368e07ec23bb8e7",
"urls": ["https://github.com/harfbuzz/harfbuzz/releases/download/2.7.4/{filename}"]
}
},
{
"name": "wayland",
"os": "linux",
"unix": {
"filename": "wayland-1.19.0.tar.xz",
"hash": "sha256:baccd902300d354581cd5ad3cc49daa4921d55fb416a5883e218750fef166d15",
"urls": ["https://wayland.freedesktop.org/releases/{filename}"]
}
},
{
"name": "wayland-protocols",
"os": "linux",
"unix": {
"filename": "wayland-protocols-1.20.tar.xz",
"hash": "sha256:9782b7a1a863d82d7c92478497d13c758f52e7da4f197aa16443f73de77e4de7",
"urls": ["https://wayland.freedesktop.org/releases/{filename}"]
}
}
]

View File

@@ -1,2 +1,30 @@
#!/bin/bash
cloc --exclude-list-file <(echo -e 'kitty/wcwidth-std.h\nkitty/glfw.c\nkitty/keys.h\nkitty/charsets.c\nkitty/unicode-data.c\nkitty/key_encoding.py\nkitty/rgb.py\nkitty/gl.h\nkitty/gl-wrapper.h\nkitty/gl-wrapper.c\nkitty/khrplatform.h\nkitty/glfw-wrapper.h\nkitty/glfw-wrapper.c\nkitty/emoji.h\nkittens/unicode_input/names.h') kitty kittens
#!/usr/bin/env python
import subprocess
files_to_exclude = '''\
kitty/wcwidth-std.h
kitty/charsets.c
kitty/unicode-data.c
kitty/key_encoding.py
kitty/rgb.py
kitty/gl.h
kitty/gl-wrapper.h
kitty/gl-wrapper.c
kitty/glfw-wrapper.h
kitty/glfw-wrapper.c
kitty/emoji.h
kittens/unicode_input/names.h
kitty/parse-graphics-command.h
kitty/options/types.py
kitty/options/parse.py
kitty/options/to-c-generated.h
kittens/diff/options/types.py
kittens/diff/options/parse.py
'''
p = subprocess.Popen([
'cloc', '--exclude-list-file', '/dev/stdin', 'kitty', 'kittens'
], stdin=subprocess.PIPE)
p.communicate(files_to_exclude.encode('utf-8'))
raise SystemExit(p.wait())

View File

@@ -21,6 +21,10 @@ div.body p, div.body dd, div.body li, div.body blockquote {
text-align: justify;
}
div.body {
min-width: 200px;
}
pre {
white-space: pre-wrap;
}
@@ -78,6 +82,8 @@ body div.document {
div.sphinxsidebar {
font-size: inherit;
line-height: inherit;
max-height: 100%;
overflow-y: auto;
}
#sidebartoc li {

128
docs/basic.rst Normal file
View File

@@ -0,0 +1,128 @@
Tabs and Windows
-------------------
|kitty| is capable of running multiple programs organized into tabs and
windows. The top level of organization is the *Tab*. Each tab consists
of one or more *windows*. The windows can be arranged in multiple
different layouts, like windows are organized in a tiling window
manager. The keyboard controls (which are all customizable) for tabs and
windows are:
Scrolling
~~~~~~~~~~~~~~
======================== =======================
Action Shortcut
======================== =======================
Scroll line up :sc:`scroll_line_up` (also :kbd:`⌥+⌘+⇞` and :kbd:`⌘+↑` on macOS)
Scroll line down :sc:`scroll_line_down` (also :kbd:`⌥+⌘+⇟` and :kbd:`⌘+↓` on macOS)
Scroll page up :sc:`scroll_page_up` (also :kbd:`⌘+⇞` on macOS)
Scroll page down :sc:`scroll_page_down` (also :kbd:`⌘+⇟` on macOS)
Scroll to top :sc:`scroll_home` (also :kbd:`⌘+↖` on macOS)
Scroll to bottom :sc:`scroll_end` (also :kbd:`⌘+↘` on macOS)
======================== =======================
Tabs
~~~~~~~~~~~
======================== =======================
Action Shortcut
======================== =======================
New tab :sc:`new_tab` (also :kbd:`⌘+t` on macOS)
Close tab :sc:`close_tab` (also :kbd:`⌘+w` on macOS)
Next tab :sc:`next_tab` (also :kbd:`^+⇥` and :kbd:`⇧+⌘+]` on macOS)
Previous tab :sc:`previous_tab` (also :kbd:`⇧+^+⇥` and :kbd:`⇧+⌘+[` on macOS)
Next layout :sc:`next_layout`
Move tab forward :sc:`move_tab_forward`
Move tab backward :sc:`move_tab_backward`
Set tab title :sc:`set_tab_title` (also :kbd:`⇧+⌘+i` on macOS)
======================== =======================
Windows
~~~~~~~~~~~~~~~~~~
======================== =======================
Action Shortcut
======================== =======================
New window :sc:`new_window` (also :kbd:`⌘+↩` on macOS)
New OS window :sc:`new_os_window` (also :kbd:`⌘+n` on macOS)
Close window :sc:`close_window` (also :kbd:`⇧+⌘+d` on macOS)
Next window :sc:`next_window`
Previous window :sc:`previous_window`
Move window forward :sc:`move_window_forward`
Move window backward :sc:`move_window_backward`
Move window to top :sc:`move_window_to_top`
Focus specific window :sc:`first_window`, :sc:`second_window` ... :sc:`tenth_window`
(also :kbd:`⌘+1`, :kbd:`⌘+2` ... :kbd:`⌘+9` on macOS)
(clockwise from the top-left)
======================== =======================
Additionally, you can define shortcuts in :file:`kitty.conf` to focus neighboring
windows and move windows around (similar to window movement in vim)::
map ctrl+left neighboring_window left
map shift+left move_window right
map ctrl+down neighboring_window down
map shift+down move_window up
...
You can also define a shortcut to switch to the previously active window::
map ctrl+p nth_window -1
``nth_window`` will focus the nth window for positive numbers and the
previously active windows for negative numbers.
.. _detach_window:
You can define shortcuts to detach the current window and
move it to another tab or another OS window::
# moves the window into a new OS window
map ctrl+f2 detach_window
# moves the window into a new Tab
map ctrl+f3 detach_window new-tab
# asks which tab to move the window into
map ctrl+f4 detach_window ask
Similarly, you can detach the current tab, with::
# moves the tab into a new OS window
map ctrl+f2 detach_tab
# asks which OS Window to move the tab into
map ctrl+f4 detach_tab ask
Finally, you can define a shortcut to close all windows in a tab other than
the currently active window::
map f9 close_other_windows_in_tab
Other keyboard shortcuts
----------------------------------
================================== =======================
Action Shortcut
================================== =======================
Copy to clipboard :sc:`copy_to_clipboard` (also :kbd:`⌘+c` on macOS)
Paste from clipboard :sc:`paste_from_clipboard` (also :kbd:`⌘+v` on macOS)
Paste from selection :sc:`paste_from_selection`
Increase font size :sc:`increase_font_size` (also :kbd:`⌘++` on macOS)
Decrease font size :sc:`decrease_font_size` (also :kbd:`⌘+-` on macOS)
Restore font size :sc:`reset_font_size` (also :kbd:`⌘+0` on macOS)
Toggle fullscreen :sc:`toggle_fullscreen` (also :kbd:`^+⌘+f` on macOS)
Toggle maximized :sc:`toggle_maximized`
Input unicode character :sc:`input_unicode_character` (also :kbd:`^+⌘+space` on macOS)
Click URL using the keyboard :sc:`open_url`
Reset the terminal :sc:`reset_terminal`
Reload :file:`kitty.conf` :sc:`reload_config_file` (also :kbd:`^+⌘+f5` on macOS)
Debug :file:`kitty.conf` :sc:`debug_config` (also :kbd:`⌘+option+f6` on macOS)
Pass current selection to program :sc:`pass_selection_to_program`
Edit |kitty| config file :sc:`edit_config_file`
Open a |kitty| shell :sc:`kitty_shell`
Increase background opacity :sc:`increase_background_opacity`
Decrease background opacity :sc:`decrease_background_opacity`
Full background opacity :sc:`full_background_opacity`
Reset background opacity :sc:`reset_background_opacity`
================================== =======================

View File

@@ -44,10 +44,17 @@ particular desktop, but it should work for most major desktop environments.
# your PATH)
ln -s ~/.local/kitty.app/bin/kitty ~/.local/bin/
# Place the kitty.desktop file somewhere it can be found by the OS
cp ~/.local/kitty.app/share/applications/kitty.desktop ~/.local/share/applications
cp ~/.local/kitty.app/share/applications/kitty.desktop ~/.local/share/applications/
# Update the path to the kitty icon in the kitty.desktop file
sed -i "s/Icon\=kitty/Icon\=\/home\/$USER\/.local\/kitty.app\/share\/icons\/hicolor\/256x256\/apps\/kitty.png/g" ~/.local/share/applications/kitty.desktop
sed -i "s|Icon=kitty|Icon=/home/$USER/.local/kitty.app/share/icons/hicolor/256x256/apps/kitty.png|g" ~/.local/share/applications/kitty.desktop
.. note::
If you use the venerable `stow <https://www.gnu.org/software/stow/>`_
command to manage your manual installations, the following takes care of the
above for you (use with :file:`dest=~/.local/stow`)::
cd ~/.local/stow
stow -v kitty.app
Customizing the installation

View File

@@ -1,26 +1,39 @@
Building kitty from source
==============================
.. image:: https://circleci.com/gh/kovidgoyal/kitty.svg?style=svg
.. image:: https://github.com/kovidgoyal/kitty/workflows/CI/badge.svg
:alt: Build status
:target: https://circleci.com/gh/kovidgoyal/kitty
:target: https://github.com/kovidgoyal/kitty/actions?query=workflow%3ACI
|kitty| is designed to run from source, for easy hackability. Make sure
|kitty| is designed to run from source, for easy hack-ability. Make sure
the following dependencies are installed first.
.. note::
If you are making small changes only to the python parts of kitty, there is no need to
build kitty at all, instead, assuming you have installed the official kitty
binaries, you can simply set the KITTY_DEVELOP_FROM enviroment variable to
point to the directory into which you have checked out the kitty source
code. kitty will then load its python code from there. You should use a
version of the source that matches the binary version as closely as
possible, since the two are tightly coupled.
Dependencies
----------------
Run-time dependencies:
* python >= 3.5
* harfbuzz >= 1.5.0
* python >= 3.6
* harfbuzz >= 2.2.0
* zlib
* libpng
* liblcms2
* freetype (not needed on macOS)
* fontconfig (not needed on macOS)
* ImageMagick (optional, needed to use the ``kitty icat`` tool to display images in the terminal)
* libcanberra (not needed on macOS)
* ImageMagick (optional, needed to use the ``kitty +kitten icat`` tool to display images in the terminal)
* pygments (optional, need for syntax highlighting in ``kitty +kitten diff``)
Build-time dependencies:
@@ -28,7 +41,7 @@ Build-time dependencies:
* gcc or clang
* pkg-config
* For building on Linux in addition to the above dependencies you might also need to install the ``-dev`` packages for:
``libdbus-1-dev``, ``libxcursor-dev``, ``libxrandr-dev``, ``libxi-dev``, ``libxinerama-dev``, ``libgl1-mesa-dev``, ``libxkbcommon-x11-dev``, ``libfontconfig-dev`` and ``libpython-dev``.
``libdbus-1-dev``, ``libxcursor-dev``, ``libxrandr-dev``, ``libxi-dev``, ``libxinerama-dev``, ``libgl1-mesa-dev``, ``libxkbcommon-x11-dev``, ``libfontconfig-dev``, ``libx11-xcb-dev``, ``liblcms2-dev``, and ``libpython3-dev``,
if they are not already installed by your distro.
Install and run from source
@@ -44,25 +57,17 @@ Now build the native code parts of |kitty| with the following command::
You can run |kitty|, as::
python3 .
./kitty/launcher/kitty
If that works, you can create a script to launch |kitty|:
.. code-block:: sh
#!/usr/bin/env python3
import runpy
runpy.run_path('/path/to/kitty/dir', run_name='__main__')
And place it in :file:`~/bin` or :file:`/usr/bin` so that you can run |kitty| using
If that works, you can create a symlink to the launcher in :file:`~/bin` or
some other directory on your PATH so that you can run |kitty| using
just ``kitty``.
Building kitty.app on macOS from source
-------------------------------------------
Install `imagemagick`, `optipng` and `librsvg` using `brew` or similar (needed
for the logo generation step). And run::
Run::
make app
@@ -70,10 +75,31 @@ This :file:`kitty.app` unlike the released one does not include its own copy of
python and the other dependencies. So if you ever un-install/upgrade those dependencies
you might have to rebuild the app.
Note that the released :file:`kitty.dmg` includes all dependencies, unlike the
:file:`kitty.app` built above and is built automatically by using the :file:`kitty` branch of
`build-calibre <https://github.com/kovidgoyal/build-calibre>`_ however, that
is designed to run on Linux and is not for the faint of heart.
.. note::
The released :file:`kitty.dmg` includes all dependencies, unlike the
:file:`kitty.app` built above and is built automatically by using the
<https://github.com/kovidgoyal/bypy>`_ however, that is designed to
run on Linux and is not for the faint of heart.
.. note::
Apple disallows certain functionality, such as notifications for unsigned applications.
If you need this functionality, you can try signing the built kitty.app with
a self signed certificate, see for example, `here
<https://stackoverflow.com/questions/27474751/how-can-i-codesign-an-app-without-being-in-the-mac-developer-program/27474942>`_.
Build and run from source with Nix
-------------------------------------------
On NixOS or any other Linux or macOS system with the Nix package manager
installed, execute `nix-shell
<https://nixos.org/guides/nix-pills/developing-with-nix-shell.html>`_ to create
the correct environment to build kitty or use ``nix-shell --pure`` instead to
eliminate most of the influence of the outside system, e.g. globally installed
packages. ``nix-shell`` will automatically fetch all required dependencies and
make them available in the newly spawned shell.
Then proceed with ``make`` or ``make app`` according to the platform specific instructions above.
Note for Linux/macOS packagers
@@ -111,3 +137,9 @@ without needing to install all of |kitty|.
This applies to creating packages for |kitty| for macOS package managers such as
brew or MacPorts as well.
.. note::
|kitty| has its own update check mechanism, if you would like to turn
it off for your package, use
``python3 setup.py linux-package --update-check-interval=0``

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fileencoding=utf-8
#
# Configuration file for the Sphinx documentation builder.
#
@@ -7,28 +7,30 @@
# full list see the documentation:
# https://www.sphinx-doc.org/en/master/config
import importlib
import os
import re
import subprocess
import sys
import time
from functools import partial
from typing import Any, Callable, Dict, Iterable, List, Match, Optional, Tuple
from docutils import nodes
from docutils.parsers.rst.roles import set_classes
from pygments.lexer import RegexLexer, bygroups
from pygments.token import (
from pygments.lexer import RegexLexer, bygroups # type: ignore
from pygments.token import ( # type: ignore
Comment, Keyword, Literal, Name, Number, String, Whitespace
)
from sphinx import addnodes
from sphinx.environment.adapters.toctree import TocTree
from sphinx.util.logging import getLogger
from sphinx import addnodes, version_info # type: ignore
from sphinx.environment.adapters.toctree import TocTree # type: ignore
from sphinx.util.logging import getLogger # type: ignore
kitty_src = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if kitty_src not in sys.path:
sys.path.insert(0, kitty_src)
str_version = importlib.import_module('kitty.constants').str_version
from kitty.conf.types import Definition # noqa
from kitty.constants import str_version # noqa
# config {{{
# -- Project information -----------------------------------------------------
@@ -77,7 +79,7 @@ master_doc = 'index'
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language: Optional[str] = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
@@ -134,9 +136,6 @@ html_theme_options = {
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static', '../logo/kitty.png']
html_context = {
'css_files': ['_static/custom.css']
}
html_favicon = '../logo/kitty.png'
# Custom sidebar templates, must be a dictionary that maps document names
@@ -164,8 +163,8 @@ html_show_sourcelink = False
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('invocation', 'kitty', 'kitty Documentation',
[author], 1)
('invocation', 'kitty', 'kitty Documentation', [author], 1),
('conf', 'kitty.conf', 'kitty.conf Documentation', [author], 5)
]
@@ -176,7 +175,7 @@ man_pages = [
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'kitty', 'kitty Documentation',
author, 'kitty', 'A cross-platform, fast, feature full, GPU based terminal emulator',
author, 'kitty', 'Cross-platform, fast, feature-rich, GPU based terminal',
'Miscellaneous'),
]
# }}}
@@ -184,7 +183,7 @@ texinfo_documents = [
# GitHub linking inline roles {{{
def num_role(which, name, rawtext, text, lineno, inliner, options={}, content=[]):
def num_role(which: str, name: str, rawtext: str, text: str, lineno: int, inliner: Any, options: Any = {}, content: Any = []) -> Tuple[List, List]:
' Link to a github issue '
try:
issue_num = int(text)
@@ -202,10 +201,11 @@ def num_role(which, name, rawtext, text, lineno, inliner, options={}, content=[]
return [node], []
def commit_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
def commit_role(name: str, rawtext: str, text: str, lineno: int, inliner: Any, options: Any = {}, content: Any = []) -> Tuple[List, List]:
' Link to a github commit '
try:
commit_id = subprocess.check_output(f'git rev-list --max-count=1 --skip=# {text}'.split()).decode('utf-8').strip()
commit_id = subprocess.check_output(
f'git rev-list --max-count=1 --skip=# {text}'.split()).decode('utf-8').strip()
except Exception:
msg = inliner.reporter.error(
f'GitHub commit id "{text}" not recognized.', line=lineno)
@@ -213,21 +213,22 @@ def commit_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
return [prb], [msg]
url = f'https://github.com/kovidgoyal/kitty/commit/{commit_id}'
set_classes(options)
short_id = subprocess.check_output(f'git rev-list --max-count=1 --abbrev-commit --skip=# {commit_id}'.split()).decode('utf-8').strip()
short_id = subprocess.check_output(
f'git rev-list --max-count=1 --abbrev-commit --skip=# {commit_id}'.split()).decode('utf-8').strip()
node = nodes.reference(rawtext, f'commit: {short_id}', refuri=url, **options)
return [node], []
# }}}
# Sidebar ToC {{{
def create_toc(app, pagename):
def create_toc(app: Any, pagename: str) -> Optional[Any]:
tt = TocTree(app.env)
toctree = tt.get_toc_for(pagename, app.builder)
if toctree is not None:
subtree = toctree[toctree.first_child_matching_class(nodes.list_item)]
bl = subtree.first_child_matching_class(nodes.bullet_list)
if bl is None:
return # Empty ToC
return None # Empty ToC
subtree = subtree[bl]
# for li in subtree.traverse(nodes.list_item):
# modify_li(li)
@@ -235,29 +236,40 @@ def create_toc(app, pagename):
return app.builder.render_partial(subtree)['fragment']
def add_html_context(app, pagename, templatename, context, *args):
def add_html_context(app: Any, pagename: str, templatename: str, context: Any, *args: Any) -> None:
if 'toc' in context:
context['toc'] = create_toc(app, pagename) or context['toc']
# }}}
# CLI docs {{{
def write_cli_docs(all_kitten_names):
def write_cli_docs(all_kitten_names: Iterable[str]) -> None:
from kitty.cli import option_spec_as_rst
from kitty.launch import options_spec as launch_options_spec
with open('generated/launch.rst', 'w') as f:
f.write(option_spec_as_rst(
appname='launch', ospec=launch_options_spec, heading_char='_',
message='''\
Launch an arbitrary program in a new kitty window/tab. Note that
if you specify a program-to-run you can use the special placeholder
:code:`@selection` which will be replaced by the current selection.
'''
))
with open('generated/cli-kitty.rst', 'w') as f:
f.write(option_spec_as_rst(appname='kitty').replace(
'kitty --to', 'kitty @ --to'))
as_rst = partial(option_spec_as_rst, heading_char='_')
from kitty.remote_control import global_options_spec, cli_msg, cmap, all_commands
from kitty.rc.base import all_command_names, command_for_name
from kitty.remote_control import cli_msg, global_options_spec
with open('generated/cli-kitty-at.rst', 'w') as f:
p = partial(print, file=f)
p('kitty @\n' + '-' * 80)
p('.. program::', 'kitty @')
p('\n\n' + as_rst(
global_options_spec, message=cli_msg, usage='command ...', appname='kitty @'))
from kitty.cmds import cli_params_for
for cmd_name in all_commands:
func = cmap[cmd_name]
from kitty.rc.base import cli_params_for
for cmd_name in sorted(all_command_names()):
func = command_for_name(cmd_name)
p(f'.. _at_{func.name}:\n')
p('kitty @', func.name + '\n' + '-' * 120)
p('.. program::', 'kitty @', func.name)
@@ -276,6 +288,50 @@ def write_cli_docs(all_kitten_names):
# }}}
def write_remote_control_protocol_docs() -> None: # {{{
from kitty.rc.base import (
RemoteCommand, all_command_names, command_for_name
)
field_pat = re.compile(r'\s*([a-zA-Z0-9_+]+)\s*:\s*(.+)')
def format_cmd(p: Callable, name: str, cmd: RemoteCommand) -> None:
p(name)
p('-' * 80)
lines = (cmd.__doc__ or '').strip().splitlines()
fields = []
for line in lines:
m = field_pat.match(line)
if m is None:
p(line)
else:
fields.append((m.group(1), m.group(2)))
if fields:
p('\nFields are:\n')
for (name, desc) in fields:
if '+' in name:
title = name.replace('+', ' (required)')
else:
title = name
defval = cmd.get_default(name.replace('-', '_'), cmd)
if defval is not cmd:
title = f'{title} (default: {defval})'
else:
title = f'{title} (optional)'
p(f':code:`{title}`')
p(' ', desc), p()
p(), p()
with open('generated/rc.rst', 'w') as f:
p = partial(print, file=f)
for name in sorted(all_command_names()):
cmd = command_for_name(name)
if not cmd.__doc__:
continue
name = name.replace('_', '-')
format_cmd(p, name, cmd)
# }}}
# config file docs {{{
class ConfLexer(RegexLexer):
@@ -331,36 +387,38 @@ class SessionLexer(RegexLexer):
}
def link_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
def link_role(name: str, rawtext: str, text: str, lineno: int, inliner: Any, options: Any = {}, content: Any = []) -> Tuple[List, List]:
text = text.replace('\n', ' ')
m = re.match(r'(.+)\s+<(.+?)>', text)
if m is None:
msg = inliner.reporter.error(f'link "{text}" not recognized', line=lineno)
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
text, url = m.group(1, 2)
url = url.replace(' ', '')
set_classes(options)
node = nodes.reference(rawtext, text, refuri=url, **options)
return [node], []
def expand_opt_references(conf_name, text):
def expand_opt_references(conf_name: str, text: str) -> str:
conf_name += '.'
def expand(m):
def expand(m: Match) -> str:
ref = m.group(1)
if '<' not in ref and '.' not in ref:
full_ref = conf_name + ref
return ':opt:`{} <{}>`'.format(ref, full_ref)
return m.group()
return str(m.group())
return re.sub(r':opt:`(.+?)`', expand, text)
opt_aliases = {}
shortcut_slugs = {}
opt_aliases: Dict[str, str] = {}
shortcut_slugs: Dict[str, Tuple[str, str]] = {}
def parse_opt_node(env, sig, signode):
def parse_opt_node(env: Any, sig: str, signode: Any) -> str:
"""Transform an option description into RST nodes."""
count = 0
firstname = ''
@@ -382,94 +440,14 @@ def parse_opt_node(env, sig, signode):
return firstname
def parse_shortcut_node(env, sig, signode):
def parse_shortcut_node(env: Any, sig: str, signode: Any) -> str:
"""Transform a shortcut description into RST nodes."""
conf_name, text = sig.split('.', 1)
signode += addnodes.desc_name(text, text)
return sig
def render_conf(conf_name, all_options):
from kitty.conf.definition import merged_opts, Option
ans = ['.. default-domain:: conf', '']
a = ans.append
current_group = None
all_options = list(all_options)
kitty_mod = 'kitty_mod'
def render_group(group):
a('')
a(f'.. _conf-{conf_name}-{group.name}:')
a('')
a(group.short_text)
heading_level = '+' if '.' in group.name else '^'
a(heading_level * (len(group.short_text) + 20))
a('')
if group.start_text:
a(group.start_text)
a('')
def handle_group_end(group):
if group.end_text:
a(''), a(current_group.end_text)
def handle_group(new_group, new_group_is_shortcut=False):
nonlocal current_group
if new_group is not current_group:
if current_group:
handle_group_end(current_group)
current_group = new_group
render_group(current_group)
def handle_option(i, opt):
nonlocal kitty_mod
if not opt.long_text or not opt.add_to_docs:
return
handle_group(opt.group)
if opt.name == 'kitty_mod':
kitty_mod = opt.defval_as_string
mopts = list(merged_opts(all_options, opt, i))
a('.. opt:: ' + ', '.join(conf_name + '.' + mo.name for mo in mopts))
a('.. code-block:: conf')
a('')
sz = max(len(x.name) for x in mopts)
for mo in mopts:
a((' {:%ds} {}' % sz).format(mo.name, mo.defval_as_string))
a('')
if opt.long_text:
a(expand_opt_references(conf_name, opt.long_text))
a('')
def handle_shortcuts(shortcuts):
sc = shortcuts[0]
handle_group(sc.group, True)
sc_text = f'{conf_name}.{sc.short_text}'
a('.. shortcut:: ' + sc_text)
shortcuts = [s for s in shortcuts if s.add_to_default]
shortcut_slugs[f'{conf_name}.{sc.name}'] = (sc_text, sc.key.replace('kitty_mod', kitty_mod))
if shortcuts:
a('.. code-block:: conf')
a('')
for x in shortcuts:
if x.add_to_default:
a(' map {} {}'.format(x.key.replace('kitty_mod', kitty_mod), x.action_def))
a('')
if sc.long_text:
a(expand_opt_references(conf_name, sc.long_text))
a('')
for i, opt in enumerate(all_options):
if isinstance(opt, Option):
handle_option(i, opt)
else:
handle_shortcuts(opt)
if current_group:
handle_group_end(current_group)
return '\n'.join(ans)
def process_opt_link(env, refnode, has_explicit_title, title, target):
def process_opt_link(env: Any, refnode: Any, has_explicit_title: bool, title: str, target: str) -> Tuple[str, str]:
conf_name, opt = target.partition('.')[::2]
if not opt:
conf_name, opt = 'kitty', conf_name
@@ -477,20 +455,23 @@ def process_opt_link(env, refnode, has_explicit_title, title, target):
return title, opt_aliases.get(full_name, full_name)
def process_shortcut_link(env, refnode, has_explicit_title, title, target):
def process_shortcut_link(env: Any, refnode: Any, has_explicit_title: bool, title: str, target: str) -> Tuple[str, str]:
conf_name, slug = target.partition('.')[::2]
if not slug:
conf_name, slug = 'kitty', conf_name
full_name = conf_name + '.' + slug
try:
target, title = shortcut_slugs[full_name]
target, stitle = shortcut_slugs[full_name]
except KeyError:
logger.warning('Unknown shortcut: {}'.format(target), location=refnode)
else:
if not has_explicit_title:
title = stitle
return title, target
def write_conf_docs(app, all_kitten_names):
app.add_lexer('conf', ConfLexer())
def write_conf_docs(app: Any, all_kitten_names: Iterable[str]) -> None:
app.add_lexer('conf', ConfLexer() if version_info[0] < 3 else ConfLexer)
app.add_object_type(
'opt', 'opt',
indextemplate="pair: %s; Config Setting",
@@ -509,36 +490,38 @@ def write_conf_docs(app, all_kitten_names):
sc_role = app.registry.domain_roles['std']['sc']
sc_role.warn_dangling = True
sc_role.process_link = process_shortcut_link
shortcut_slugs.clear()
def generate_default_config(all_options, name):
from kitty.conf.definition import as_conf_file
def generate_default_config(definition: Definition, name: str) -> None:
with open(f'generated/conf-{name}.rst', 'w', encoding='utf-8') as f:
print('.. highlight:: conf\n', file=f)
f.write(render_conf(name, all_options.values()))
f.write('\n'.join(definition.as_rst(name, shortcut_slugs)))
conf_name = re.sub(r'^kitten-', '', name) + '.conf'
with open(f'generated/conf/{conf_name}', 'w', encoding='utf-8') as f:
text = '\n'.join(as_conf_file(all_options.values()))
text = '\n'.join(definition.as_conf())
print(text, file=f)
from kitty.config_data import all_options
generate_default_config(all_options, 'kitty')
from kitty.options.definition import definition
generate_default_config(definition, 'kitty')
from kittens.runner import get_kitten_conf_docs
for kitten in all_kitten_names:
all_options = get_kitten_conf_docs(kitten)
if all_options:
generate_default_config(all_options, f'kitten-{kitten}')
definition = get_kitten_conf_docs(kitten)
if definition:
generate_default_config(definition, f'kitten-{kitten}')
# }}}
def setup(app):
def setup(app: Any) -> None:
os.makedirs('generated/conf', exist_ok=True)
from kittens.runner import all_kitten_names
all_kitten_names = all_kitten_names()
write_cli_docs(all_kitten_names)
write_conf_docs(app, all_kitten_names)
app.add_lexer('session', SessionLexer())
kn = all_kitten_names()
write_cli_docs(kn)
write_remote_control_protocol_docs()
write_conf_docs(app, kn)
app.add_css_file('custom.css')
app.add_lexer('session', SessionLexer() if version_info[0] < 3 else SessionLexer)
app.add_role('link', link_role)
app.add_role('iss', partial(num_role, 'issues'))
app.add_role('pull', partial(num_role, 'pull'))

View File

@@ -5,13 +5,14 @@ Configuring kitty
.. highlight:: conf
|kitty| is highly customizable, everything from keyboard shortcuts, to painting
frames-per-second. See below for an overview of all customization
|kitty| is highly customizable, everything from keyboard shortcuts, to
rendering frames-per-second. See below for an overview of all customization
possibilities.
You can open the config file within kitty by pressing :sc:`edit_config_file`.
You can also display the current configuration by running ``kitty
--debug-config``.
You can reload the config file within kitty by pressing
:sc:`reload_config_file` or sending kitty the ``SIGUSR1`` signal. You can also
display the current configuration by pressing the :sc:`debug_config` key.
.. _confloc:
@@ -39,6 +40,16 @@ expanded, so :code:`${USER}.conf` becomes :file:`name.conf` if
Sample kitty.conf
^^^^^^^^^^^^^^^^^^^^^
You can download a sample :file:`kitty.conf` file with all default settings and
comments describing each setting by clicking: :download:`sample kitty.conf
</generated/conf/kitty.conf>`.
.. only:: html
You can download a sample :file:`kitty.conf` file with all default settings and
comments describing each setting by clicking: :download:`sample kitty.conf
</generated/conf/kitty.conf>`.
.. only:: man
You can edit a fully commented sample kitty.conf by pressing the
:sc:`edit_config_file` shortcut in kitty. This will generate a config
file with full documentation and all settings commented out. If you
have a pre-existing kitty.conf, then that will be used instead, delete
it to see the sample file.

View File

@@ -4,6 +4,7 @@ Frequently Asked Questions
.. highlight:: sh
.. contents::
:local:
Some special symbols are rendered small/truncated in kitty?
-----------------------------------------------------------
@@ -47,12 +48,23 @@ terminfo files to the server::
kitty +kitten ssh myserver
This ssh kitten takes all the same command line arguments
as ssh, you can alias it to ssh in your shell's rc files to avoid having to
type it each time::
alias ssh="kitty +kitten ssh"
If for some reason that does not work (typically because the server is using a
non POSIX compliant shell), you can use the following one-liner instead (it
non POSIX compliant shell), you can try using it with python instead::
kitty +kitten ssh use-python myserver
If that also fails, perhaps because python is not installed on the remote
server, use the following one-liner instead (it
is slower as it needs to ssh into the server twice, but will work with most
servers)::
infocmp xterm-kitty | ssh myserver tic -x -o \~/.terminfo /dev/stdin
infocmp -a xterm-kitty | ssh myserver tic -x -o \~/.terminfo /dev/stdin
If you are behind a proxy (like Balabit) that prevents this, you must redirect the
1st command to a file, copy that to the server and run ``tic`` manually. If you
@@ -63,6 +75,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?
-------------------------------------------------------------------------------------------------
@@ -97,12 +121,39 @@ How do I change the colors in a running kitty instance?
You can either use the
`OSC terminal escape codes <https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Operating-System-Commands>`_
to set colors or you can enable :doc:`remote control <remote-control>`
for |kitty| and use :ref:`at_set-colors`.
to set colors or you can define keyboard shortcuts to set colors, for example::
map f1 set_colors --configured /path/to/some/config/file/colors.conf
Or you can enable :doc:`remote control <remote-control>` for |kitty| and use :ref:`at_set-colors`.
The shortcut mapping technique has the same syntax as the remote control
command, for details, see :ref:`at_set-colors`.
A list of pre-made color themes for kitty is available at:
`kitty-themes <https://github.com/dexpota/kitty-themes>`_
Examples of using OSC escape codes to set colors::
Change the default foreground color:
printf '\x1b]10;#ff0000\x1b\\'
Change the default background color:
printf '\x1b]11;blue\x1b\\'
Change the cursor color:
printf '\x1b]12;blue\x1b\\'
Change the selection background color:
printf '\x1b]17;blue\x1b\\'
Change the selection foreground color:
printf '\x1b]19;blue\x1b\\'
Change the nth color (0 - 255):
printf '\x1b]4;n;green\x1b\\'
You can use various syntaxes/names for color specifications in the above
examples. See `XParseColor <https://linux.die.net/man/3/xparsecolor>`_
for full details.
If a ``?`` is given rather than a color specification, kitty will respond
with the current value for the specified color.
How do I specify command line options for kitty on macOS?
---------------------------------------------------------------
@@ -119,6 +170,19 @@ You can, of course, also run |kitty| from a terminal with command line options,
And within |kitty| itself, you can always run |kitty| using just `kitty` as it
cleverly adds itself to the ``PATH``.
I catted a binary file and now kitty is hung?
-----------------------------------------------
**Never** output unknown binary data directly into a terminal.
Terminals have a single channel for both data and control. Certain bytes
are control codes. Some of these control codes are of arbitrary length, so
if the binary data you output into the terminal happens to contain the starting
sequence for one of these control codes, the terminal will hang waiting for
the closing sequence. Press :kbd:`ctrl+shift+delete` to reset the terminal.
If you do want to cat unknown data, use ``cat -v``.
kitty is not able to use my favorite font?
---------------------------------------------
@@ -126,11 +190,39 @@ kitty is not able to use my favorite font?
|kitty| achieves its stellar performance by caching alpha masks of each rendered
character on the GPU, so that every character needs to be rendered only once.
This means it is a strictly character cell based display. As such it can use
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::
only monospace fonts, since every cell in the grid has to be the same size.
Furthermore, it needs fonts to be freely resizable, so it does not support
bitmapped fonts.
fc-list : family spacing | grep spacing=100
If your font is not listed in ``kitty list-fonts`` it means that it is not
monospace or is a bitmapped font. On Linux you can list all monospace fonts with::
fc-list : family spacing outline scalable | grep -e spacing=100 -e spacing=90 | grep -e outline=True | grep -e scalable=True
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>
After creating (or modifying) this file, you may need to run the following
command to rebuild your fontconfig cache::
fc-cache -r
Then, the font will be available in ``kitty list-fonts``.
How can I assign a single global shortcut to bring up the kitty terminal?
@@ -140,3 +232,122 @@ Bringing up applications on a single key press is the job of the window
manager/desktop environment. For ways to do it with kitty (or indeed any
terminal) in different environments,
see `here <https://github.com/kovidgoyal/kitty/issues/45>`_.
How do I map key presses in kitty to different keys in the terminal program?
--------------------------------------------------------------------------------------
This is accomplished by using ``map`` with :sc:`send_text <send_text>` in :file:`kitty.conf`.
For example::
map alt+s send_text normal,application \x13
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 ``show_key`` kitten. Run::
kitty +kitten show_key
Then press the key you want to emulate.
How do I open a new window or tab with the same working directory as the current window?
--------------------------------------------------------------------------------------------
In :file:`kitty.conf` add the following::
map f1 launch --cwd=current
map f2 launch --cwd=current --type=tab
Pressing :kbd:`F1` will open a new kitty window with the same working directory
as the current window. The :doc:`launch command <launch>` is very powerful,
explore :doc:`its documentation <launch>`.
Things behave differently when running kitty from system launcher vs. from another terminal?
-----------------------------------------------------------------------------------------------
This will be because of environment variables. When you run kitty from the
system launcher, it gets a default set of system environment variables. When
you run kitty from another terminal, you are actually running it from a shell,
and the shell's rc files will have setup a whole different set of environment
variables which kitty will now inherit.
You need to make sure that the environment variables you define in your shell's
rc files are either also defined system wide or via the :opt:`env` directive in
:file:`kitty.conf`. Common environment variables that cause issues are those
related to localization, such as ``LANG, LC_*`` and loading of configuration
files such as ``XDG_*, KITTY_CONFIG_DIRECTORY``.
To see the environment variables that kitty sees, you can add the following
mapping to :file:`kitty.conf`::
map f1 show_kitty_env_vars
then pressing :kbd:`F1` will show you the environment variables kitty sees.
This problem is most common on macOS, as Apple makes it exceedingly difficult to
setup environment variables system-wide, so people end up putting them in all
sorts of places where they may or may not work.
I am using tmux and have a problem
--------------------------------------
First, terminal multiplexers are `a bad idea
<https://github.com/kovidgoyal/kitty/issues/391#issuecomment-638320745>`_, do
not use them, if at all possible. kitty contains features that do all of what
tmux does, but better, with the exception of remote persistence (:iss:`391`).
If you still want to use tmux, read on.
Image display will not work, see `tmux issue
<https://github.com/tmux/tmux/issues/1391>`_.
If you are using tmux with multiple terminals or you start it under one
terminal and then switch to another and these terminals have different TERM
variables, tmux will break. You will need to restart it as tmux does not
support multiple terminfo definitions.
Copying to clipboard via OSC 52 will not work, because tmux does not support
the extended version of that protocol, you will need to add ``no-append`` to
:opt:`clipboard_control` in kitty.conf.
If you use any of the advanced features that kitty has innovated, such as
styled underlines, desktop notifications, extended keyboard support, etc.
they may or may not work, depending on the whims of tmux's maintainer, your
version of tmux, etc.
I opened and closed a lot of windows/tabs and top shows kitty's memory usage is very high?
-------------------------------------------------------------------------------------------
``top`` is not a good way to measure process memory usage. That is because on
modern systems, when allocating memory to a process, the C library functions
will typically allocate memory in large blocks, and give the process chunks of
these blocks. When the process frees a chunk, the C library will not
necessarily release the underlying block back to the OS. So even though the
application has released the memory, ``top`` will still claim the process is
using it.
To check for memory leaks, instead use a tool like ``valgrind``. Run::
PYTHONMALLOC=malloc valgrind --tool=massif kitty
Now open lots of tabs/windows, generate lots of output using tools like find/yes
etc. Then close all but one window. Do some random work for a few seconds in
that window, maybe run yes or find again. Then quit kitty and run::
massif-visualizer massif.out.*
You will see the allocations graph goes up when you opened the windows, then
goes back down when you closed them, indicating there were no memory leaks.
For those interested, you can get a similar profile out of ``valgrind`` as you get
with ``top`` by adding ``--pages-as-heap=yes`` then you will see that memory
allocated in malloc is not freed in free. This can be further refined if you
use `glibc`` as your C library by setting the environment variable
``MALLOC_MMAP_THRESHOLD_=64``. This will cause free to actually free memory
allocated in sizes of more than 64 bytes. With this set, memory usage will
climb high, then fall when closing windows, but not fall all the way back. The
remaining used memory can be investigated using valgrind again, and it will
come from arenas in the GPU drivers and the per thread arenas glibc's malloc
maintains. These too allocate memory in large blocks and dont release it back
to the OS immediately.

View File

@@ -28,17 +28,25 @@ alpha-blending and text over graphics.
:alt: Demo of graphics rendering in kitty
:align: center
Some programs that use the kitty graphics protocol:
Some programs and libraries that use the kitty graphics protocol:
* `termpdf <https://github.com/dsanson/termpdf>`_ - a terminal PDF/DJVU/CBR viewer
* `termpdf.py <https://github.com/dsanson/termpdf.py>`_ - a terminal PDF/DJVU/CBR viewer
* `ranger <https://github.com/ranger/ranger>`_ - a terminal file manager, with
image previews, see this `PR <https://github.com/ranger/ranger/pull/1077>`_
* :doc:`kitty-diff <kittens/diff>` - a side-by-side terminal diff program with support for images
* `pixcat <https://github.com/mirukana/pixcat>`_ - a third party CLI and python library that wraps the graphics protocol
* `neofetch <https://github.com/dylanaraps/neofetch>`_ - A command line system
information tool
* `viu <https://github.com/atanunq/viu>`_ - a terminal image viewer
* `glkitty <https://github.com/michaeljclark/glkitty>`_ - C library to draw OpenGL shaders in the terminal with a glgears demo
* `ctx.graphics <https://ctx.graphics/>`_ - Library for drawing graphics
* `timg <https://github.com/hzeller/timg>`_ - a terminal image and video viewer
* `notcurses <https://github.com/dankamongmen/notcurses>`_ - C library for terminal graphics with bindings for C++, Rust and Python
* `rasterm <https://github.com/BourgeoisBear/rasterm>`_ - Go library to display images in the the terminal
.. contents::
:local:
Getting the window size
@@ -53,27 +61,34 @@ In C:
.. code-block:: c
struct ttysize ts;
ioctl(0, TIOCGWINSZ, &ts);
printf("number of columns: %i, number of rows: %i, screen width: %i, screen height: %i\n", sz.ws_col, sz.ws_row, sz.ws_xpixel, sz.ws_ypixel);
#include <stdio.h>
#include <sys/ioctl.h>
int main(int argc, char **argv) {
struct winsize sz;
ioctl(0, TIOCGWINSZ, &sz);
printf("number of rows: %i, number of columns: %i, screen width: %i, screen height: %i\n", sz.ws_row, sz.ws_col, sz.ws_xpixel, sz.ws_ypixel);
return 0;
}
In Python:
.. code-block:: python
import array, fcntl, termios
import array, fcntl, sys, termios
buf = array.array('H', [0, 0, 0, 0])
fcntl.ioctl(sys.stdout, termios.TIOCGWINSZ, buf)
print('number of columns: {}, number of rows: {}, screen width: {}, screen height: {}'.format(*buf))
print('number of rows: {}, number of columns: {}, screen width: {}, screen height: {}'.format(*buf))
Note that some terminals return ``0`` for the width and height values. Such
terminals should be modified to return the correct values. Examples of
terminals that return correct values: ``kitty, xterm``
You can also use the *CSI t* escape code to get the screen size. Send
``<ESC>[14t`` to *stdout* and kitty will reply on *stdin* with
``<ESC>[4;<height>;<width>t`` where *height* and *width* are the window size in
pixels. This escape code is supported in many terminals, not just kitty.
``<ESC>[14t`` to ``STDOUT`` and kitty will reply on ``STDIN`` with
``<ESC>[4;<height>;<width>t`` where ``height`` and ``width`` are the window
size in pixels. This escape code is supported in many terminals, not just
kitty.
A minimal example
------------------
@@ -107,7 +122,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
@@ -133,6 +149,8 @@ The meaning of the payload is interpreted based on the control data.
The first step is to transmit the actual image data.
.. _transferring_pixel_data:
Transferring pixel data
--------------------------
@@ -152,9 +170,10 @@ of transmitting paletted images.
RGB and RGBA data
~~~~~~~~~~~~~~~~~~~
In these formats the pixel data is stored directly as 3 or 4 bytes per pixel, respectively.
When specifying images in this format, the image dimensions **must** be sent in the control data.
For example::
In these formats the pixel data is stored directly as 3 or 4 bytes per pixel,
respectively. The colors in the data **must** be in the *sRGB color space*. When
specifying images in this format, the image dimensions **must** be sent in the
control data. For example::
<ESC>_Gf=24,s=10,v=20;<payload><ESC>\
@@ -178,16 +197,17 @@ compression, then you must provide the ``S`` key with the size of the PNG data.
Compression
~~~~~~~~~~~~~
The client can send compressed image data to the terminal emulator, by specifying the
``o`` key. Currently, only zlib based deflate compression is supported, which is specified using
``o=z``. For example::
The client can send compressed image data to the terminal emulator, by
specifying the ``o`` key. Currently, only :rfc:`1950` ZLIB based deflate
compression is supported, which is specified using ``o=z``. For example::
<ESC>_Gf=24,s=10,v=20,o=z;<payload><ESC>\
This is the same as the example from the RGB data section, except that the
payload is now compressed using deflate. The terminal emulator will decompress
it before rendering. You can specify compression for any format. The terminal
emulator will decompress before interpreting the pixel data.
payload is now compressed using deflate (this occurs prior to base64-encoding).
The terminal emulator will decompress it before rendering. You can specify
compression for any format. The terminal emulator will decompress before
interpreting the pixel data.
The transmission medium
@@ -206,8 +226,12 @@ Value of `t` Meaning
is in a known temporary directory, such as :file:`/tmp`,
:file:`/dev/shm`, :file:`TMPDIR env var if present` and any platform
specific temporary directories.
``s`` A `POSIX shared memory object <http://man7.org/linux/man-pages/man7/shm_overview.7.html>`_.
The terminal emulator will delete it after reading the pixel data
``s`` A *shared memory object*, which on POSIX systems is a `POSIX shared memory object
<http://man7.org/linux/man-pages/man7/shm_overview.7.html>`_ and on Windows is a
`Named shared memory object <https://docs.microsoft.com/en-us/windows/win32/memory/creating-named-shared-memory>`_.
The terminal emulator must read the data from the memory
object and then unlink and close it on POSIX and just
close it on Windows.
================== ============
Local client
@@ -253,13 +277,16 @@ sequence of escape codes to the terminal emulator::
<ESC>_Gm=0;<encoded pixel data last chunk><ESC>\
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
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Querying support and available transmission mediums
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Since a client has no a-priori knowledge of whether it shares a filesystem/shared memory
with the terminal emulator, it can send an id with the control data, using the ``i`` key
@@ -285,17 +312,39 @@ use the *query action*, set ``a=q``. Then the terminal emulator will try to load
the image and respond with either OK or an error, as above, but it will not
replace an existing image with the same id, nor will it store the image.
While as of May 2020, kitty is the only terminal emulator to support this
graphics protocol, we intend that any terminal emulator that wishes to support
it can. To check if a terminal emulator supports the graphics protocol the best way
is to send the above *query action* followed by a request for the
`primary device attributes <https://vt100.net/docs/vt510-rm/DA1.html>`_. If you
get back an answer for the device attributes without getting back an answer for
the *query action* the terminal emulator does not support the graphics
protocol.
This means that terminal emulators that support the graphics protocol, **must**
reply to *query actions* immediately without processing other input. Most
terminal emulators handle input in a FIFO manner, anyway.
So for example, you could send::
<ESC>_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA<ESC>\<ESC>[c
If you get back a response to the graphics query, the terminal emulator supports
the protocol, if you get back a response to the device attributes query without
a response to the graphics query, it does not.
Display images on screen
-----------------------------
Every transmitted image can be displayed an arbitrary number of times on the
screen, in different locations, using different parts of the source image, as
needed. You can either simultaneously transmit and display an image using the
action ``a=T``, or first transmit the image with a id, such as ``i=10`` and then display
it with ``a=p,i=10`` which will display the previously transmitted image at the current
cursor position. When specifying an image id, the terminal emulator will reply with an
acknowledgement code, which will be either::
needed. Each such display of an image is called a *placement*. You can either
simultaneously transmit and display an image using the action ``a=T``, or first
transmit the image with a id, such as ``i=10`` and then display it with
``a=p,i=10`` which will display the previously transmitted image at the current
cursor position. When specifying an image id, the terminal emulator will reply
to the placement request with an acknowledgement code, which will be either::
<ESC>_Gi=<id>;OK<ESC>\
@@ -308,6 +357,24 @@ scheme described above for querying available transmission media, except that
here we are querying if the image with the specified id is available or needs to
be re-transmitted.
Since there can be many placements per image, you can also give placements an
id. To do so add the ``p`` key with a number between ``1`` and ``4294967295``.
When you specify a placement id, it will be added to the acknowledgement code
above. Every placement is uniquely identified by the pair of the ``image id``
and the ``placement id``. If you specify a placement id for an image that does
not have an id, it will be ignored. An example response::
<ESC>_Gi=<image id>,p=<placement id>;OK<ESC>\
If you send two placements with the same ``image id`` and ``placement id`` the
second one will replace the first. This can be used to resize or move
placements around the screen, without flicker.
.. versionadded:: 0.19.3
Support for specifying placement ids (see :doc:`kittens/query_terminal` to query kitty version)
Controlling displayed image layout
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -330,7 +397,22 @@ Finally, you can specify the image *z-index*, i.e. the vertical stacking order.
placed in the same location with different z-index values will be blended if
they are semi-transparent. You can specify z-index values using the ``z`` key.
Negative z-index values mean that the images will be drawn under the text. This
allows rendering of text on top of images.
allows rendering of text on top of images. Negative z-index values below
INT32_MIN/2 (-1,073,741,824) will be drawn under cells with non-default background
colors.
.. note:: After placing an image on the screen the cursor must be moved to the
right by the number of cols in the image placement rectangle and down by the
number of rows in the image placement rectangle. If either of these cause
the cursor to leave either the screen or the scroll area, the exact
positioning of the cursor is undefined, and up to implementations.
The client can ask the terminal emulator to not move the cursor at all
by specifying ``C=1`` in the command, which sets the cursor movement policy
to no movement for placing the current image.
.. versionadded:: 0.20.0
Support for the C=1 cursor movement policy
Deleting images
---------------------
@@ -348,33 +430,218 @@ scrollback buffer. The values of the ``x`` and ``y`` keys are the same as cursor
================= ============
Value of ``d`` Meaning
================= ============
``a`` or ``A`` Delete all images visible on screen
``i`` or ``I`` Delete all images with the specified id, specified using the ``i`` key.
``c`` or ``C`` Delete all images that intersect with the current cursor position.
``p`` or ``P`` Delete all images that intersect a specific cell, the cell is specified using the ``x`` and ``y`` keys
``q`` or ``Q`` Delete all images that intersect a specific cell having a specific z-index. The cell and z-index is specified using the ``x``, ``y`` and ``z`` keys.
``x`` or ``X`` Delete all images that intersect the specified column, specified using the ``x`` key.
``y`` or ``Y`` Delete all images that intersect the specified row, specified using the ``y`` key.
``z`` or ``Z`` Delete all images that have the specified z-index, specified using the ``z`` key.
``a`` or ``A`` Delete all placements visible on screen
``i`` or ``I`` Delete all images with the specified id, specified using the ``i`` key. If you specify a ``p`` key for the placement id as well, then only the placement with the specified image id and placement id will be deleted.
``n`` or ``N`` Delete newest image with the specified number, specified using the ``I`` key. If you specify a ``p`` key for the
placement id as well, then only the placement with the specified number and placement id will be deleted.
``c`` or ``C`` Delete all placements that intersect with the current cursor position.
``f`` or ``F`` Delete animation frames.
``p`` or ``P`` Delete all placements that intersect a specific cell, the cell is specified using the ``x`` and ``y`` keys
``q`` or ``Q`` Delete all placements that intersect a specific cell having a specific z-index. The cell and z-index is specified using the ``x``, ``y`` and ``z`` keys.
``x`` or ``X`` Delete all placements that intersect the specified column, specified using the ``x`` key.
``y`` or ``Y`` Delete all placements that intersect the specified row, specified using the ``y`` key.
``z`` or ``Z`` Delete all placements that have the specified z-index, specified using the ``z`` key.
================= ============
Note when all placements for an image have been deleted, the image is also
deleted, if the capital letter form above is specified. Also, when the terminal
is running out of quota space for new images, existing images without
placements will be preferentially deleted.
Some examples::
<ESC>_Ga=d<ESC>\ # delete all visible images
<ESC>_Ga=d,i=10<ESC>\ # delete the image with id=10
<ESC>_Ga=Z,z=-1<ESC>\ # delete the images with z-index -1, also freeing up image data
<ESC>_Ga=P,x=3,y=4<ESC>\ # delete all images that intersect the cell at (3, 4)
<ESC>_Ga=d<ESC>\ # delete all visible placements
<ESC>_Ga=d,d=i,i=10<ESC>\ # delete the image with id=10, without freeing data
<ESC>_Ga=d,d=i,i=10,p=7<ESC>\ # delete the image with id=10 and placement id=7, without freeing data
<ESC>_Ga=d,d=Z,z=-1<ESC>\ # delete the placements with z-index -1, also freeing up image data
<ESC>_Ga=d,d=p,x=3,y=4<ESC>\ # delete all placements that intersect the cell at (3, 4), without freeing data
Suppressing responses from the terminal
-------------------------------------------
If you are using the graphics protocol from a limited client, such as a shell
script, it might be useful to avoid having to process responses from the
terminal. For this, you can use the ``q`` key. Set it to ``1`` to suppress
``OK`` responses and to ``2`` to suppress failure responses.
.. versionadded:: 0.19.3
The ability to suppress responses (see :doc:`kittens/query_terminal` to query kitty version)
Requesting image ids from the terminal
-------------------------------------------
If you are writing a program that is going to share the screen with other
programs and you still want to use image ids, it is not possible to know
what image ids are free to use. In this case, instead of using the ``i``
key to specify an image id use the ``I`` key to specify an image number
instead. These numbers are not unique.
When creating a new image, even if an existing image has the same number a new
one is created. And the terminal will reply with the id of the newly created
image. For example, when creating an image with ``I=13``, the terminal will
send the response::
<ESC>_Gi=99,I=13;OK<ESC>\
Here, the value of ``i`` is the id for the newly created image and the value of
``I`` is the same as was sent in the creation command.
All future commands that refer to images using the image number, such as
creating placements or deleting images, will act on only the newest image with
that number. This allows the client program to send a bunch of commands dealing
with an image by image number without waiting for a response from the terminal
with the image id. Once such a response is received, the client program should
use the ``i`` key with the image id for all future communication.
.. note:: Specifying both ``i`` and ``I`` keys in any command is an error. The
terminal must reply with an EINVAL error message, unless silenced.
.. versionadded:: 0.19.3
The ability to use image numbers (see :doc:`kittens/query_terminal` to query kitty version)
.. _animation_protocol:
Animation
-------------------------------------------
.. versionadded:: 0.20.0
Animation support (see :doc:`kittens/query_terminal` to query kitty version)
When designing support for animation, the two main considerations were:
#. There should be a way for both client and terminal driven animations.
Since there is unknown and variable latency between client and terminal,
especially over SSH, client driven animations are not sufficient.
#. Animations often consist of small changes from one frame to the next, the
protocol should thus allow transmitting these deltas for efficiency and
performance reasons.
Animation support is added to the protocol by adding two new modes for the
``a`` (action) key. A ``f`` mode for transmitting frame data and an ``a`` mode
for controlling the animation of an image. Animation proceeds in two steps,
first a normal image is created as described earlier. Then animation frames are
added to the image to make it into an animation. Since every animation is
associated with a single image, all animation escape codes must specify either
the ``i`` or ``I`` keys to identify the image being operated on.
Transferring animation frame data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Transferring animation frame data is very similar to
:ref:`transferring_pixel_data` above. The main difference is that the image
the frame belongs to must be specified and it is possible to transmit data for
only part of a frame, declaring the rest of the frame to be filled in by data
from a previous frame, or left blank. To transfer frame data the ``a=f``
key must be used in all escape codes.
First, to transfer a simple frame that has data for the full image area, the
escape codes used are exactly the same as for transferring image data, with the
addition of: ``a=f,i=<image id>`` or ``a=f,I=<image number>``.
If the frame has data for only a part of the image, you can specify the
rectangle for it using the ``x, y, s, v`` keys, for example::
x=10,y=5,s=100,v=200 # A 100x200 rectangle with its top left corner at (10, 5)
Frames are created by composing the transmitted data onto a background canvas.
This canvas can be either a single color, or the pixels from a previous frame.
The composition can be of two types, either a simple replacement (``X=1``) key
or a full alpha blend (the default).
To use a background color for the canvas, specify the ``Y`` key as a 32-bit
RGBA color. For example::
Y=4278190335 # 0xff0000ff opaque red
Y=16711816 # 0x00ff0088 translucent green (alpha=0.53)
The default background color when none is specified is ``0`` i.e. a black,
transparent pixel.
To use the data from a previous frame, specify the ``c`` key which is a 1-based
frame number. Thus ``c=1`` refers to the root frame (the base image data),
``c=2`` refers to the second frame and so on.
If the frame is composed of multiple rectangular blocks, these can be expressed
by using the ``r`` key. When specifying the ``r`` key the data for an existing
frame is edited. The same composition operation as above happens, but now the
background canvas is the existing frame itself. ``r`` is a 1-based index, so
``r=1`` is the root frame (base image data), ``r=2`` is the second frame and so
on.
Finally, while transferring frame data, the frame *gap* can also be specified
using the ``z`` key. The gap is the number of milliseconds to wait before
displaying the next frame when the animation is running. A value of ``z=0`` is
ignored, ``z=positive number`` sets the gap to the specified number of
milliseconds and ``z=negative number`` creates a *gapless* frame. Gapless
frames are not displayed to the user since they are instantly skipped over,
however they can be useful as the base data for subsequent frames. For example,
for an animation where the background remains the same and a small object or two
move.
Controlling animations
~~~~~~~~~~~~~~~~~~~~~~~~~~
Clients can control animations by using the ``a=a`` key in the escape code sent
to the terminal.
The simplest is client driven animations, where the client transmits the frame
data and the also instructs the terminal to make a particular frame the current
frame. To change the current frame, use the ``c`` key::
<ESC>_Ga=a,i=3,c=7<ESC>\
This will make the seventh frame in the image with id ``3`` the current frame.
However, client driven animations can be sub-optimal, since the latency between
the client and terminal is unknown and variable especially over the network.
Also they require the client to remain running for the lifetime of the
animation, which is not desirable for cat like utilities.
Terminal driven animations are achieved by the client specifying *gaps* (time
in milliseconds) between frames and instructing the terminal to stop or start
the animation.
The animation state is controlled by the ``s`` key. ``s=1`` stops the
animation. ``s=2`` runs the animation, but in *loading* mode, in this mode when
reaching the last frame, instead of looping, the terminal will wait for the
arrival of more frames. ``s=3`` runs the animation normally, after the last
frame, the terminal loops back to the first frame. The number of loops can be
controlled by the ``v`` key. ``v=0`` is ignored, ``v=1`` is loop infinitely,
and any other positive number is loop ``number - 1`` times. Note that stopping
the animation resets the loop counter.
Finally, the *gap* for frames can be set using the ``z`` key. This can be
specified either when the frame is created as part of the transmit escape code
or separately using the animation control escape code. The *gap* is the time in
milliseconds to wait before displaying the next frame in the animation.
For example::
<ESC>_Ga=a,i=7,r=3,z=48<ESC>\
This sets the gap for the third frame of the image with id ``7`` to ``48``
milliseconds. Note that *gapless* frames are not displayed to the user since
the next frame comes immediately, however they can be useful to store base data
for subsequent frames, such as in an animation with an object moving against a
static background.
In particular, the first frame or *root frame* is created with the base image
data and has no gap, so its gap must be set using this control code.
Image persistence and storage quotas
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----------------------------------------
In order to avoid *Denial-of-Service* attacks, terminal emulators should have a
maximum storage quota for image data. It should allow at least a few full
screen images. For example the quota in kitty is 320MB per buffer. When adding
a new image, if the total size exceeds the quota, the terminal emulator should
delete older images to make space for the new one.
delete older images to make space for the new one. In kitty, for animations,
the additional frame data is stored on disk and has a separate, larger quota of
five times the base quota.
Control data reference
@@ -387,7 +654,13 @@ take, and the default value they take when missing. All integers are 32-bit.
Key Value Default Description
======= ==================== ========= =================
``a`` Single character. ``t`` The overall action this graphics command is performing.
``(t, T, q, p, d)``
``(t, T, q, p, d)`` ``t`` - transmit data, ``T`` - transmit data and display image,
``q`` - query terminal, ``p`` - put (display) previous transmitted image,
``d`` - delete image, ``f`` - transmit data for animation frames,
``a`` - control animation
``q`` ``0, 1, 2`` ``0`` Suppress responses from the terminal to this graphics command.
**Keys for image transmission**
-----------------------------------------------------------
``f`` Positive integer. ``32`` The format in which the image data is sent.
@@ -400,26 +673,63 @@ Key Value Default Description
``O`` Positive integer. ``0`` The offset from which to read data from a file.
``i`` Positive integer.
``(0 - 4294967295)`` ``0`` The image id
``I`` Positive integer.
``(0 - 4294967295)`` ``0`` The image number
``p`` Positive integer.
``(0 - 4294967295)`` ``0`` The placement id
``o`` Single character. ``null`` The type of data compression.
``only z``
``m`` zero or one ``0`` Whether there is more chunked data available.
**Keys for image display**
-----------------------------------------------------------
``x`` Positive integer ``0`` The left edge (in pixels) of the image area to display
``y`` Positive integer ``0`` The top edge (in pixels) of the image area to display
``w`` Positive integer ``0`` The width (in pixels) of the image area to display. By default, the entire width is used.
``w`` Positive integer ``0`` The width (in pixels) of the image area to display. By default, the entire width is used
``h`` Positive integer ``0`` The height (in pixels) of the image area to display. By default, the entire height is used
``X`` Positive integer ``0`` The x-offset within the first cell at which to start displaying the image
``Y`` Positive integer ``0`` The y-offset within the first cell at which to start displaying the image
``c`` Positive integer ``0`` The number of columns to display the image over
``r`` Positive integer ``0`` The number of rows to display the image over
``z`` Integer ``0`` The *z-index* vertical stacking order of the image
``C`` Positive integer ``0`` Cursor movement policy. ``0`` is the default, to move the cursor to after the image.
``1`` is to not move the cursor at all when placing the image.
``z`` 32-bit integer ``0`` The *z-index* vertical stacking order of the image
**Keys for animation frame loading**
-----------------------------------------------------------
``x`` Positive integer ``0`` The left edge (in pixels) of where the frame data should be updated
``y`` Positive integer ``0`` The top edge (in pixels) of where the frame data should be updated
``c`` Positive integer ``0`` The 1-based frame number of the frame whose image data serves as the base data
when creating a new frame, by default the base data is black, fully transparent pixels
``r`` Positive integer ``0`` The 1-based frame number of the frame that is being edited. By default, a new frame is created
``z`` 32-bit integer ``0`` The gap (in milliseconds) of this frame from the next one. A value of
zero is ignored. Negative values create a *gapless* frame. If not specified,
frames have a default gap of ``40ms``. The root frame defaults to zero gap.
``X`` Positive integer ``0`` The composition mode for blending pixels when creating a new frame or
editing a frame's data. The default is full alpha blending. ``1`` means a
simple overwrite.
``Y`` Positive integer ``0`` The background color for pixels not
specified in the frame data. Must be in 32-bit RGBA format
**Keys for animation control**
-----------------------------------------------------------
``s`` Positive integer ``0`` ``1`` - stop animation, ``2`` - run animation, but wait for new frames, ``3`` - run animation
``r`` Positive integer ``0`` The 1-based frame number of the frame that is being affected
``z`` 32-bit integer ``0`` The gap (in milliseconds) of this frame from the next one. A value of
zero is ignored. Negative values create a *gapless* frame.
``c`` Positive integer ``0`` The 1-based frame number of the frame that should be made the current frame
``v`` Positive integer ``0`` The number of loops to play. ``0`` is
ignored, ``1`` is play infinite and is the default and larger number
means play that number ``-1`` loops
**Keys for deleting images**
-----------------------------------------------------------
``d`` Single character. ``a`` What to delete.
``(a, A, c, C, i,
I, p, P, q, Q, x, X,
y, Y, z, Z)``.
``(a, A, c, C, n, N,
i, I, p, P, q, Q, x,
X, y, Y, z, Z)``.
======= ==================== ========= =================

View File

@@ -10,10 +10,12 @@ kitty - the fast, featureful, GPU based terminal emulator
buttery smooth scrolling. Uses threaded rendering to minimize input latency.
* Supports all modern terminal features: :doc:`graphics (images)
<graphics-protocol>`, unicode, true-color, OpenType ligatures, mouse
protocol, focus tracking, `bracketed paste
<https://cirw.in/blog/bracketed-paste>`_ and several :doc:`new terminal
protocol extensions <protocol-extensions>`.
<graphics-protocol>`, unicode, `true-color
<https://gist.github.com/XVilka/8346728>`_,
OpenType ligatures, mouse protocol, :doc:`hyperlinks <open_actions>`,
focus tracking, `bracketed paste <https://cirw.in/blog/bracketed-paste>`_
and several :doc:`new terminal protocol extensions
<protocol-extensions>`.
* Supports tiling multiple terminal windows side by side in different
:ref:`layouts <layouts>` without needing to use an extra program like tmux
@@ -47,6 +49,12 @@ kitty - the fast, featureful, GPU based terminal emulator
Screenshot, showing vim, tig and git running in |kitty| with the 'Tall' layout
.. contents::
:local:
:depth: 1
.. _quickstart:
Quickstart
@@ -56,26 +64,19 @@ Pre-built binaries of |kitty| are available for both macOS and Linux.
See the :doc:`binary install instructions </binary>`. You can also
:doc:`build from source </build>`.
You can also use your favorite package manager to install the |kitty| package.
|kitty| packages are available for:
`macOS with Homebrew (Cask) <https://formulae.brew.sh/cask/kitty>`_,
`macOS and Linux with Nix <https://nixos.org/nixos/packages.html#kitty>`_,
`Ubuntu <https://launchpad.net/ubuntu/+source/kitty>`_,
`Debian <https://packages.debian.org/buster/kitty>`_,
`openSUSE <https://build.opensuse.org/package/show/X11:terminals/kitty>`_,
`Arch Linux <https://www.archlinux.org/packages/community/x86_64/kitty/>`_,
`Gentoo <https://packages.gentoo.org/packages/x11-terms/kitty>`_,
`Fedora <https://copr.fedorainfracloud.org/coprs/gagbo/kitty-latest/>`_,
`Void Linux <https://github.com/void-linux/void-packages/blob/master/srcpkgs/kitty/template>`_,
and `Solus <https://dev.getsol.us/source/kitty/>`_.
Additionally, you can use your favorite package manager to install the |kitty|
package, but note that some Linux distribution packages are woefully outdated.
|kitty| is available in a vast number of package repositories for macOS
and Linux.
.. image:: https://repology.org/badge/tiny-repos/kitty.svg
:target: https://repology.org/project/kitty/versions
:alt: Number of repositories kitty is available in
See :doc:`Configuring kitty <conf>` for help on configuring |kitty| and
:doc:`Invocation <invocation>` for the command line arguments |kitty| supports.
.. contents::
Design philosophy
-------------------
@@ -97,164 +98,33 @@ styled (curly) underlines. One of the design goals of |kitty| is to be
easily extensible so that new features can be added in the future with
relatively little effort.
Tabs and Windows
-------------------
|kitty| is capable of running multiple programs organized into tabs and
windows. The top level of organization is the *Tab*. Each tab consists
of one or more *windows*. The windows can be arranged in multiple
different layouts, like windows are organized in a tiling window
manager. The keyboard controls (which are all customizable) for tabs and
windows are:
Scrolling
~~~~~~~~~~~~~~
======================== =======================
Action Shortcut
======================== =======================
Scroll line up :sc:`scroll_line_up` (also :kbd:`⌥+⌘+⇞` and :kbd:`⌘+↑` on macOS)
Scroll line down :sc:`scroll_line_down` (also :kbd:`⌥+⌘+⇟` and :kbd:`⌘+↓` on macOS)
Scroll page up :sc:`scroll_page_up` (also :kbd:`⌘+⇞` on macOS)
Scroll page down :sc:`scroll_page_down` (also :kbd:`⌘+⇟` on macOS)
Scroll to top :sc:`scroll_home` (also :kbd:`⌘+↖` on macOS)
Scroll to bottom :sc:`scroll_end` (also :kbd:`⌘+↘` on macOS)
======================== =======================
Tabs
~~~~~~~~~~~
======================== =======================
Action Shortcut
======================== =======================
New tab :sc:`new_tab` (also :kbd:`⌘+t` on macOS)
Close tab :sc:`close_tab` (also :kbd:`⌘+w` on macOS)
Next tab :sc:`next_tab` (also :kbd:`^+⇥` and :kbd:`⇧+⌘+]` on macOS)
Previous tab :sc:`previous_tab` (also :kbd:`⇧+^+⇥` and :kbd:`⇧+⌘+[` on macOS)
Next layout :sc:`next_layout`
Move tab forward :sc:`move_tab_forward`
Move tab backward :sc:`move_tab_backward`
Set tab title :sc:`set_tab_title` (also :kbd:`⇧+⌘+i` on macOS)
======================== =======================
Windows
~~~~~~~~~~~~~~~~~~
======================== =======================
Action Shortcut
======================== =======================
New window :sc:`new_window` (also :kbd:`⌘+↩` on macOS)
New OS window :sc:`new_os_window` (also :kbd:`⌘+n` on macOS)
Close window :sc:`close_window` (also :kbd:`⇧+⌘+d` on macOS)
Next window :sc:`next_window`
Previous window :sc:`previous_window`
Move window forward :sc:`move_window_forward`
Move window backward :sc:`move_window_backward`
Move window to top :sc:`move_window_to_top`
Focus specific window :sc:`first_window`, :sc:`second_window` ... :sc:`tenth_window`
(also :kbd:`⌘+1`, :kbd:`⌘+2` ... :kbd:`⌘+9` on macOS)
(clockwise from the top-left)
======================== =======================
Additionally, you can define shortcuts in :file:`kitty.conf` to focus neighboring
windows and move windows around (similar to window movement in vim)::
map ctrl+left neighboring_window left
map shift+left move_window right
map ctrl+down neighboring_window down
map shift+down move_window up
...
You can also define a shortcut to switch to the previously active window::
map ctrl+p nth_window -1
``nth_window`` will focus the nth window for positive numbers and the
previously active windows for negative numbers.
Other keyboard shortcuts
----------------------------------
================================== =======================
Action Shortcut
================================== =======================
Copy to clipboard :sc:`copy_to_clipboard` (also :kbd:`⌘+c` on macOS)
Paste from clipboard :sc:`paste_from_clipboard` (also :kbd:`⌘+v` on macOS)
Paste from selection :sc:`paste_from_selection`
Increase font size :sc:`increase_font_size` (also :kbd:`⌘++` on macOS)
Decrease font size :sc:`decrease_font_size` (also :kbd:`⌘+-` on macOS)
Restore font size :sc:`reset_font_size` (also :kbd:`⌘+0` on macOS)
Toggle fullscreen :sc:`toggle_fullscreen` (also :kbd:`^+⌘+f` on macOS)
Toggle maximized :sc:`toggle_maximized`
Input unicode character :sc:`input_unicode_character`
Click URL using the keyboard :sc:`open_url`
Reset the terminal :sc:`reset_terminal`
Pass current selection to program :sc:`pass_selection_to_program`
Edit |kitty| config file :sc:`edit_config_file`
Open a |kitty| shell :sc:`kitty_shell`
Increase background opacity :sc:`increase_background_opacity`
Decrease background opacity :sc:`decrease_background_opacity`
Full background opacity :sc:`full_background_opacity`
Reset background opacity :sc:`reset_background_opacity`
================================== =======================
.. include:: basic.rst
.. _layouts:
Layouts
----------
A layout is an arrangement of multiple *windows*. You can create a new window
A layout is an arrangement of multiple kitty *windows* inside a top-level OS window. You can create a new window
using the :sc:`new_window` key combination.
Currently, there are five layouts available,
Currently, there are seven layouts available:
* **Stack** -- Only a single maximized window is shown at a time
* **Tall** -- One window is shown full height on the left, the rest of the windows are shown one below the other on the right
* **Fat** -- One window is shown full width on the top, the rest of the windows are shown side-by-side on the bottom
* **Fat** -- One (or optionally more) windows are shown full width on the top, the rest of the windows are shown side-by-side on the bottom
* **Grid** -- All windows are shown in a grid
* **Horizontal** -- All windows are shown side-by-side
* **Splits** -- Windows arranged in arbitrary patterns created using horizontal and vertical splits
* **Stack** -- Only a single maximized window is shown at a time
* **Tall** -- One (or optionally more) windows are shown full height on the left, the rest of the windows are shown one below the other on the right
* **Vertical** -- All windows are shown one below the other
You can switch between layouts using the :sc:`next_layout` key combination. You can
also create shortcuts to select particular layouts, and choose which layouts
you want to enable/disable, see :ref:`conf-kitty-shortcuts.layout` for examples.
By default, all layouts are enabled and you can switch between layouts using
the :sc:`next_layout` key combination. You can also create shortcuts to select
particular layouts, and choose which layouts you want to enable/disable, see
:ref:`conf-kitty-shortcuts.layout` for examples. The first layout listed in
:opt:`enabled_layouts` becomes the default layout.
You can resize windows inside layouts. Press :sc:`start_resizing_window` (also :kbd:`⌘+r` on macOS) to
enter resizing mode and follow the on-screen instructions. In a given window
layout only some operations may be possible for a particular window. For
example, in the Tall layout you can make the first window wider/narrower, but
not taller/shorter. Note that what you are resizing is actually not a window,
but a row/column in the layout, all windows in that row/column will be resized.
You can also define shortcuts in :file:`kitty.conf` to make the active window
wider, narrower, taller, or shorter by mapping to the ``resize_window``
action, for example::
map ctrl+left resize_window narrower
map ctrl+right resize_window wider
map ctrl+up resize_window taller
map ctrl+down resize_window shorter 3
The ``resize_window`` action has a second, optional argument to control
the resizing increment (a positive integer that defaults to 1).
Some layouts take options to control their behavior. For example, the ``fat``
and ``tall`` layouts accept the ``bias`` option to control how the available
space is split up. To specify the option, in :opt:`kitty.conf <enabled_layouts>` use::
enabled_layouts tall:bias=70
This will make the tall window occupy ``70%`` of available width. ``bias`` can be
any number between 10 and 90.
Writing a new layout only requires about a hundred lines of code, so if there
is some layout you want, take a look at `layout.py
<https://github.com/kovidgoyal/kitty/blob/master/kitty/layout.py>`_ and submit
a pull request!
For more details on the layouts and how to use them see :doc:`layouts`.
.. _kittens:
@@ -281,13 +151,30 @@ Some prominent kittens:
:doc:`Hints <kittens/hints>`
Select and open/paste/insert arbitrary text snippets such as URLs,
filenames, words, lines, etc from the terminal screen.
filenames, words, lines, etc. from the terminal screen.
:doc:`Remote file <kittens/remote_file>`
Edit, open, or download remote files over SSH easily, by simply clicking on
the filename.
:doc:`Hyperlinked grep <kittens/hyperlinked_grep>`
Search your files using `ripgrep <https://github.com/BurntSushi/ripgrep>`_
and open the results directly in your favorite editor in the terminal,
at the line containing the search result, simply by clicking on the result you want.
:doc:`Broadcast <kittens/broadcast>`
Type in one kitty window and have it broadcast to all (or a subset) of
other kitty windows.
:doc:`Panel <kittens/panel>`
Draw a GPU accelerated dock panel on your desktop showing the output
from an arbitrary terminal program.
:doc:`Clipboard <kittens/clipboard>`
Copy/paste to the clipboard from shell scripts, even over SSH.
@@ -298,8 +185,9 @@ Configuring kitty
-------------------
|kitty| is highly configurable, everything from keyboard shortcuts to
painting frames-per-second. For details and a sample :file:`kitty.conf`,
see the :doc:`configuration docs <conf>`.
painting frames-per-second. Press :sc:`edit_config_file` in kitty
to open its fully commented sample config file in your text editor.
For details see the :doc:`configuration docs <conf>`.
Remote control
@@ -331,10 +219,9 @@ For example:
launch zsh
# Create a window with some environment variables set and run
# vim in it
launch env FOO=BAR vim
launch --env FOO=BAR vim
# Set the title for the next window
title Chat with x
launch irssi --profile x
launch --title "Chat with x" irssi --profile x
# Create a new tab (the part after new_tab is the optional tab
# name which will be displayed in the tab bar, if omitted, the
@@ -351,23 +238,38 @@ For example:
new_os_window
# set new window size to 80x25 cells
os_window_size 80c 25c
# set the --class for the new OS window
os_window_class mywindow
launch sh
# Make the current window the active (focused) window
focus
launch emacs
.. note::
The :doc:`launch <launch>` command when used in a session file
cannot create new OS windows, or tabs.
Mouse features
-------------------
* You can hold down :kbd:`ctrl+shift` and click on a URL to open it in a browser.
* You can click on a URL to open it in a browser.
* You can double click to select a word and then drag to select more words.
* You can triple click to select a line and then drag to select more lines.
* You can triple click while holding :kbd:`ctrl+alt` to select from clicked
point to end of line.
* You can right click to extend a previous selection.
* You can hold down :kbd:`ctrl+alt` and drag with the mouse to select in
columns.
* Selecting text automatically copies it to the primary clipboard (on
platforms with a primary clipboard).
* You can middle click to paste from the primary clipboard (on platforms
with a primary clipboard).
* You can select text with kitty even when a terminal program has grabbed
the mouse by holding down the :kbd:`shift` key.
All these actions can be customized in :file:`kitty.conf` as described
:ref:`here <conf-kitty-mouse.mousemap>`.
Font control
@@ -400,11 +302,15 @@ comfortably within the pager.
Additionally, you can pipe the contents of the scrollback buffer to an
arbitrary, command running in a new window, tab or overlay, for example::
map f1 pipe @ansi window less +G -R
map f1 launch --stdin-source=@screen_scrollback --stdin-add-formatting less +G -R
Would open the scrollback buffer in a new window when you press the :kbd:`F1`
key. See :sc:`show_scrollback` for details.
If you want to use it with an editor such as vim to get more powerful features,
you can see tips for doing so, in
`this thread <https://github.com/kovidgoyal/kitty/issues/719>`_.
If you wish to store very large amounts of scrollback to view using the piping or
:sc:`show_scrollback` features, you can use the :opt:`scrollback_pager_history_size`
option.
@@ -426,6 +332,14 @@ internal buffer named ``a`` and :kbd:`F2` to paste from that buffer. The buffer
names are arbitrary strings, so you can define as many such buffers as you
need.
Marks
-------------
kitty has the ability to mark text on the screen based on regular expressions.
This can be useful to highlight words or phrases when browsing output from long
running programs or similar. To learn how this feature works, see :doc:`marks`.
Frequently Asked Questions
---------------------------------
@@ -433,6 +347,15 @@ The list of Frequently Asked Questions (*FAQ*) is :doc:`available here <faq>`.
.. _completion:
Cool integrations for kitty with other CLI tools
--------------------------------------------------
kitty provides extremely powerful interfaces such as :doc:`remote-control` and
:doc:`kittens/custom` and :doc:`kittens/icat`
that allow it to be integrated with other tools seamlessly. For a list of such
user created integrations, see: :doc:`integrations`.
Completion for kitty
---------------------------------
@@ -448,6 +371,14 @@ Add the following to your :file:`~/.bashrc`
source <(kitty + complete setup bash)
Older versions of bash (for example, v3.2) do not support
process substitution with the source command, in which
case you can try an alternative:
.. code-block:: sh
source /dev/stdin <<<"$(kitty + complete setup bash)"
zsh
~~~~~~~~~
@@ -468,7 +399,8 @@ completions happens after the call to :file:`compinit`.
fish
~~~~~~~~
Add the following to your :file:`~/.config/fish/config.fish`
For versions of fish earlier than 3.0.0, add the following to your
:file:`~/.config/fish/config.fish`. Later versions source completions by default.
.. code-block:: sh
@@ -486,3 +418,4 @@ See :doc:`changelog`.
*
kittens/*
generated/rc

View File

@@ -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')

160
docs/integrations.rst Normal file
View File

@@ -0,0 +1,160 @@
Integrations with other tools
================================
kitty provides extremely powerful interfaces such as :doc:`remote-control` and
:doc:`kittens/custom` and :doc:`kittens/icat`
that allow it to be integrated with other tools seamlessly.
Image and document viewers
----------------------------
Powered by kitty's :doc:`graphics-protocol` there exist many tools for viewing
images and other types of documents directly in your terminal, even over SSH.
`termpdf.py <https://github.com/dsanson/termpdf.py>`_
a terminal PDF/DJVU/CBR viewer
`mdcat <https://github.com/lunaryorn/mdcat>`_
Display markdown files nicely formatted with images in the terminal
`ranger <https://github.com/ranger/ranger>`_
a terminal file manager, with previews of file contents powered by kitty's graphics protocol.
`nnn <https://github.com/jarun/nnn/>`_
another terminal file manager, with previews of file contents powered by kitty's graphics protocol.
`hunter <https://github.com/rabite0/hunter>`_
another terminal file manager, with previews of file contents powered by kitty's graphics protocol.
`koneko <https://github.com/twenty5151/koneko>`_
browse images from the pixiv artist community directly in kitty.
`viu <https://github.com/atanunq/viu>`_
view images in the terminal, similar to kitty's icat.
`nb <https://github.com/xwmx/nb>`_
command line and local web note-taking, bookmarking, archiving, and
knowledge base application that uses kitty's graphics protocol for images.
`w3m <https://github.com/tats/w3m>`_
A text mode WWW browser that supports kitty's graphics protocol to display
images.
`timg <https://github.com/hzeller/timg>`_
A terminal image and video viewer, that displays static and animated
images or plays videos. Fast multi-threaded loading, JPEG exif rotation,
grid view and connecting to the webcam make it a versatile terminal utility.
System and data visualisation tools
---------------------------------------
`neofetch <https://github.com/dylanaraps/neofetch>`_
A command line system information tool that shows images using kitty's graphics protocol
`matplotlib <https://github.com/jktr/matplotlib-backend-kitty>`_
show matplotlib plots directly in kitty
`KittyTerminalImages.jl <https://github.com/simonschoelly/KittyTerminalImages.jl>`_
show images from Julia directly in kitty
`euporie <https://github.com/joouha/euporie>`_
a text-based user interface for running and editing Jupyter notebooks,
powered by kitty's graphics protocol for displaying plots
`gnuplot <http://www.gnuplot.info/>`_
a graphing and data visualization tool that can be made to display its
output in kitty with the following bash snippet::
function iplot {
cat <<EOF | gnuplot
set terminal pngcairo enhanced font 'Fira Sans,10'
set autoscale
set samples 1000
set output '|kitty +kitten icat --stdin yes'
set object 1 rectangle from screen 0,0 to screen 1,1 fillcolor rgb"#fdf6e3" behind
plot $@
set output '/dev/null'
EOF
}
Add this to bashrc and then to plot a function, simply do::
iplot 'sin(x*3)*exp(x*.2)'
`onefetch <https://github.com/o2sh/onefetch>`_
a tool to fetch information about your git repositories
`patat <https://github.com/jaspervdj/patat>`_
terminal based presentations using pandoc and kitty's image protocol for
images
`wttr.in <https://github.com/chubin/wttr.in>`_
a tool to display weather information in your terminal with curl
`wl-clipboard-manager <https://github.com/maximbaz/wl-clipboard-manager>`_
view and manage the system clipboard under Wayland in your kitty terminal
`dmenu-term <https://github.com/maximbaz/dmenu-term>`_
run applications on your system with fuzzy find inside a kitty window
Editor integration
-----------------------
kitty can be integrated into many different terminal editors to add features
such a split windows, previews, REPLs etc.
`kakoune <https://kakoune.org/>`_
integrates with kitty to use native kitty windows for its windows/panels and REPLs.
`vim-slime <https://github.com/jpalardy/vim-slime#kitty>`_
uses kitty remote control for a Lisp REPL.
`vim-kitty-navigator <https://github.com/knubie/vim-kitty-navigator>`_
allows you to navigate seamlessly between vim and kitty splits using a consistent set of hotkeys.
`vim-test <https://github.com/vim-test/vim-test>`_
allows easily running tests in a terminal window
`hologram.nvim <https://github.com/edluffy/hologram.nvim>`_
terminal image viewer for nvim
Scrollback manipulation
-------------------------
`kitty-search <https://github.com/trygveaa/kitty-kitten-search>`_
Live incremental search of the scrollback buffer.
`kitty-grab <https://github.com/yurikhan/kitty_grab>`_
keyboard based text selection for the kitty scrollback buffer.
Miscellaneous
------------------
`kitty-smart-tab <https://github.com/yurikhan/kitty-smart-tab>`_
use keys to either control tabs or pass them onto running applications if
no tabs are present
`kitty-smart-scroll <https://github.com/yurikhan/kitty-smart-scroll>`_
use keys to either scroll or pass them onto running applications if
no scrollback buffer is present
`reload keybindings <https://github.com/kovidgoyal/kitty/issues/1292#issuecomment-582388769>`_
reload key bindings from :file:`kitty.conf` without needing to restart
kitty
`kitti3 <https://github.com/LandingEllipse/kitti3>`_
allow using kitty as a drop-down terminal under the i3 window manager
`weechat-hints <https://github.com/GermainZ/kitty-weechat-hints>`_
URL hints kitten for WeeChat that works without having to use WeeChat's
raw-mode.
`glkitty <https://github.com/michaeljclark/glkitty>`_
C library to draw OpenGL shaders in the terminal with a glgears demo

View File

@@ -4,3 +4,10 @@ The kitty command line interface
.. program:: kitty
.. include:: generated/cli-kitty.rst
.. include:: basic.rst
See also
-----------
See kitty.conf(5)

View File

@@ -1,128 +0,0 @@
Key encoding for extended keyboard protocol
===============================================
See :ref:`extended-key-protocol` for more information and `this table in JSON
format <https://github.com/kovidgoyal/kitty/blob/master/key_encoding.json>`_.
===================== ======================
Name Encoded representation
0 ``G``
1 ``H``
2 ``I``
3 ``J``
4 ``K``
5 ``L``
6 ``M``
7 ``N``
8 ``O``
9 ``P``
A ``S``
APOSTROPHE ``B``
B ``T``
BACKSLASH ``t``
BACKSPACE ``1``
C ``U``
CAPS LOCK ``:``
COMMA ``C``
D ``V``
DELETE ``3``
DOWN ``6``
E ``W``
END ``-``
ENTER ``z``
EQUAL ``R``
ESCAPE ``y``
F ``X``
F1 ``/``
F10 ``]``
F11 ``{``
F12 ``}``
F13 ``@``
F14 ``%``
F15 ``$``
F16 ``#``
F17 ``BA``
F18 ``BB``
F19 ``BC``
F2 ``*``
F20 ``BD``
F21 ``BE``
F22 ``BF``
F23 ``BG``
F24 ``BH``
F25 ``BI``
F3 ``?``
F4 ``&``
F5 ``<``
F6 ``>``
F7 ``(``
F8 ``)``
F9 ``[``
G ``Y``
GRAVE ACCENT ``v``
H ``Z``
HOME ``.``
I ``a``
INSERT ``2``
J ``b``
K ``c``
KP 0 ``BJ``
KP 1 ``BK``
KP 2 ``BL``
KP 3 ``BM``
KP 4 ``BN``
KP 5 ``BO``
KP 6 ``BP``
KP 7 ``BQ``
KP 8 ``BR``
KP 9 ``BS``
KP ADD ``BX``
KP DECIMAL ``BT``
KP DIVIDE ``BU``
KP ENTER ``BY``
KP EQUAL ``BZ``
KP MULTIPLY ``BV``
KP SUBTRACT ``BW``
L ``d``
LEFT ``5``
LEFT ALT ``Bc``
LEFT BRACKET ``s``
LEFT CONTROL ``Bb``
LEFT SHIFT ``Ba``
LEFT SUPER ``Bd``
M ``e``
MINUS ``D``
N ``f``
NUM LOCK ``=``
O ``g``
P ``h``
PAGE DOWN ``9``
PAGE UP ``8``
PAUSE ``!``
PERIOD ``E``
PRINT SCREEN ``^``
Q ``i``
R ``j``
RIGHT ``4``
RIGHT ALT ``Bg``
RIGHT BRACKET ``u``
RIGHT CONTROL ``Bf``
RIGHT SHIFT ``Be``
RIGHT SUPER ``Bh``
S ``k``
SCROLL LOCK ``+``
SEMICOLON ``Q``
SLASH ``F``
SPACE ``A``
T ``l``
TAB ``0``
U ``m``
UP ``7``
V ``n``
W ``o``
WORLD 1 ``w``
WORLD 2 ``x``
X ``p``
Y ``q``
Z ``r``
===================== ======================

654
docs/keyboard-protocol.rst Normal file
View File

@@ -0,0 +1,654 @@
A protocol for comprehensive keyboard handling in terminals
=================================================================
There are various problems with the current state of keyboard handling in
terminals. They include:
* No way to use modifiers other than ``ctrl`` and ``alt``
* No way to reliably use multiple modifier keys, other than, ``shift+alt`` and
``ctrl+alt``.
* Many of the existing escape codes used to encode these events are ambiguous
with different key presses mapping to the same escape code.
* No way to handle different types of keyboard events, such as press, release or repeat
* No reliable way to distinguish single ``Esc`` key presses from the start of a
escape sequence. Currently, client programs use fragile timing related hacks
for this, leading to bugs, for example:
`neovim #2035 <https://github.com/neovim/neovim/issues/2035>`_.
To solve these issues and others, kitty has created a new keyboard protocol,
that is backward compatible but allows applications to opt-in to support more
advanced usages. The protocol is based on initial work in `fixterms
<http://www.leonerd.org.uk/hacks/fixterms/>`_, however, it corrects various
issues in that proposal, listed at the :ref:`bottom of this document
<fixterms_bugs>`. For public discussion of this spec, see :iss:`3248`.
You can see this protocol with all enhancements in action by running::
kitty +kitten show_key -m kitty
inside the kitty terminal to report key events.
.. versionadded:: 0.20.0
Quickstart
---------------
If you are an application or library developer just interested in using this
protocol to make keyboard handling simpler and more robust in your application,
without too many changes, do the following:
#. Emit the escape code ``CSI > 1 u`` at application startup or when entering
alternate screen mode
#. All key events will now be sent in only a few forms to your application,
that are easy to parse unambiguously.
#. Emit the escape sequence ``CSI < u`` at application exit or just before
leaving alternate screen mode to restore the previously used keyboard mode.
Key events will all be delivered to your application either as plain UTF-8
text, or using the following escape codes, for those keys that do not produce
text (``CSI`` is the bytes ``0x1b 0x5b``)::
CSI number ; modifiers [u~]
CSI 1; modifiers [ABCDEFHPQRS]
0x0d - for the Enter key
0x7f or 0x08 - for Backspace
0x09 - for Tab
The ``number`` in the first form above will be either the Unicode codepoint for a
key, such as ``97`` for the :kbd:`a` key, or one of the numbers from the
:ref:`functional` table below. The ``modifiers`` optional parameter encodes any
modifiers pressed for the key event. The encoding is described in the
:ref:`modifiers` section.
The second form is used for a few functional keys, such as the :kbd:`Home, End,
Arrow keys and F1-F4`, they are enumerated in the :ref:`functional` table below.
Note that if no modifiers are present the parameters are omitted entirely
giving an escape code of the form ``CSI [ABCDEFHPQRS]``.
If you want support for more advanced features such as repeat and release
events, alternate keys for shortcut matching et cetera, these can be turned on
using :ref:`progressive_enhancement` as documented in the rest of this
specification.
An overview
------------------
Key events are divided into two types, those that produce text and those that
do not. When a key event produces text, the text is sent directly as UTF-8
encoded bytes. This is safe as UTF-8 contains no C0 control codes.
When the key event does not have text, the key event is encoded as an escape code. In
legacy compatibility mode (the default) this uses legacy escape codes, so old terminal
applications continue to work. Key events that could not be represented in
legacy mode are encoded using a ``CSI u`` escape code, that most terminal
programs should just ignore. For more advanced features, such as release/repeat
reporting etc., applications can tell the terminal they want this information by
sending an escape code to :ref:`progressively enhance <progressive_enhancement>` the data reported for
key events.
The central escape code used to encode key events is::
CSI unicode-key-code:alternate-key-codes ; modifiers:event-type ; text-as-codepoints u
Spaces in the above definition are present for clarity and should be ignored.
``CSI`` is the bytes ``0x1b 0x5b``. All parameters are decimal numbers. Fields
are separated by the semi-colon and sub-fields by the colon. Only the
``unicode-key-code`` field is mandatory, everything else is optional. The
escape code is terminated by the ``u`` character (the byte ``0x75``).
.. _key_codes:
Key codes
~~~~~~~~~~~~~~
The ``unicode-key-code`` above is the Unicode codepoint representing the key, as a
decimal number. For example, the :kbd:`A` key is represented as ``97`` which is
the unicode code for lowercase ``a``. Note that the codepoint used is *always*
the lower-case (or more technically, un-shifted) version of the key. If the
user presses, for example, :kbd:`ctrl+shift+a` the escape code would be ``CSI
97;modifiers u``. It *must not* be ``CSI 65; modifiers u``.
If *alternate key reporting* is requested by the program running in the
terminal, the terminal can send two additional Unicode codepoints, the
*shifted key* and *base layout key*, separated by colons.
The shifted key is simply the upper-case version of ``unicode-codepoint``, or
more technically, the shifted version. So `a` becomes `A` and so on, based on
the current keyboard layout. This is needed to be able to match against a
shortcut such as :kbd:`ctrl+plus` which depending on the type of keyboard could
be either :kbd:`ctrl+shift+equal` or :kbd:`ctrl+plus`. Note that the shifted
key must be present only if shift is also present in the modifiers.
The *base layout key* is the key corresponding to the physical key in the
standard PC-101 key layout. So for example, if the user is using a Cyrillic
keyboard with a Cyrillic keyboard layout pressing the :kbd:`ctrl+С` key will
be :kbd:`ctrl+c` in the standard layout. So the terminal should send the *base
layout key* as ``99`` corresponding to the ``c`` key.
If only one alternate key is present, it is the *shifted key* if the terminal
wants to send only a base layout key but no shifted key, it must use an empty
sub-field for the shifted key, like this::
CSI unicode-key-code::base-layout-key
.. _modifiers:
Modifiers
~~~~~~~~~~~~~~
This protocol supports six modifier keys, :kbd:`shift, alt, ctrl, super, hyper
and meta` as well as :kbd:`num_lock and caps_lock`. Here :kbd:`super` is either
the *Windows/Linux* key or the *Cmd* key on mac keyboards. :kbd:`hyper` and
:kbd:`meta` are typically present only on X11 based systems with special XKB
rules. Modifiers are encoded as a bit field with::
shift 0b1 (1)
alt 0b10 (2)
ctrl 0b100 (4)
super 0b1000 (8)
hyper 0b10000 (16)
meta 0b100000 (32)
caps_lock 0b1000000 (64)
num_lock 0b10000000 (128)
In the escape code, the modifier value is encoded as a decimal number which is
``1 + actual modifiers``. So to represent :kbd:`shift` only, the value would be ``1 +
1 = 2``, to represent :kbd:`ctrl+shift` the value would be ``1 + 0b101 = 6``
and so on. If the modifier field is not present in the escape code, its default
value is ``1`` which means no modifiers.
.. _event_types:
Event types
~~~~~~~~~~~~~~~~
There are three key event types: ``press, repeat and release``. They are
reported (if requested ``0b10``) as a sub-field of the modifiers field
(separated by a colon). If no modifiers are present, the modifiers field must
have the value ``1`` and the event type sub-field the type of event. The
``press`` event type has value ``1`` and is the default if no event type sub
field is present. The ``repeat`` type is ``2`` and the ``release`` type is
``3``. So for example::
CSI key-code # this is a press event
CSI key-code;modifier # this is a press event
CSI key-code;modifier:1 # this is a press event
CSI key-code;modifier:2 # this is a repeat event
CSI key-code;modifier:3 # this is a release event
.. note:: Key events that result in text are reported as plain UTF-8 text, so
events are not supported for them, unless the application requests *key
report mode*, see below.
.. _text_as_codepoints:
Text as code points
~~~~~~~~~~~~~~~~~~~~~
The terminal can optionally send the text associated with key events as a
sequence of Unicode code points. This behavior is opt-in by the :ref:`progressive
enhancement <progressive_enhancement>` mechanism described below. Some examples::
shift+a -> CSI 97 ; 2 ; 65 u # The text 'A' is reported as 65
option+a -> CSI 97 ; ; 229 u # The text 'å' is reported as 229
If multiple code points are present, they must be separated by colons.
If no known key is associated with the text the key number ``0`` must be used.
Non-Unicode keys
~~~~~~~~~~~~~~~~~~~~~~~
There are many keys that don't correspond to letters from human languages, and
thus aren't represented in Unicode. Think of functional keys, such as
:kbd:`Escape, Play, Pause, F1, Home, etc`. These are encoded using Unicode code
points from the Private Use Area (``57344 - 63743``). The mapping of key
names to code points for these keys is in the
:ref:`Functional key definition table below <functional>`.
.. _progressive_enhancement:
Progressive enhancement
--------------------------
While, in theory, every key event could be completely represented by this
protocol and all would be hunk-dory, in reality there is a vast universe of
existing terminal programs that expect legacy control codes for key events and
that are not likely to ever be updated. To support these, in default mode,
the terminal will emit legacy escape codes for compatibility. If a terminal
program wants more robust key handling, it can request it from the terminal,
via the mechanism described here. Each enhancement is described in detail
below. The escape code for requesting enhancements is::
CSI = flags ; mode u
Here ``flags`` is a decimal encoded integer to specify a set of bit-flags. The
meanings of the flags are given below. The second, ``mode`` parameter is
optional (defaulting to ``1``) and specifies how the flags are applied.
The value ``1`` means all set bits are set and all unset bits are reset.
The value ``2`` means all set bits are set, unset bits are left unchanged.
The value ``3`` means all set bits are reset, unset bits are left unchanged.
.. csv-table:: The progressive enhancement flags
:header: "Bit", "Meaning"
"0b1 (1)", ":ref:`disambiguate`"
"0b10 (2)", ":ref:`report_events`"
"0b100 (4)", ":ref:`report_alternates`"
"0b1000 (8)", ":ref:`report_all_keys`"
"0b10000 (16)", ":ref:`report_text`"
The program running in the terminal can query the terminal for the
current values of the flags by sending::
CSI ? u
The terminal will reply with::
CSI ? flags u
The program can also push/pop the current flags onto a stack in the
terminal with::
CSI > flags u # for push, if flags ommitted default to zero
CSI < number u # to pop number entries, defaulting to 1 if unspecified
Terminals should limit the size of the stack as appropriate, to prevent
Denial-of-Service attacks. Terminals must maintain separate stacks for the main
and alternate screens. If a pop request is received that empties the stack,
all flags are reset. If a push request is received and the stack is full, the
oldest entry from the stack must be evicted.
.. note:: In the interests of interoperation, the XTerm specific sequences
`CSI > 4; 1 m` and `CSI > 4; 0 m` are treated as `CSI > 1 u` and `CSI < 1 u`.
These codes cause XTerm to use the CSI u encoding for more keys and are therefore
treated as similar to the disambiguate progressive enhancement.
.. _disambiguate:
Disambiguate escape codes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This type of progressive enhancement (``0b1``) fixes the problem of some legacy key press
encodings overlapping with other control codes. For instance, pressing the
:kbd:`Esc` key generates the byte ``0x1b`` which also is used to indicate the
start of an escape code. Similarly pressing the key :kbd:`alt+[` will generate
the bytes used for CSI control codes.
Turning on this flag will cause the terminal to report the :kbd:`Esc, alt+key,
ctrl+key, ctrl+alt+key, shift+alt+key` keys using ``CSI u`` sequences instead
of legacy ones. Here key is any ASCII key as described in :ref:`legacy_text`.
Additionally, all keypad keys will be reported as separate keys with ``CSI u``
encoding, using dedicated numbers from the :ref:`table below <functional>`.
With this flag turned on, all key events that do not generate text are
represented in one of the following two forms::
CSI number; modifier u
CSI 1; modifier [~ABCDEFHPQRS]
This makes it very easy to parse key events in an application. In particular,
:kbd:`ctrl+c` will no longer generate the ``SIGINT`` signal, but instead be
delivered as a ``CSI u`` escape code. This has the nice side effect of making it
much easier to integrate into the application event loop. The only exceptions
are the :kbd:`Enter, Tab and Backspace` keys which still generate the same
bytes as in legacy mode this is to allow the user to type and execute commands
in the shell such as ``reset`` after a program that sets this mode crashes
without clearing it.
.. _report_events:
Report event types
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This progressive enhancement (``0b10``) causes the terminal to report key repeat
and key release events. Normally only key press events are reported and key
repeat events are treated as key press events. See :ref:`event_types` for
details on how these are reported.
.. _report_alternates:
Report alternate keys
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This progressive enhancement (``0b100``) causes the terminal to report
alternate key values in addition to the main value, to aid in shortcut
matching. See :ref:`key_codes` for details on how these are reported.
.. _report_all_keys:
Report all keys as escape codes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Key events that generate text, such as plain key presses without modifiers,
result in just the text being sent, in the legacy protocol. There is no way to
be notified of key repeat/release events. These types of events are needed for
some applications, such as games (think of movement using the ``WASD`` keys).
This progressive enhancement (``0b1000``) turns on key reporting even for key
events that generate text. When it is enabled, text will not be sent, instead
only key events are sent. If the text is needed as well, combine with the
Report associated text enhancement below.
Additionally, with this mode, events for pressing modifier keys are reported.
Note that *all* keys are reported as escape codes, including :kbd:`Enter, Tab,
Backspace` etc.
.. _report_text:
Report associated text
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This progressive enhancement (``0b10000``) causes key events that generate text
to be reported as ``CSI u`` escape codes with the text embedded in the escape
code. See :ref:`text_as_codepoints` above for details on the mechanism.
.. _detection:
Detection of support for this protocol
------------------------------------------
An application can query the terminal for support of this protocol by sending
the escape code querying for the :ref:`current progressive enhancement
<progressive_enhancement>` status
followed by request for the `primary device attributes
<https://vt100.net/docs/vt510-rm/DA1.html>`. If an answer for the device
attributes is received without getting back an answer for the progressive
enhancement the terminal does not support this protocol.
Legacy key event encoding
--------------------------------
In the default mode, the terminal uses a legacy encoding for key events. In
this encoding, only key press and repeat events are sent and there is no
way to distinguish between them. Text is sent directly as UTF-8 bytes.
Any key events not described in this section are sent using the standard
``CSI u`` encoding. This includes keys that are not encodable in the legacy
encoding, thereby increasing the space of usable key combinations even without
progressive enhancement.
Legacy functional keys
~~~~~~~~~~~~~~~~~~~~~~~~
These keys are encoded using three schemes::
CSI number ; modifier ~
CSI 1 ; modifier {ABCDEFHPQRS}
SS3 {ABCDEFHPQRS}
In the above, if there are no modifiers, the modifier parameter is omitted.
The modifier value is encoded as described in the :ref:`modifiers` section,
above. When the second form is used, the number is always ``1`` and must be
omitted if the modifiers field is also absent. The third form becomes the
second form when modifiers are present (``SS3 is the bytes 0x1b 0x4f``).
These sequences must match entries in the terminfo database for maximum
compatibility. The table below lists the key, its terminfo entry name and
the escape code used for it by kitty. A different terminal would use whatever
escape code is present in its terminfo database for the key.
Some keys have an alternate representation when the terminal is in *cursor key
mode* (the ``smkx/rmkx`` terminfo capabilities). This form is used only in
*cursor key mode* and only when no modifiers are present.
.. csv-table:: Legacy functional encoding
:header: "Name", "Terminfo name", "Escape code"
"INSERT", "kich1", "CSI 2 ~"
"DELETE", "kdch1", "CSI 3 ~"
"PAGE_UP", "kpp", "CSI 5 ~"
"PAGE_DOWN", "knp", "CSI 6 ~"
"UP", "cuu1,kcuu1", "CSI A, SS3 A"
"DOWN", "cud1,kcud1", "CSI B, SS3 B"
"RIGHT", "cuf1,kcuf1", "CSI C, SS3 C"
"LEFT", "cub1,kcub1", "CSI D, SS3 D"
"HOME", "home,khome", "CSI H, SS3 H"
"END", "-,kend", "CSI F, SS3 F"
"F1", "kf1", "SS3 P"
"F2", "kf2", "SS3 Q"
"F3", "kf3", "SS3 R"
"F4", "kf4", "SS3 S"
"F5", "kf5", "CSI 15 ~"
"F6", "kf6", "CSI 17 ~"
"F7", "kf7", "CSI 18 ~"
"F8", "kf8", "CSI 19 ~"
"F9", "kf9", "CSI 20 ~"
"F10", "kf10", "CSI 21 ~"
"F11", "kf11", "CSI 23 ~"
"F12", "kf12", "CSI 24 ~"
There are a few more functional keys that have special cased legacy encodings.
These are present because they are commonly used and for the sake of legacy
terminal applications that get confused when seeing CSI u escape codes:
.. csv-table:: C0 controls
:header: "Key", "No mods", "Ctrl", "Alt", "Shift", "Ctrl + Shift", "Alt + Shift", "Ctrl + Alt"
"Enter", "0xd", "0xd", "0x1b 0xd", "0xd", "0xd", "0x1b 0xd", "0x1b 0xd"
"Escape", "0x1b", "0x1b", "0x1b 0x1b", "0x1b", "0x1b", "0x1b 0x1b", "0x1b 0x1b"
"Backspace", "0x7f", "0x8", "0x1b 0x7f", "0x7f", "0x8", "0x1b 0x7f", "0x1b 0x8"
"Tab", "0x9", "0x9", "0x1b 0x9", "CSI Z", "CSI Z", "0x1b CSI Z", "0x1b 0x9"
"Space", "0x20", "0x0", "0x1b 0x20", "0x20", "0x0", "0x1b 0x20", "0x1b 0x0"
Note that :kbd:`Backspace` and :kbd:`ctrl+Backspace` are swapped in some
terminals, this can be detected using the ``kbs`` terminfo property that
must correspond to the :kbd:`Backspace` key.
All keypad keys are reported as their equivalent non-keypad keys. To
distinguish these, use the :ref:`disambiguate <disambiguate>` flag.
.. _legacy_text:
Legacy text keys
~~~~~~~~~~~~~~~~~~~
For legacy compatibility, the keys
:kbd:`a-z 0-9 \` - = [ ] \ ; ' , . /` with the modifiers
:kbd:`shift, alt, ctrl, shift+alt, ctrl+alt` are output using the
following algorithm:
#. If the :kbd:`alt` key is pressed output the byte for ``ESC (0x1b)``
#. If the :kbd:`ctrl` modifier is pressed map the key using the table
in :ref:`ctrl_mapping`.
#. Otherwise, if the :kbd:`shift` modifier is pressed, output the shifted key,
for example, ``A`` for ``a`` and ``$`` for ``4``.
#. Otherwise, output the key unmodified
Additionally, :kbd:`ctrl+space` is output as the NULL byte ``(0x0)``.
Any other combination of modifiers with these keys is output as the appropriate
``CSI u`` escape code.
.. csv-table:: Example encodings
:header: "Key", "Plain", "shift", "alt", "ctrl", "shift+alt", "alt+ctrl", "ctrl+shift"
"i", "i (105)", "I (73)", "ESC i", ") (41)", "ESC I", "ESC )", "CSI 105; 6 u"
"3", "3 (51)", "# (35)", "ESC 3", "3 (51)", "ESC #", "ESC 3", "CSI 51; 6 u"
";", "; (59)", ": (58)", "ESC ;", "; (59)", "ESC :", "ESC ;", "CSI 59; 6 u"
.. note::
Many of the legacy escape codes are ambiguous with multiple different key
presses yielding the same escape code(s), for example, :kbd:`ctrl+i` is the
same as :kbd:`tab`, :kbd:`ctrl+m` is the same as :kbd:`Enter`, :kbd:`ctrl+r`
is the same :kbd:`ctrl+shift+r`, etc. To resolve these use the
:ref:`disambiguate progressive enhancement <disambiguate>`.
.. _functional:
Functional key definitions
----------------------------
All numbers are in the Unicode Private Use Area (``57344 - 63743``) except
for a handful of keys that use numbers under 32 and 127 (C0 control codes) for legacy
compatibility reasons.
.. {{{
.. start functional key table (auto generated by gen-key-constants.py do not edit)
.. csv-table:: Functional key codes
:header: "Name", "CSI", "Name", "CSI"
"ESCAPE", "``27 u``", "ENTER", "``13 u``"
"TAB", "``9 u``", "BACKSPACE", "``127 u``"
"INSERT", "``2 ~``", "DELETE", "``3 ~``"
"LEFT", "``1 D``", "RIGHT", "``1 C``"
"UP", "``1 A``", "DOWN", "``1 B``"
"PAGE_UP", "``5 ~``", "PAGE_DOWN", "``6 ~``"
"HOME", "``1 H or 7 ~``", "END", "``1 F or 8 ~``"
"CAPS_LOCK", "``57358 u``", "SCROLL_LOCK", "``57359 u``"
"NUM_LOCK", "``57360 u``", "PRINT_SCREEN", "``57361 u``"
"PAUSE", "``57362 u``", "MENU", "``57363 u``"
"F1", "``1 P or 11 ~``", "F2", "``1 Q or 12 ~``"
"F3", "``1 R or 13 ~``", "F4", "``1 S or 14 ~``"
"F5", "``15 ~``", "F6", "``17 ~``"
"F7", "``18 ~``", "F8", "``19 ~``"
"F9", "``20 ~``", "F10", "``21 ~``"
"F11", "``23 ~``", "F12", "``24 ~``"
"F13", "``57376 u``", "F14", "``57377 u``"
"F15", "``57378 u``", "F16", "``57379 u``"
"F17", "``57380 u``", "F18", "``57381 u``"
"F19", "``57382 u``", "F20", "``57383 u``"
"F21", "``57384 u``", "F22", "``57385 u``"
"F23", "``57386 u``", "F24", "``57387 u``"
"F25", "``57388 u``", "F26", "``57389 u``"
"F27", "``57390 u``", "F28", "``57391 u``"
"F29", "``57392 u``", "F30", "``57393 u``"
"F31", "``57394 u``", "F32", "``57395 u``"
"F33", "``57396 u``", "F34", "``57397 u``"
"F35", "``57398 u``", "KP_0", "``57399 u``"
"KP_1", "``57400 u``", "KP_2", "``57401 u``"
"KP_3", "``57402 u``", "KP_4", "``57403 u``"
"KP_5", "``57404 u``", "KP_6", "``57405 u``"
"KP_7", "``57406 u``", "KP_8", "``57407 u``"
"KP_9", "``57408 u``", "KP_DECIMAL", "``57409 u``"
"KP_DIVIDE", "``57410 u``", "KP_MULTIPLY", "``57411 u``"
"KP_SUBTRACT", "``57412 u``", "KP_ADD", "``57413 u``"
"KP_ENTER", "``57414 u``", "KP_EQUAL", "``57415 u``"
"KP_SEPARATOR", "``57416 u``", "KP_LEFT", "``57417 u``"
"KP_RIGHT", "``57418 u``", "KP_UP", "``57419 u``"
"KP_DOWN", "``57420 u``", "KP_PAGE_UP", "``57421 u``"
"KP_PAGE_DOWN", "``57422 u``", "KP_HOME", "``57423 u``"
"KP_END", "``57424 u``", "KP_INSERT", "``57425 u``"
"KP_DELETE", "``57426 u``", "KP_BEGIN", "``1 E or 57427 ~``"
"MEDIA_PLAY", "``57428 u``", "MEDIA_PAUSE", "``57429 u``"
"MEDIA_PLAY_PAUSE", "``57430 u``", "MEDIA_REVERSE", "``57431 u``"
"MEDIA_STOP", "``57432 u``", "MEDIA_FAST_FORWARD", "``57433 u``"
"MEDIA_REWIND", "``57434 u``", "MEDIA_TRACK_NEXT", "``57435 u``"
"MEDIA_TRACK_PREVIOUS", "``57436 u``", "MEDIA_RECORD", "``57437 u``"
"LOWER_VOLUME", "``57438 u``", "RAISE_VOLUME", "``57439 u``"
"MUTE_VOLUME", "``57440 u``", "LEFT_SHIFT", "``57441 u``"
"LEFT_CONTROL", "``57442 u``", "LEFT_ALT", "``57443 u``"
"LEFT_SUPER", "``57444 u``", "LEFT_HYPER", "``57445 u``"
"LEFT_META", "``57446 u``", "RIGHT_SHIFT", "``57447 u``"
"RIGHT_CONTROL", "``57448 u``", "RIGHT_ALT", "``57449 u``"
"RIGHT_SUPER", "``57450 u``", "RIGHT_HYPER", "``57451 u``"
"RIGHT_META", "``57452 u``", "ISO_LEVEL3_SHIFT", "``57453 u``"
"ISO_LEVEL5_SHIFT", "``57454 u``"
.. end functional key table
.. }}}
Note that the escape codes above of the form ``CSI 1 letter`` will omit the
``1`` if there are no modifiers, since ``1`` is the default value.
.. _ctrl_mapping:
Legacy :kbd:`ctrl` mapping of ASCII keys
------------------------------------------
When the :kbd:`ctrl` key and another key are pressed on the keyboard, terminals
map the result *for some keys* to a *C0 control code* i.e. an value from ``0 -
31``. This mapping was historically dependent on the layout of hardware
terminal keyboards and is not specified anywhere, completely. The best known
reference is `Table 3-5 in the VT-100 docs <https://vt100.net/docs/vt100-ug/chapter3.html>`_.
The table below provides a mapping that is a commonly used superset of the table above.
Any ASCII keys not in the table must be left untouched by :kbd:`ctrl`.
.. {{{
.. start ctrl mapping (auto generated by gen-key-constants.py do not edit)
.. csv-table:: Emitted bytes when :kbd:`ctrl` is held down and a key is pressed
:header: "Key", "Byte", "Key", "Byte", "Key", "Byte"
"SPC ", "0", "/", "31", "0", "48"
"1", "49", "2", "0", "3", "27"
"4", "28", "5", "29", "6", "30"
"7", "31", "8", "127", "9", "57"
"?", "127", "@", "0", "[", "27"
"\\", "28", "]", "29", "^", "30"
"_", "31", "a", "1", "b", "2"
"c", "3", "d", "4", "e", "5"
"f", "6", "g", "7", "h", "8"
"i", "9", "j", "10", "k", "11"
"l", "12", "m", "13", "n", "14"
"o", "15", "p", "16", "q", "17"
"r", "18", "s", "19", "t", "20"
"u", "21", "v", "22", "w", "23"
"x", "24", "y", "25", "z", "26"
"~", "30"
.. end ctrl mapping
.. }}}
.. _fixterms_bugs:
Bugs in fixterms
-------------------
The following is a list of errata in the `original fixterms proposal
<http://www.leonerd.org.uk/hacks/fixterms/>`_, corrected in this
specification.
* No way to disambiguate :kbd:`Esc` key presses, other than using 8-bit controls
which are undesirable for other reasons
* Incorrectly claims special keys are sometimes encoded using ``CSI letter`` encodings when it
is actually ``SS3 letter`` in all terminals newer than a VT-52, which is
pretty much everything.
* :kbd:`ctrl+shift+tab` should be ``CSI 9 ; 6 u`` not ``CSI 1 ; 5 Z``
(shift+tab is not a separate key from tab)
* No support for the :kbd:`super` modifier.
* Makes no mention of cursor key mode and how it changes encodings
* Incorrectly encoding shifted keys when shift modifier is used, for instance,
for :kbd:`ctrl+shift+i` is encoded as :kbd:`ctrl+I`.
* No way to have non-conflicting escape codes for :kbd:`alt+letter,
ctrl+letter, ctrl+alt+letter` key presses
* No way to specify both shifted and unshifted keys for robust shortcut
matching (think matching :kbd:`ctrl+shift+equal` and :kbd:`ctrl+plus`)
* No way to specify alternate layout key. This is useful for keyboard layouts
such as Cyrillic where you want the shortcut :kbd:`ctrl+c` to work when
pressing the :kbd:`ctrl+С` on the keyboard.
* No way to report repeat and release key events, only key press events
* No way to report key events for presses that generate text, useful for
gaming. Think of using the :kbd:`WASD` keys to control movement.
* Only a small subset of all possible functional keys are assigned numbers.
* Claims the ``CSI u`` escape code has no fixed meaning, but has been used for
decades as ``SCORC`` for instance by xterm and ansi.sys and `DECSMBV
<https://vt100.net/docs/vt510-rm/DECSMBV.html>`_ by the VT-510 hardware
terminal. This doesn't really matter since these uses are for communication
to the terminal not from the terminal.
* Handwaves that :kbd:`ctrl` *tends to* mask with ``0x1f``. In actual fact it
does this only for some keys. The action of :kbd:`ctrl` is not specified and
varies between terminals, historically because of different keyboard layouts.

View File

@@ -0,0 +1,23 @@
broadcast - type text in all kitty windows
==================================================
The ``broadcast`` kitten can be used to type text simultaneously in
all kitty windows (or a subset as desired).
To use it, simply create a mapping in :file:`kitty.conf` such as::
map F1 launch --allow-remote-control kitty +kitten broadcast
Then press the :kbd:`F1` key and whatever you type in the newly created widow
will be sent to all kitty windows.
You can use the options described below to control which windows
are selected.
.. program:: kitty +kitten broadcast
Command Line Interface
--------------------------
.. include:: /generated/cli-kitten-broadcast.rst

View File

@@ -20,24 +20,27 @@ your machine).
.. code-block:: python
def main(args):
# this is the main entry point of the kitten, it will be executed in
# the overlay window when the kitten is launched
answer = input('Enter some text: ')
# whatever this function returns will be available in the
# handle_result() function
return answer
from typing import List
from kitty.boss import Boss
def handle_result(args, answer, target_window_id, boss):
# get the kitty window into which to paste answer
w = boss.window_id_map.get(target_window_id)
if w is not None:
w.paste(answer)
def main(args: List[str]) -> str:
# this is the main entry point of the kitten, it will be executed in
# the overlay window when the kitten is launched
answer = input('Enter some text: ')
# whatever this function returns will be available in the
# handle_result() function
return answer
def handle_result(args: List[str], answer: str, target_window_id: int, boss: Boss) -> None:
# get the kitty window into which to paste answer
w = boss.window_id_map.get(target_window_id)
if w is not None:
w.paste(answer)
Now in :file:`kitty.conf` add the lines::
map ctrl+k kitten mykitten.py
map ctrl+k kitten mykitten.py
Start kitty and press :kbd:`ctrl+k` and you should see the kitten running.
@@ -53,12 +56,13 @@ Passing arguments to kittens
You can pass arguments to kittens by defining them in the map directive in
:file:`kitty.conf`. For example::
map ctrl+k kitten mykitten.py arg1 arg2
map ctrl+k kitten mykitten.py arg1 arg2
These will be available as the ``args`` parameter in the ``main()`` and
``handle_result()`` functions. Note also that the current working directory
of the kitten is set to the working directory of whatever program is
running in the active kitty window.
running in the active kitty window. The special argument ``@selection``
is replaced by the currently selected text in the active kitty window.
Passing the contents of the screen to the kitten
@@ -70,23 +74,25 @@ function, telling kitty what kind of input your kitten would like. For example:
.. code-block:: py
# in main, STDIN is for the kitten process and will contain
# the contents of the screen
def main(args):
return sys.stdin.read()
# in main, STDIN is for the kitten process and will contain
# the contents of the screen
def main(args):
return sys.stdin.read()
# in handle_result, STDIN is for the kitty process itself, rather
# than the kitten process and should not be read from.
def handle_result(args, stdin_data, target_window_id, boss):
pass
# in handle_result, STDIN is for the kitty process itself, rather
# than the kitten process and should not be read from.
from kittens.tui.handler import result_handler
@result_handler(type_of_input='text')
def handle_result(args, stdin_data, target_window_id, boss):
pass
handle_result.type_of_input = 'text'
This will send the plain text of the active window to the kitten's
:file:`STDIN`. For text with formatting escape codes, use ``ansi``
instead. If you want line wrap markers as well, use ``screen-ansi``
or just ``screen``. For the scrollback buffer as well, use
``history``, ``ansi-history`` or ``screen-history``.
``history``, ``ansi-history`` or ``screen-history``. To get
the currently selected text, use ``selection``.
Using kittens to script kitty, without any terminal UI
@@ -103,23 +109,23 @@ Create a file in the kitty config folder, :file:`~/.config/kitty/zoom_toggle.py`
.. code-block:: py
def main(args):
pass
def main(args):
pass
def handle_result(args, answer, target_window_id, boss):
tab = boss.active_tab
if tab is not None:
if tab.current_layout.name == 'stack':
tab.last_used_layout()
else:
tab.goto_layout('stack')
handle_result.no_ui = True
from kittens.tui.handler import result_handler
@result_handler(no_ui=True)
def handle_result(args, answer, target_window_id, boss):
tab = boss.active_tab
if tab is not None:
if tab.current_layout.name == 'stack':
tab.last_used_layout()
else:
tab.goto_layout('stack')
Now in kitty.conf add::
map f11 kitten zoom_toggle.py
map f11 kitten zoom_toggle.py
Pressing :kbd:`F11` will now act as a zoom toggle function. You can get even
more fancy, switching the kitty OS window to fullscreen as well as changing the
@@ -128,7 +134,56 @@ layout, by simply adding the line::
boss.toggle_fullscreen()
to the ``handle_result()`` function, above.
To the ``handle_result()`` function, above.
.. _send_mouse_event:
Sending mouse events
--------------------
If the program running in a window is receiving mouse events you can simulate
those using::
from kitty.fast_data_types import send_mouse_event
send_mouse_event(screen, x, y, button, action, mods)
``screen`` is the ``screen`` attribute of the window you want to send the event
to. ``x`` and ``y`` are the 0-indexed coordinates. ``button`` is a number using
the same numbering as X11 (left: ``1``, middle: ``2``, right: ``3``, scroll up:
``4``, scroll down: ``5``, scroll left: ``6``, scroll right: ``7``, back:
``8``, forward: ``9``). ``action`` is one of ``PRESS``, ``RELEASE``, ``DRAG``
or ``MOVE``. ``mods`` is a bitmask of ``GLFW_MOD_{mod}`` where ``{mod}`` is one
of ``SHIFT``, ``CONTROL`` or ``ALT``. All the mentioned constants are imported
from ``kitty.fast_data_types``.
For example, to send a left click at position x: 2, y: 3 to the active window::
from kitty.fast_data_types import send_mouse_event, PRESS
send_mouse_event(boss.active_window.screen, 2, 3, 1, PRESS, 0)
The function will only send the event if the program is receiving events of
that type, and will return ``True`` if it sent the event, and ``False`` if not.
Debugging kittens
--------------------
The part of the kitten that runs in ``main()`` is just a normal program and
the output of print statements will be visible in the kitten window. Or
alternately, you can use::
from kittens.tui.loop import debug
debug('whatever')
The ``debug()`` function is just like ``print()`` except that the output
will appear in the ``STDOUT`` of the kitty process inside which the kitten is
running.
The ``handle_result()`` part of the kitten runs inside the kitty process.
The output of print statements will go to the ``STDOUT`` of the kitty process.
So if you run kitty from another kitty instance, the output will be visible
in the first kitty instance.
.. _external_kittens:
@@ -136,11 +191,15 @@ Kittens created by kitty users
---------------------------------------------
`vim-kitty-navigator <https://github.com/knubie/vim-kitty-navigator>`_
Allows you to navigate seamlessly between vim and kitty splits using a consistent set of hotkeys.
Allows you to navigate seamlessly between vim and kitty splits using a consistent set of hotkeys.
`smart-scroll <https://github.com/yurikhan/kitty-smart-scroll>`_
Makes the kitty scroll bindings work in full screen applications
Makes the kitty scroll bindings work in full screen applications
`insert password <https://github.com/kovidgoyal/kitty/issues/1222>`_
Insert a password from a CLI password manager, taking care to only do it at
a password prompt.
Insert a password from a CLI password manager, taking care to only do it at
a password prompt.
`weechat-hints <https://github.com/GermainZ/kitty-weechat-hints>`_
URL hints kitten for WeeChat that works without having to use WeeChat's
raw-mode.

View File

@@ -26,6 +26,7 @@ Major Features
Screenshot, showing a sample diff
.. contents::
:local:
Installation

View File

@@ -18,11 +18,77 @@ select anything that looks like a path or filename and then insert it into the
terminal, very useful for picking files from the output of a ``git`` or ``ls`` command and
adding them to the command line for the next command.
You can also press :sc:`goto_file_line` to select anything that looks
like a path or filename followed by a colon and a line number and open
the file in vim at the specified line number. The patterns and editor
to be used can be modified using options passed to the kitten. For example::
map ctrl+g kitten hints --type=linenum --linenum-action=tab nvim +{line} {path}
will open the selected file in a new tab inside neovim when you press
:kbd:`ctrl+g`.
Pressing :sc:`open_selected_hyperlink` will open hyperlinks, i.e. a URL
that has been marked as such by the program running in the terminal,
for example, by ``ls --hyperlink=auto``. You can also :doc:`customize what actions are
taken for different types of URLs <../open_actions>`.
The hints kitten is very powerful to see more detailed help on its various
options and modes of operation, see below. You can use these options to
create mappings in :file:`kitty.conf` to select various different text
snippets. See :sc:`insert_selected_path` for examples.
Completely customizing the matching and actions of the kitten
---------------------------------------------------------------
The hints kitten supports writing simple python scripts that can be used to
completely customize how it finds matches and what happens when a match is
selected. This allows the hints kitten to provide the user interface, while
you can provide the logic for finding matches and performing actions on them.
This is best illustrated with an example. Create the file
:file:`custom-hints.py` in the kitty config directory with the following
contents:
.. code-block:: python
import re
def mark(text, args, Mark, extra_cli_args, *a):
# This function is responsible for finding all
# matching text. extra_cli_args are any extra arguments
# passed on the command line when invoking the kitten.
# We mark all individual word for potential selection
for idx, m in enumerate(re.finditer(r'\w+', text)):
start, end = m.span()
mark_text = text[start:end].replace('\n', '').replace('\0', '')
# The empty dictionary below will be available as groupdicts
# in handle_result() and can contain arbitrary data.
yield Mark(idx, start, end, mark_text, {})
def handle_result(args, data, target_window_id, boss, extra_cli_args, *a):
# This function is responsible for performing some
# action on the selected text.
# matches is a list of the selected entries and groupdicts contains
# the arbitrary data associated with each entry in mark() above
matches, groupdicts = [], []
for m, g in zip(data['match'], data['groupdicts']):
if m:
matches.append(m), groupdicts.append(g)
for word, match_data in zip(matches, groupdicts):
# Lookup the word in a dictionary, the open_url function
# will open the provided url in the system browser
boss.open_url(f'https://www.google.com/search?q=define:{word}')
Now run kitty with::
kitty -o 'map f1 kitten hints --customize-processing custom-hints.py'
When you press the :kbd:`F1` key you will be able to select a word to
look it up in the Google dictionary.
Command Line Interface
-------------------------

View File

@@ -0,0 +1,71 @@
Hyperlinked grep
=================
This kitten allows you to search your files using `ripgrep
<https://www.google.com/search?q=ripgrep>`_ and open the results
directly in your favorite editor in the terminal, at the line containing
the search result, simply by clicking on the result you want.
.. versionadded:: 0.19.0
To set it up, first create :file:`~/.config/kitty/open-actions.conf` with the
following contents:
.. code:: conf
# Open any file with a fragment in vim, fragments are generated
# by the hyperlink_grep kitten and nothing else so far.
protocol file
fragment_matches [0-9]+
action launch --type=overlay vim +${FRAGMENT} ${FILE_PATH}
# Open text files without fragments in the editor
protocol file
mime text/*
action launch --type=overlay ${EDITOR} ${FILE_PATH}
Now, run a search with::
kitty +kitten hyperlinked_grep something
Hold down the :kbd:`ctrl+shift` keys and click on any of the
result lines, to open the file in vim at the matching line. If
you use some editor other than vim, you should adjust the
:file:`open-actions.conf` file accordingly.
Finally, add an alias to your shell's rc files to invoke the kitten as ``hg``::
alias hg='kitty +kitten hyperlinked_grep'
You can now run searches with::
hg some-search-term
If you want to enable completion, for the kitten, you can delegate completion
to rg. For that, instead of using an alias create a simple wrapper script named
:file:`hg` somewhere in your ``PATH``:
.. code-block:: sh
#!/bin/sh
exec kitty +kitten hyperlinked_grep "$@"
Then, for example, for ZSH, add the following to :file:`.zshrc`::
compdef _rg hg
To learn more about kitty's powerful framework for customizing URL click
actions, :doc:`see here <../open_actions>`.
Hopefully, someday this functionality will make it into some `upstream grep
<https://github.com/BurntSushi/ripgrep/issues/665>`_
program directly removing the need for this kitten.
.. note::
While you can pass any of ripgrep's comand line options to the kitten and
they will be forwarded to rg, do not use options that change the output
formatting as the kitten works by parsing the output from ripgrep.

View File

@@ -21,6 +21,12 @@ Then you can simply use ``icat image.png`` to view images.
`ImageMagick <https://www.imagemagick.org>`_ must be installed for ``icat`` to
work.
.. note::
kitty's image display protocol may not work when used within a terminal
multiplexer such as ``screen`` or ``tmux``, depending on whether the
multiplexer has added support for it or not.
.. program:: kitty +kitten icat

View File

@@ -0,0 +1,21 @@
Query terminal
=================
Used to query kitty from terminal programs about version, values of various
runtime options controlling its features, etc.
The querying is done using the (*semi*) standard XTGETTCAP escape sequence
pioneered by XTerm, so it works over SSH as well. The downside is that it
is slow, since it requires a roundtrip to the terminal emulator and back.
If you want to do some of the same querying in your terminal program without
depending on the kitten, you can do so, by processing the same escape codes.
Search `this page <https://invisible-island.net/xterm/ctlseqs/ctlseqs.html>`_
for *XTGETTCAP* to see the syntax for the escape code and read the source
of this kitten to find the values of the keys for the various queries.
Command Line Interface
-------------------------
.. include:: ../generated/cli-kitten-query_terminal.rst

View File

@@ -0,0 +1,37 @@
Remote files
==============
|kitty| has the ability to easily *Edit*, *Open* or *Download* files
from a computer into which you are SSHed. In your SSH session run::
ls --hyperlink=auto
Then hold down :kbd:`ctrl+shift` and click the name of the file.
.. figure:: ../screenshots/remote_file.png
:alt: Remote file actions
:align: center
:scale: 100%
Remote file actions
|kitty| will ask you what you want to do with the remote file. You can choose
to *Edit* it in which case kitty will download it and open it locally in your
``EDITOR``. As you make changes to the file, they are automatically transferred
to the remote computer. Note that this happens without needing to install *any*
special software on the server, beyond ``ls`` that supports hyperlinks.
.. versionadded:: 0.19.0
.. note::
Nested SSH sessions are not supported. The kitten will always try to copy
remote files from the first SSH host. This is because there is no way for
|kitty| to detect and follow a nested SSH session robustly.
.. note::
If you have not setup automatic password-less SSH access, then, when
editing starts you will be asked to enter your password just once,
thereafter the SSH connection will be re-used.
Similarly, you can choose to save the file to the local computer or download
and open it in its default file handler.

View File

@@ -18,7 +18,17 @@ typing a leading period and then the two character index and pressing Enter.
The up and down arrow keys can be used to choose the previous and next unicode
symbol respectively.
In :guilabel:`Name` mode you instead type words from the character name and use the arrow
keys/tab to select the character from the displayed matches. You can also type
a leading period and the index for the match if you don't like to use arrow
keys.
In :guilabel:`Name` mode you instead type words from the character name and use
the arrow keys/tab to select the character from the displayed matches. You can
also type a space followed by a period and the index for the match if you don't
like to use arrow keys.
You can switch between modes using either the function keys or by pressing
:kbd:`Ctrl+[` and :kbd:`Ctrl+]` or by pressing :kbd:`Ctrl+Tab` and
:kbd:`Ctrl+Shift+Tab`.
Command Line Interface
-------------------------
.. include:: ../generated/cli-kitten-unicode_input.rst

137
docs/launch.rst Normal file
View File

@@ -0,0 +1,137 @@
Launching programs in new windows/tabs
========================================
.. program:: launch
|kitty| has a :code:`launch` action that can be used to run arbitrary programs
in new windows/tabs. It can be mapped to user defined shortcuts in kitty.conf.
It is very powerful and allows sending the contents of
the current window to the launched program, as well as many other options.
In the simplest form, you can use it to open a new kitty window running the
shell, as shown below::
map f1 launch
To run a different program simply pass the command line as arguments to
launch::
map f1 launch vim path/to/some/file
To open a new window with the same working directory as the currently
active window::
map f1 launch --cwd=current
To open the new window in a new tab::
map f1 launch --type=tab
To run multiple commands in a shell, use::
map f1 launch sh -c "ls && zsh"
To pass the contents of the current screen and scrollback to the started process::
map f1 launch --stdin-source=@screen_scrollback less
There are many more powerful options, refer to the complete list below.
The piping environment
--------------------------
When using :option:`launch --stdin-source`, the program to which the data is
piped has a special environment variable declared, ``KITTY_PIPE_DATA`` whose
contents are::
KITTY_PIPE_DATA={scrolled_by}:{cursor_x},{cursor_y}:{lines},{columns}
where ``scrolled_by`` is the number of lines kitty is currently scrolled by,
``cursor_(x|y)`` is the position of the cursor on the screen with ``(1,1)``
being the top left corner and ``{lines},{columns}`` being the number of rows
and columns of the screen.
Special arguments
-------------------
There are a few special placeholder arguments that can be specified as part of
the command line:
``@selection``
replaced by the currently selected text
``@active-kitty-window-id``
replaced by the id of the currently active kitty window
``@line-count``
replaced by the number of lines in STDIN. Only present when passing some
data to STDIN
``@input-line-number``
replaced the number of lines a pager should scroll to match the current
scroll position in kitty. See :opt:`scrollback_pager` for details
``@scrolled-by``
replaced by the number of lines kitty is currently scrolled by
``@cursor-x``
replaced by the current cursor x position with 1 being the leftmost cell
``@cursor-y``
replaced by the current cursor y position with 1 being the topmost cell
For example::
map f1 launch my-program @active-kitty-window-id
Watching launched windows
---------------------------
The :option:`launch --watcher` option allows you to specify python functions
that will be called at specific events, such as when the window is resized or
closed. Simply specify the path to a python module that specifies callback
functions for the events you are interested in, for example:
.. code-block:: python
def on_resize(boss, window, data):
# Here data will contain old_geometry and new_geometry
def on_focus_change(boss, window, data):
# Here data kill contain focused
def on_close(boss, window, data):
# called when window is closed, typically when the program running in
# it exits.
Every callback is passed a reference to the global ``Boss`` object as well as
the ``Window`` object the action is occurring on. The ``data`` object is
mapping that contains event dependent data. Some useful methods and attributes
for the ``Window`` object are: ``as_text(as_ans=False, add_history=False,
add_wrap_markers=False, alternate_screen=False)`` with which you can get the
contents of the window and its scrollback buffer. Similarly,
``window.child.pid`` is the PID of the processes that was launched
in the window and ``window.id`` is the internal kitty ``id`` of the
window.
Finding executables
-----------------------
When you specify a command to run as just a name rather than an absolute path,
it is searched for in the system-wide ``PATH`` environment variable. Note that
this **may not** be the value of ``PATH`` inside a shell, as shell startup scripts
often change the value of this variable. If it is not found there, then a
system specific list of default paths is searched. If it is still not found,
then your shell is run and the value of ``PATH`` inside the shell is used.
Syntax reference
------------------
.. include:: /generated/launch.rst

261
docs/layouts.rst Normal file
View File

@@ -0,0 +1,261 @@
Layouts
============
kitty has the ability to define its own windows that can be tiled next to each
other in arbitrary arrangements, based on *Layouts*, see below for examples:
.. figure:: screenshots/screenshot.png
:alt: Screenshot, showing three programs in the 'Tall' layout
:align: center
:scale: 100%
Screenshot, showing vim, tig and git running in |kitty| with the 'Tall' layout
.. figure:: screenshots/splits.png
:alt: Screenshot, showing windows in the 'Splits' layout
:align: center
:scale: 100%
Screenshot, showing windows with arbitrary arrangement in the 'Splits'
layout
There are many different layouts available. They are all enabled by default,
you can switch layouts using :sc:`next_layout`. To control which layouts
are available use :opt:`enabled_layouts`, the first listed layout becomes
the default. Individual layouts and how to use them are described below.
.. contents::
:local:
The Stack Layout
------------------
This is the simplest layout it displays a single window using all available
space, other windows are hidden behind it. It has no options::
enabled_layouts stack
The Tall Layout
------------------
Displays one (or optionally more) full height windows on the left half of the
screen. Remaining windows are tiled vertically on the right half of the screen.
There are options to control how the screen is split horizontally ``bias``
(an integer between ``10`` and ``90``) and options to control how many
full-height windows there are ``full_size`` (a positive integer). The
``mirrored`` option when set to ``true`` will cause the short windows to be
on the left side of the screen instead of the right. The syntax
for the options is shown below::
enabled_layouts tall:bias=50;full_size=1;mirrored=false
┌──────────────┬───────────────┐
│ │ │
│ │ │
│ │ │
│ ├───────────────┤
│ │ │
│ │ │
│ │ │
│ ├───────────────┤
│ │ │
│ │ │
│ │ │
└──────────────┴───────────────┘
In addition, you can map keys to increase or decrease the number of full size
windows, for example::
map ctrl+[ layout_action decrease_num_full_size_windows
map ctrl+] layout_action increase_num_full_size_windows
The Fat Layout
----------------
Displays one (or optionally more) full width windows on the top half of the
screen. Remaining windows are tiled horizontally on the bottom half of the screen.
There are options to control how the screen is split vertically ``bias``
(an integer between ``10`` and ``90``) and options to control how many
full-height windows there are ``full_size`` (a positive integer). The
``mirrored`` option when set to ``true`` will cause the narrow windows to be
on the top of the screen instead of the bottom. The syntax for the options is
shown below::
enabled_layouts fat:bias=50;full_size=1;mirrored=false
┌──────────────────────────────┐
│ │
│ │
│ │
│ │
├─────────┬──────────┬─────────┤
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
└─────────┴──────────┴─────────┘
The Grid Layout
--------------------
Display windows in a balanced grid with all windows the same size except the
last column if there are not enough windows to fill the grid. Has no options::
enabled_layouts grid
┌─────────┬──────────┬─────────┐
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
├─────────┼──────────┼─────────┤
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
└─────────┴──────────┴─────────┘
.. _splits_layout:
The Splits Layout
--------------------
This is the most flexible layout. You can create any arrangement of windows
by splitting exiting windows repeatedly. To best use this layout you should
define a few extra keybindings in :file:`kitty.conf`::
map F5 launch --location=hsplit
map F6 launch --location=vsplit
map F7 layout_action rotate
map shift+up move_window up
map shift+left move_window left
map shift+right move_window right
map shift+down move_window down
map ctrl+left neighboring_window left
map ctrl+right neighboring_window right
map ctrl+up neighboring_window up
map ctrl+down neighboring_window down
Now you can create horizontal and vertical splits by using :kbd:`F5` and
:kbd:`F6`. You can move them around using :kbd:`shift+arrow keys`
and you can move focus to neighboring windows using :kbd:`ctrl+arrow keys`.
You can switch an existing split from horizontal to vertical and vice versa
using :kbd:`F7`. Finally, windows can be resized using :ref:`window_resizing`.
This layout takes one option, ``split_axis`` that controls whether new windows
are placed into vertical or horizontal splits, by default::
enabled_layouts splits:split_axis=horizontal
┌──────────────┬───────────────┐
│ │ │
│ │ │
│ │ │
│ ├───────┬───────┤
│ │ │ │
│ │ │ │
│ │ │ │
│ ├───────┴───────┤
│ │ │
│ │ │
│ │ │
└──────────────┴───────────────┘
.. versionadded:: 0.17.0
The Splits layout
The Horizontal Layout
------------------------
All windows are shown side by side. Has no options::
enabled_layouts horizontal
┌─────────┬──────────┬─────────┐
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
└─────────┴──────────┴─────────┘
The Vertical Layout
-----------------------
All windows are shown one below the other. Has no options::
enabled_layouts vertical
┌──────────────────────────────┐
│ │
│ │
│ │
├──────────────────────────────┤
│ │
│ │
│ │
├──────────────────────────────┤
│ │
│ │
│ │
└──────────────────────────────┘
.. _window_resizing:
Resizing windows
------------------
You can resize windows inside layouts. Press :sc:`start_resizing_window` (also
:kbd:`⌘+r` on macOS) to enter resizing mode and follow the on-screen
instructions. In a given window layout only some operations may be possible
for a particular window. For example, in the Tall layout you can make the first
window wider/narrower, but not taller/shorter. Note that what you are resizing
is actually not a window, but a row/column in the layout, all windows in that
row/column will be resized.
You can also define shortcuts in :file:`kitty.conf` to make the active window
wider, narrower, taller, or shorter by mapping to the ``resize_window``
action, for example::
map ctrl+left resize_window narrower
map ctrl+right resize_window wider
map ctrl+up resize_window taller
map ctrl+down resize_window shorter 3
The ``resize_window`` action has a second, optional argument to control
the resizing increment (a positive integer that defaults to 1).
Some layouts take options to control their behavior. For example, the ``fat``
and ``tall`` layouts accept the ``bias`` and ``full_size`` options to control
how the available space is split up.
To specify the option, in :opt:`kitty.conf <enabled_layouts>` use::
enabled_layouts tall:bias=70;full_size=2
This will have ``2`` instead of a single tall window, that occupy ``70%``
instead of ``50%`` of available width. ``bias`` can be any number between 10
and 90.
Writing a new layout only requires about two hundred lines of code, so if there
is some layout you want, take a look at one of the existing layouts in the
`layout <https://github.com/kovidgoyal/kitty/tree/master/kitty/layout>`_
package and submit a pull request!

125
docs/marks.rst Normal file
View File

@@ -0,0 +1,125 @@
Marks
=================
kitty has the ability to mark text on the screen based on regular expressions.
This can be useful to highlight words or phrases when browsing output from long
running programs or similar. Lets start with a few examples:
Suppose we want to be able to highlight the word ERROR in the current window.
Add the following to :file:`kitty.conf`::
map f1 toggle_marker text 1 ERROR
Now when you press :kbd:`F1` all instances of the word :code:`ERROR` will be
highlighted. To turn off the highlighting, press :kbd:`F1` again.
If you want to make it case-insensitive, use::
map f1 toggle_marker itext 1 ERROR
To make it match only complete words, use::
map f1 toggle_marker regex 1 \\bERROR\\b
Suppose you want to highlight both :code:`ERROR` and :code:`WARNING`, case
insensitively::
map f1 toggle_marker iregex 1 \\bERROR\\b 2 \\bWARNING\\b
kitty supports up to 3 mark groups (the numbers in the commands above). You
can control the colors used for these groups in :file:`kitty.conf` with::
mark1_foreground red
mark1_background gray
mark2_foreground green
...
.. note::
For performance reasons, matching is done per line only, and only when that line is
altered in any way. So you cannot match text that stretches across multiple
lines.
Creating markers dynamically
---------------------------------
If you want to create markers dynamically rather than pre-defining them in
:file:`kitty.conf` you can do so as follows::
map f1 create_marker
map f2 remove_marker
Then pressing :kbd:`F1` will allow you to enter the marker definition and set
it and pressing :kbd:`F2` will remove the marker. ``create_marker`` accepts
the same syntax as ``toggle_marker`` above. Note that while creating
markers, the prompt has history so you can easily re-use previous marker
expressions.
You can also use the facilities for :doc:`remote-control` to dynamically
add/remove markers.
Scrolling to marks
--------------------
kitty has an action to scroll to the next line that contains a mark. You can
use it by mapping it to some shortcut in :file:`kitty.conf`::
map ctrl+p scroll_to_mark prev
map ctrl+n scroll_to_mark next
Then pressing :kbd:`ctrl+p` will scroll to the first line in the scrollback
buffer above the current top line that contains a mark. Pressing :kbd:`ctrl+n`
will scroll to show the first line below the current last line that contains
a mark. If you wish to jump to a mark of a specific type, you can add that to
the mapping::
map ctrl+1 scroll_to_mark prev 1
Which will scroll only to marks of type 1.
The full syntax for creating marks
-------------------------------------
The syntax of the :code:`toggle_marker` command is::
toggle_marker <marker-type> <specification>
Here :code:`marker-type` is one of:
* :code:`text` - simple substring matching
* :code:`itext` - case-insensitive substring matching
* :code:`regex` - A python regular expression
* :code:`iregex` - A case-insensitive python regular expression
* :code:`function` - An arbitrary function defined in a python file, see
:ref:`marker_funcs`.
.. _marker_funcs:
Arbitrary marker functions
-----------------------------
You can create your own marker functions. Create a python file named
:file:`mymarker.py` and in it create a :code:`marker` function. This
function receives the text of the line as input and must yield three numbers,
the starting character position, the ending character position and the mark
group (1-3). For example:
.. code-block::
def marker(text):
# Function to highlight the letter X
for i, ch in enumerate(text):
if ch.lower() == 'x':
yield i, i, 3
Save this file somewhere and in :file:`kitty.conf`, use::
map f1 toggle_marker function /path/to/mymarker.py
If you save the file in the kitty config directory, you can use::
map f1 toggle_marker function mymarker.py

95
docs/open_actions.rst Normal file
View File

@@ -0,0 +1,95 @@
Customizing the actions taken when clicking on links
======================================================
|kitty| has support for `terminal hyperlinks <https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda>`_. These
are generated by many terminal programs, such as ``ls``, ``gcc``, ``systemd``,
``mdcat``, etc. You can customize exactly what happens when clicking on these hyperlinks
in |kitty|.
You can tell kitty to take arbitrarily many, complex actions
when a link is clicked. Let us illustrate with some examples, first. Create
the file :file:`~/.config/kitty/open-actions.conf` with the following:
.. code:: conf
# Open any image in the full kitty window by clicking on it
protocol file
mime image/*
action launch --type=overlay kitty +kitten icat --hold ${FILE_PATH}
Now, run ``ls --hyperlink=auto`` in kitty and click on the filename of an
image, holding down :kbd:`ctrl+shift`. It will be opened over the current
window. Press any key to close it.
Each entry in :file:`open-actions.conf` consists of one or more
:ref:`matching_criteria`, such as ``protocol`` and ``mime`` and one or more
``action`` entries. In the example above kitty uses the :doc:`launch <launch>`
action which can be used to run external programs. Entries are separated by
blank lines.
Actions are very powerful, anything that you can map to a key combination in
`kitty.conf` can be used as an action. You can specify more than one action per
entry if you like, for example:
.. code:: conf
# Tail a log file (*.log) in a new OS Window and reduce its font size
protocol file
ext log
action launch --title ${FILE} --type=os-window tail -f ${FILE_PATH}
action change_font_size current -2
In the action specification you can expand environment variables, as shown in
the examples above. In addition to regular environment variables, there are
some special variables, documented below:
``URL``
The full URL being opened
``FILE_PATH``
The path portion of the URL (unquoted)
``FILE``
The file portion of the path of the URL (unquoted)
``FRAGMENT``
The fragment (unquoted), if any of the URL or the empty string.
.. _matching_criteria:
Matching criteria
------------------
An entry in :file:`open-actions.conf` must have one or more matching criteria.
URLs that match all criteria for an entry will trigger that entry's actions.
Processing stops at the first matching entry, so put more specific matching
criteria at the start of the list. Entries in the file are separated by blank
lines. The various available criteria are:
``protocol``
A comma separated list of protocols, for example: ``http, https``. If
absent, there is no constraint on protocol
``url``
A regular expression that must match against the entire (unquoted) URL
``fragment_matches``
A regular expression that must match against the fragment (part after #) in
the URL
``mime``
A comma separated list of MIME types, for example: ``text/*, image/*,
application/pdf``. You can add MIME types to kitty by creating the
:file:`mime.types` in the kitty configuration directory. Useful if your
system MIME database does not have definitions you need. This file is
in the standard format of one definition per line, like: ``text/plain rst
md``.
``ext``
A comma separated list of file extensions, for example: ``jpeg, tar.gz``
``file``
A shell glob pattern that must match the filename, for example:
``image-??.png``

View File

@@ -14,12 +14,12 @@ render loop to reduce CPU usage. See :ref:`conf-kitty-performance` for details.
See also the :opt:`sync_to_monitor` option to further decrease latency at the cost
of some `tearing <https://en.wikipedia.org/wiki/Screen_tearing>`_ while scrolling.
You can generate detailed per-function performance data using
`gperftools <https://github.com/gperftools/gperftools>`_. Build |kitty| with
`make profile` which will create an executable called `kitty-profile`. Run
that and perform the task you want to analyse, for example, scrolling a large
file with `less`. After you quit, function call statistics will be printed to
`stdout` and you can use tools like *kcachegrind* for more detailed analysis.
You can generate detailed per-function performance data using `gperftools
<https://github.com/gperftools/gperftools>`_. Build |kitty| with `make
profile`. Run kitty and perform the task you want to analyse, for example,
scrolling a large file with `less`. After you quit, function call statistics
will be printed to `stdout` and you can use tools like *kcachegrind* for more
detailed analysis.
Here are some CPU usage numbers for the task of scrolling a file continuously
in less. The CPU usage is for the terminal process and X together and is

View File

@@ -1,6 +1,9 @@
Working with the screen and history buffer contents
======================================================
.. warning::
The pipe action has been deprecated in favor of the
:doc:`launch <launch>` action which is more powerful.
You can pipe the contents of the current screen and history buffer as
:file:`STDIN` to an arbitrary program using the ``pipe`` function. The program
@@ -43,6 +46,10 @@ You can choose where to run the pipe program:
``tab``
A new window in a new tab
``clipboard, primary``
Copy the text directly to the clipboard. In this case the specified program
is not run, so use some dummy program name for it.
``none``
Run it in the background
@@ -52,6 +59,9 @@ Input placeholders
There are various different kinds of placeholders
``@selection``
Plain text, currently selected text
``@text``
Plain text, current screen + scrollback buffer

View File

@@ -16,9 +16,11 @@ is to make it as easy to implement these protocol extensions as possible,
thereby hopefully encouraging their widespread adoption.
If you wish to discuss these extensions, propose additions/changes to them
please do so by opening issues in the github bug tracker.
please do so by opening issues in the `GitHub
<https://github.com/kovidgoyal/kitty/issues>`_ bug tracker.
.. contents::
:local:
Colored and styled underlines
-------------------------------
@@ -69,91 +71,9 @@ of this protocol to enable drawing of arbitrary raster images in the terminal.
Keyboard handling
-------------------
There are various problems with the current state of keyboard handling. They
include:
* No way to use modifiers other than ``Ctrl`` and ``Alt``
* No way to reliably use multiple modifier keys, other than, ``Shift+Alt``.
* No way to handle different types of keyboard events, such as press, release or repeat
* No reliable way to distinguish single ``Esc`` keypresses from the start of a
escape sequence. Currently, client programs use fragile timing related hacks
for this, leading to bugs, for example:
`neovim #2035 <https://github.com/neovim/neovim/issues/2035>`_.
There are already two distinct keyboard handling modes, *normal mode* and
*application mode*. These modes generate different escape sequences for the
various special keys (arrow keys, function keys, home/end etc.) Most terminals
start out in normal mode, however, most shell programs like ``bash`` switch them to
application mode. We propose adding a third mode, named *full mode* that addresses
the shortcomings listed above.
Switching to the new *full mode* is accomplished using the standard private
mode DECSET escape sequence::
<ESC>[?2017h
and to leave *full mode*, use DECRST::
<ESC>[?2017l
The number ``2017`` above is not used for any existing modes, as far as I know.
Client programs can query if the terminal emulator is in *full mode* by using
the standard `DECRQM <https://vt100.net/docs/vt510-rm/DECRQM.html>`_ escape sequence.
The new mode works as follows:
* All printable key presses without modifier keys are sent just as in the
*normal mode*. This means all printable ASCII characters and in addition,
``Enter``, ``Space`` and ``Backspace``. Also any unicode characters generated by
platform specific extended input modes, such as using the ``AltGr`` key. This
is done so that client programs that are not aware of this mode can still
handle basic text entry, so if a *full mode* using program crashes and does
not reset, the user can still issue a ``reset`` command in the shell to restore
normal key handling. Note that this includes pressing the ``Shift`` modifier
and printable keys. Note that this means there are no repeat and release
events for these keys and also for the left and right shift keys.
* For non printable keys and key combinations including one or more modifiers,
an escape sequence encoding the key event is sent. For details on the
escape sequence, see below.
The escape sequence encodes the following properties:
* Type of event: ``press,repeat,release``
* Modifiers pressed at the time of the event
* The actual key being pressed
Schematically::
<ESC>_K<type><modifiers><key><ESC>\
Where ``<type>`` is one of ``p`` -- press, ``r`` -- release and ``t`` -- repeat.
Modifiers is a bitmask represented as a single base64 digit. Shift -- ``0x1``,
Alt -- ``0x2``, Control -- ``0x4`` and Super -- ``0x8``. ``<key>`` is a number
(encoded in base85) corresponding to the key pressed. The key name to number
mapping is defined in :doc:`this table <key-encoding>`.
Client programs must ignore events for keys they do not know. The mapping in
the above table is stable and will never change, however, new codes might be
added to it in the future, for new keys.
For example::
<ESC>_KpGp<ESC>\ is <Ctrl>+<Alt>+x (press)
<ESC>_KrP8<ESC>\ is <Ctrl>+<Alt>+<Shift>+<Super>+PageUp (release)
This encoding means each key event is represented by 8 or 9 printable ascii
only bytes, for maximum robustness.
To see the full mode in action, run::
kitty +kitten key_demo
Support for this mode is indicated by the ``fullkbd`` boolean capability
in the terminfo database, in case querying for it via DECQRM is inconvenient.
kitty has a :doc:`keyboard protocol <keyboard-protocol>` for reporting key
presses to terminal applications that solves all key handling issues in
terminal applications.
.. _ext_styles:
@@ -180,23 +100,32 @@ rectangular region of the screen from (3, 4) to (10, 11), you use::
<ESC>[2*x<ESC>[4;3;11;10;44$r<ESC>[*x
Saving and restoring the default foreground/background/selection/cursor colors
Saving and restoring colors
---------------------------------------------------------------------------------
It is often useful for a full screen application with its own color themes
to set the default foreground, background, selection and cursor colors. This
allows for various performance optimizations when drawing the screen. The
problem is that if the user previously used the escape codes to change these
colors herself, then running the full screen application will lose her
changes even after it exits. To avoid this, kitty introduces a new pair of
*OSC* escape codes to push and pop the current color values from a stack::
It is often useful for a full screen application with its own color themes to
set the default foreground, background, selection and cursor colors and the
ANSI color table. This allows for various performance optimizations when
drawing the screen. The problem is that if the user previously used the escape
codes to change these colors herself, then running the full screen application
will lose her changes even after it exits. To avoid this, kitty introduces a
new pair of *OSC* escape codes to push and pop the current color values from a
stack::
<ESC>]30001<ESC>\ # push onto stack
<ESC>]30101<ESC>\ # pop from stack
These escape codes save/restore the so called *dynamic colors*, default
These escape codes save/restore the colors, default
background, default foreground, selection background, selection foreground and
cursor color.
cursor color and the 256 colors of the ANSI color table.
.. note:: In July 2020, after several years, XTerm copied this protocol
extension, without acknowledgement, and using incompatible escape codes
(XTPUSHCOLORS, XTPOPCOLORS, XTREPORTCOLORS). And they decided to save not
just the dynamic colors but the entire ANSI color table. In the interests of
promoting interoperability, kitty added support for XTerm's escape codes as
well, and changed this extension to also save/restore the entire ANSI color
table.
Pasting to clipboard
@@ -219,7 +148,172 @@ first, for example::
<ESC>]52;c;!<ESC>\
Here ``!`` is not valid base64 encoded text, so it clears the clipboard.
Further, since it is invalid, it should be ignored by terminal emulators
that do not support this extension, thereby making it safe to use, simply
always send it before starting a new OSC 52 paste, even if you aren't chunking
up large pastes, that way kitty won't concatenate your paste, and it will have
no ill-effects in other terminal emulators.
In case you're using software that can't be easily adapted to this
protocol extension, it can be disabled by specifying ``no-append`` to the
:opt:`clipboard_control` setting.
.. _unscroll:
Unscrolling the screen
-----------------------
This is a small extension to the `SD (Pan up) escape code
<https://vt100.net/docs/vt510-rm/SD.html>`_ from the VT-420 terminal. The
``SD`` escape code normally causes the text on screen to scroll down by the
specified number of lines, with empty lines appearing at the top of the screen.
This extension allows the new lines to be filled in from the scrollback buffer
instead of being blank.
The motivation for this is that many modern shells will show completions in a
block of lines under the cursor, this causes some of the on-screen text to be
lost even after the completion is completed, because it has scrolled off
screen. This escape code allows that text to be restored.
If the scrollback buffer is empty or there is no scrollback buffer, such as for
the alternate screen, then the newly inserted lines must be empty, just as with
the original ``SD`` escape code. The maximum number of lines that can be
scrolled down is implementation defined, but must be at least one screen worth.
The syntax of the escape code is identical to that of ``SD`` except that it has
a trailing ``+`` modifier. This is legal under the `ECMA 48 standard
<https://www.ecma-international.org/publications-and-standards/standards/ecma-48/>`_
and unused for any other purpose as far as I can tell. So for example, to
unscroll three lines, the escape code would be::
CSI 3 + T
See `discussion here
<https://gitlab.freedesktop.org/terminal-wg/specifications/-/issues/30>`_.
.. versionadded:: 0.20.2
.. _desktop_notifications:
Desktop notifications
---------------------------------
|kitty| implements an extensible escape code (OSC 99) to show desktop
notifications. It is easy to use from shell scripts and fully extensible to
show title and body. Clicking on the notification can optionally focus the
window it came from, and/or send an escape code back to the application running
in that window.
The design of the escape code is partially based on the discussion in
the defunct
`terminal-wg <https://gitlab.freedesktop.org/terminal-wg/specifications/-/issues/13>`_
The escape code has the form::
<OSC> 99 ; metadata ; payload <terminator>
Here ``<OSC>`` is :code:`<ESC>]` and ``<terminator>`` is
:code:`<ESC><backslash>`. The metadata is a section of colon separated
:code:`key=value` pairs. Every key must be a single character from the set
:code:`a-zA-Z` and every value must be a word consisting of characters from
the set :code:`a-zA-Z0-9-_/\+.,(){}[]*&^%$#@!`~`. The payload must be
interpreted based on the metadata section. The two semi-colons *must* always be
present even when no metadata is present.
Before going into details, lets see how one can display a simple, single line
notification from a shell script::
printf '\x1b]99;;Hello world\x1b\\'
To show a message with a title and a body::
printf '\x1b]99;i=1:d=0;Hello world\x1b\\'
printf '\x1b]99;i=1:d=1:p=body;This is cool\x1b\\'
The most important key in the metadata is the ``p`` key, it controls how the
payload is interpreted. A value of ``title`` means the payload is setting the
title for the notification. A value of ``body`` means it is setting the body,
and so on, see the table below for full details.
The design of the escape code is fundamentally chunked, this is because
different terminal emulators have different limits on how large a single escape
code can be. Chunking is accomplished by the ``i`` and ``d`` keys. The ``i``
key is the *notification id* which can be any string containing the characters
``[a-zA-Z0-9_-+.]``. The ``d`` key stands for *done* and
can only take the values ``0`` and ``1``. A value of ``0`` means the
notification is not yet done and the terminal emulator should hold off
displaying it. A value of ``1`` means the notification is done, and should be
displayed. You can specify the title or body multiple times and the terminal
emulator will concatenate them, thereby allowing arbitrarily long text
(terminal emulators are free to impose a sensible limit to avoid
Denial-of-Service attacks).
Both the ``title`` and ``body`` payloads must be either UTF-8 encoded plain
text with no embedded escape codes, or UTF-8 text that is base64 encoded, in
which case there must be an ``e=1`` key in the metadata to indicate the payload
is base64 encoded.
When the user clicks the notification, a couple of things can happen, the
terminal emulator can focus the window from which the notification came, and/or
it can send back an escape code to the application indicating the notification
was activated. This is controlled by the ``a`` key which takes a comma
separated set of values, ``report`` and ``focus``. The value ``focus`` means
focus the window from which the notification was issued and is the default.
``report`` means send an escape code back to the application. The format of the
returned escape code is::
<OSC> 99 ; i=identifier ; <terminator>
The value of ``identifier`` comes from the ``i`` key in the escape code sent by
the application. If the application sends no identifier, then the terminal
*must* use ``i=0``. Actions can be preceded by a negative sign to turn them
off, so for example if you do not want any action, turn off the default
``focus`` action with::
a=-focus
Complete specification of all the metadata keys is in the table below. If a
terminal emulator encounters a key in the metadata it does not understand,
the key *must* be ignored, to allow for future extensibility of this escape
code. Similarly if values for known keys are unknown, the terminal emulator
*should* either ignore the entire escape code or perform a best guess effort
to display it based on what it does understand.
.. note::
It is possible to extend this escape code to allow specifying an icon for
the notification, however, given that some platforms, such as macOS, dont
allow displaying custom icons on a notification, at all, it was decided to
leave it out of the spec for the time being.
Similarly, features such as scheduled notifications could be added in future
revisions.
======= ==================== ========= =================
Key Value Default Description
======= ==================== ========= =================
``a`` Comma separated list ``focus`` What action to perform when the
of ``report``, notification is clicked
``focus``, with
optional leading
``-``
``d`` ``0`` or ``1`` ``1`` Indicates if the notification is
complete or not.
``e`` ``0`` or ``1`` ``0`` If set to ``1`` means the payload is base64 encoded UTF-8,
otherwise it is plain UTF-8 text with no C0 control codes in it
``i`` ``[a-zA-Z0-9-_+.]`` ``0`` Identifier for the notification
``p`` One of ``title`` or ``title`` Whether the payload is the notification title or body. If a
``body``. notification has no title, the body will be used as title.
======= ==================== ========= =================
.. note::
|kitty| also supports the legacy OSC 9 protocol developed by iTerm2 for
desktop notifications.

41
docs/rc_protocol.rst Normal file
View File

@@ -0,0 +1,41 @@
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 of kitty has the
form::
<ESC>P@kitty-cmd<JSON object><ESC>\
Where ``<ESC>`` is the byte ``0x1b``. The JSON object has the form::
{
"cmd": "command name",
"version": <kitty version>,
"no_response": <Optional Boolean>,
"payload": <Optional JSON object>,
}
The ``version`` above is an array of the form :code:`[0, 14, 2]`. If you are developing a
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 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.
As a quick example showing how easy to use this protocol is, we will implement
the ``@ ls`` command from the shell using only shell tools. First, run kitty
as::
kitty -o allow_remote_control=socket-only --listen-on unix:/tmp/test
Now, in a different terminal, you can get the pretty printed ``@ ls`` output
with the following command line::
echo -en '\eP@kitty-cmd{"cmd":"ls","version":[0,14,2]}\e\' | socat - unix:/tmp/test | awk '{ print substr($0, 13, length($0) - 14) }' | jq -c '.data | fromjson' | jq .
.. include:: generated/rc.rst

View File

@@ -21,7 +21,7 @@ In order for control to work, :opt:`allow_remote_control` must be enabled in
Now, in the new |kitty| window, enter the command::
kitty @ new-window --title Output --keep-focus cat
kitty @ launch --title Output --keep-focus cat
This will open a new window, running the ``cat`` program that will appear next
to the current window.
@@ -54,7 +54,7 @@ window. Type ``Ctrl+D`` when you are ready to stop.
Now, let's open a new tab::
kitty @ new-window --new-tab --tab-title "My Tab" --keep-focus bash
kitty @ launch --type=tab --tab-title "My Tab" --keep-focus bash
This will open a new tab running the bash shell with the title "My Tab".
We can change the title of the tab with::
@@ -115,8 +115,10 @@ shell. Run ``kitty @`` with no arguments and you will be dropped into the |kitty
shell with completion for |kitty| command names and options.
You can even open the |kitty| shell inside a running |kitty| using a simple
keyboard shortcut (:sc:`kitty_shell` by default). This has the added
advantage that you don't need to use ``allow_remote_control`` to make it work.
keyboard shortcut (:sc:`kitty_shell` by default).
.. note:: This has the added advantage that you don't need to use
``allow_remote_control`` to make it work.
Allowing only some windows to control kitty
@@ -126,7 +128,7 @@ If you do not want to allow all programs running in |kitty| to control it, you c
enable remote control for only some |kitty| windows. Simply create a shortcut
such as::
map ctrl+k new_window @ some_program
map ctrl+k launch --allow-remote-control some_program
Then programs running in windows created with that shortcut can use ``kitty @``
to control kitty. Note that any program with the right level of permissions can
@@ -134,5 +136,46 @@ still write to the pipes of any other program on the same computer and
therefore can control |kitty|. It can, however, be useful to block programs
running on other computers (for example, over ssh) or as other users.
.. note:: You dont need ``allow_remote_control`` to make this work as it is
limited to only programs running in that specific window. Be careful with
what programs you run in such windows, since they can effectively control
kitty, as if you were running with ``allow_remote_control`` turned on.
Mapping key presses to remote control commands
--------------------------------------------------
If you wish to trigger a remote control command easily with just a keypress,
you can map it in :file:`kitty.conf`. For example::
map F1 remote_control set-spacing margin=30
Then pressing the :kbd:`F1` key will set the active window margins to 30.
The syntax for what follows :code:`remote_control` is exactly the same
as the syntax for what follows :code:`kitty @` above.
.. note:: You do not need ``allow_remote_control`` to use these mappings,
as they are not actual remote programs, but are simply a way to resuse
the remote control infrastructure via keybings.
Broadcasting what you type to all kitty windows
--------------------------------------------------
As a simple illustration of the power of remote control, lets
have what we type sent to all open kitty windows. To do that define the
following mapping in :file:`kitty.conf`::
map F1 launch --allow-remote-control kitty +kitten broadcast
Now press, F1 and start typing, what you type will be sent to all windows,
live, as you type it.
Documentation for the remote control protocol
-----------------------------------------------
If you wish to develop your own client to talk to |kitty|, you
can use the :doc:`rc_protocol`.
.. include:: generated/cli-kitty-at.rst

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

BIN
docs/screenshots/splits.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@@ -4,18 +4,23 @@
import subprocess
from collections import defaultdict
from typing import Any, DefaultDict, Dict, FrozenSet, List, Tuple, Union
KeymapType = Dict[str, Tuple[str, Union[FrozenSet[str], str]]]
def resolve_keys(keymap):
ans = defaultdict(list)
def resolve_keys(keymap: KeymapType) -> DefaultDict[str, List[str]]:
ans: DefaultDict[str, List[str]] = defaultdict(list)
for ch, (attr, atype) in keymap.items():
if atype not in ('int', 'uint'):
atype = 'flag'
ans[atype].append(ch)
if isinstance(atype, str) and atype in ('int', 'uint'):
q = atype
else:
q = 'flag'
ans[q].append(ch)
return ans
def enum(keymap):
def enum(keymap: KeymapType) -> str:
lines = []
for ch, (attr, atype) in keymap.items():
lines.append(f"{attr}='{ch}'")
@@ -26,15 +31,15 @@ def enum(keymap):
'''.format(',\n'.join(lines))
def parse_key(keymap):
def parse_key(keymap: KeymapType) -> str:
lines = []
for attr, atype in keymap.values():
vs = atype.upper() if atype in ('uint', 'int') else 'FLAG'
vs = atype.upper() if isinstance(atype, str) and atype in ('uint', 'int') else 'FLAG'
lines.append(f'case {attr}: value_state = {vs}; break;')
return ' \n'.join(lines)
def parse_flag(keymap, type_map, command_class):
def parse_flag(keymap: KeymapType, type_map: Dict[str, Any], command_class: str) -> str:
lines = []
for ch in type_map['flag']:
attr, allowed_values = keymap[ch]
@@ -52,14 +57,14 @@ def parse_flag(keymap, type_map, command_class):
return ' \n'.join(lines)
def parse_number(keymap):
def parse_number(keymap: KeymapType) -> Tuple[str, str]:
int_keys = [f'I({attr})' for attr, atype in keymap.values() if atype == 'int']
uint_keys = [f'U({attr})' for attr, atype in keymap.values() if atype == 'uint']
return '; '.join(int_keys), '; '.join(uint_keys)
def cmd_for_report(report_name, keymap, type_map, payload_allowed):
def group(atype, conv):
def cmd_for_report(report_name: str, keymap: KeymapType, type_map: Dict[str, Any], payload_allowed: bool) -> str:
def group(atype: str, conv: str) -> Tuple[str, str]:
flag_fmt, flag_attrs = [], []
cv = {'flag': 'c', 'int': 'i', 'uint': 'I'}[atype]
for ch in type_map[atype]:
@@ -84,7 +89,15 @@ def cmd_for_report(report_name, keymap, type_map, payload_allowed):
return '\n'.join(ans)
def generate(function_name, callback_name, report_name, keymap, command_class, initial_key='a', payload_allowed=True):
def generate(
function_name: str,
callback_name: str,
report_name: str,
keymap: KeymapType,
command_class: str,
initial_key: str = 'a',
payload_allowed: bool = True
) -> str:
type_map = resolve_keys(keymap)
keys_enum = enum(keymap)
handle_key = parse_key(keymap)
@@ -93,7 +106,7 @@ def generate(function_name, callback_name, report_name, keymap, command_class, i
report_cmd = cmd_for_report(report_name, keymap, type_map, payload_allowed)
if payload_allowed:
payload_after_value = "case ';': state = PAYLOAD; break;"
payload = payload = ', PAYLOAD'
payload = ', PAYLOAD'
parr = 'static uint8_t payload[4096];'
payload_case = f'''
case PAYLOAD: {{
@@ -124,6 +137,7 @@ static inline void
{parr}
{keys_enum}
enum KEYS key = '{initial_key}';
if (screen->parser_buf[pos] == ';') state = AFTER_VALUE;
while (pos < screen->parser_buf_pos) {{
switch(state) {{
@@ -225,7 +239,7 @@ static inline void
'''
def write_header(text, path):
def write_header(text: str, path: str) -> None:
with open(path, 'w') as f:
print(f'// This file is generated by {__file__} do not edit!', file=f, end='\n\n')
print('#pragma once', file=f)
@@ -233,16 +247,19 @@ def write_header(text, path):
subprocess.check_call(['clang-format', '-i', path])
def graphics_parser():
def graphics_parser() -> None:
flag = frozenset
keymap = {
'a': ('action', flag('tTqpd')),
'd': ('delete_action', flag('aAiIcCpPqQxXyYzZ')),
keymap: KeymapType = {
'a': ('action', flag('tTqpdfa')),
'd': ('delete_action', flag('aAiIcCfFnNpPqQxXyYzZ')),
't': ('transmission_type', flag('dfts')),
'o': ('compressed', flag('z')),
'f': ('format', 'uint'),
'm': ('more', 'uint'),
'i': ('id', 'uint'),
'I': ('image_number', 'uint'),
'p': ('placement_id', 'uint'),
'q': ('quiet', 'uint'),
'w': ('width', 'uint'),
'h': ('height', 'uint'),
'x': ('x_offset', 'uint'),
@@ -256,6 +273,7 @@ def graphics_parser():
'X': ('cell_x_offset', 'uint'),
'Y': ('cell_y_offset', 'uint'),
'z': ('z_index', 'int'),
'C': ('cursor_movement', 'uint'),
}
text = generate('parse_graphics_code', 'screen_handle_graphics_command', 'graphics_command', keymap, 'GraphicsCommand')
write_header(text, 'kitty/parse-graphics-command.h')

435
gen-config.py Executable file
View File

@@ -0,0 +1,435 @@
#!/usr/bin/env python
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
import inspect
import os
import pprint
import re
import textwrap
from typing import (
Any, Callable, Dict, Iterator, List, Set, Tuple, Union, get_type_hints
)
from kitty.conf.types import Definition, MultiOption, Option, unset
def chunks(lst: List, n: int) -> Iterator[List]:
for i in range(0, len(lst), n):
yield lst[i:i + n]
def atoi(text: str) -> str:
return f'{int(text):08d}' if text.isdigit() else text
def natural_keys(text: str) -> Tuple[str, ...]:
return tuple(atoi(c) for c in re.split(r'(\d+)', text))
def generate_class(defn: Definition, loc: str) -> Tuple[str, str]:
class_lines: List[str] = []
tc_lines: List[str] = []
a = class_lines.append
t = tc_lines.append
a('class Options:')
t('class Parser:')
choices = {}
imports: Set[Tuple[str, str]] = set()
tc_imports: Set[Tuple[str, str]] = set()
def type_name(x: type) -> str:
ans = x.__name__
if x.__module__ and x.__module__ != 'builtins':
imports.add((x.__module__, x.__name__))
return ans
def option_type_as_str(x: Any) -> str:
if hasattr(x, '__name__'):
return type_name(x)
ans = repr(x)
ans = ans.replace('NoneType', 'None')
return ans
def option_type_data(option: Union[Option, MultiOption]) -> Tuple[Callable, str]:
func = option.parser_func
if func.__module__ == 'builtins':
return func, func.__name__
th = get_type_hints(func)
rettype = th['return']
typ = option_type_as_str(rettype)
if isinstance(option, MultiOption):
typ = typ[typ.index('[') + 1:-1]
typ = typ.replace('Tuple', 'Dict', 1)
return func, typ
is_mutiple_vars = {}
option_names = set()
color_table = list(map(str, range(256)))
def parser_function_declaration(option_name: str) -> None:
t('')
t(f' def {option_name}(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:')
for option in sorted(defn.iter_all_options(), key=lambda a: natural_keys(a.name)):
option_names.add(option.name)
parser_function_declaration(option.name)
if isinstance(option, MultiOption):
mval: Dict[str, Dict[str, Any]] = {'macos': {}, 'linux': {}, '': {}}
func, typ = option_type_data(option)
for val in option:
if val.add_to_default:
gr = mval[val.only]
for k, v in func(val.defval_as_str):
gr[k] = v
is_mutiple_vars[option.name] = typ, mval
sig = inspect.signature(func)
tc_imports.add((func.__module__, func.__name__))
if len(sig.parameters) == 1:
t(f' for k, v in {func.__name__}(val):')
t(f' ans["{option.name}"][k] = v')
else:
t(f' for k, v in {func.__name__}(val, ans["{option.name}"]):')
t(f' ans["{option.name}"][k] = v')
continue
if option.choices:
typ = 'typing.Literal[{}]'.format(', '.join(repr(x) for x in option.choices))
ename = f'choices_for_{option.name}'
choices[ename] = typ
typ = ename
func = str
elif defn.has_color_table and option.is_color_table_color:
func, typ = option_type_data(option)
t(f' ans[{option.name!r}] = {func.__name__}(val)')
tc_imports.add((func.__module__, func.__name__))
cnum = int(option.name[5:])
color_table[cnum] = '0x{:06x}'.format(func(option.defval_as_string).__int__())
continue
else:
func, typ = option_type_data(option)
try:
params = inspect.signature(func).parameters
except Exception:
params = {}
if 'dict_with_parse_results' in params:
t(f' {func.__name__}(val, ans)')
else:
t(f' ans[{option.name!r}] = {func.__name__}(val)')
if func.__module__ != 'builtins':
tc_imports.add((func.__module__, func.__name__))
defval = repr(func(option.defval_as_string))
if option.macos_defval is not unset:
md = repr(func(option.macos_defval))
defval = f'{md} if is_macos else {defval}'
imports.add(('kitty.constants', 'is_macos'))
a(f' {option.name}: {typ} = {defval}')
if option.choices:
t(' val = val.lower()')
t(f' if val not in self.choices_for_{option.name}:')
t(f' raise ValueError(f"The value {{val}} is not a valid choice for {option.name}")')
t(f' ans["{option.name}"] = val')
t('')
t(f' choices_for_{option.name} = frozenset({option.choices!r})')
for option_name, (typ, mval) in is_mutiple_vars.items():
a(f' {option_name}: {typ} = ' '{}')
for parser, aliases in defn.deprecations.items():
for alias in aliases:
parser_function_declaration(alias)
tc_imports.add((parser.__module__, parser.__name__))
t(f' {parser.__name__}({alias!r}, val, ans)')
action_parsers = {}
def resolve_import(ftype: str) -> str:
if '.' in ftype:
fmod, ftype = ftype.rpartition('.')[::2]
else:
fmod = f'{loc}.options.utils'
imports.add((fmod, ftype))
return ftype
for aname, action in defn.actions.items():
option_names.add(aname)
action_parsers[aname] = func = action.parser_func
th = get_type_hints(func)
rettype = th['return']
typ = option_type_as_str(rettype)
typ = typ[typ.index('[') + 1:-1]
a(f' {aname}: typing.List[{typ}] = []')
for imp in action.imports:
resolve_import(imp)
for fname, ftype in action.fields.items():
ftype = resolve_import(ftype)
a(f' {fname}: {ftype} = ' '{}')
parser_function_declaration(aname)
t(f' for k in {func.__name__}(val):')
t(f' ans[{aname!r}].append(k)')
tc_imports.add((func.__module__, func.__name__))
if defn.has_color_table:
imports.add(('array', 'array'))
a(' color_table: array = array("L", (')
for grp in chunks(color_table, 8):
a(' ' + ', '.join(grp) + ',')
a(' ))')
a(' config_paths: typing.Tuple[str, ...] = ()')
a(' config_overrides: typing.Tuple[str, ...] = ()')
a('')
a(' def __init__(self, options_dict: typing.Optional[typing.Dict[str, typing.Any]] = None) -> None:')
a(' if options_dict is not None:')
a(' for key in option_names:')
a(' setattr(self, key, options_dict[key])')
a('')
a(' @property')
a(' def _fields(self) -> typing.Tuple[str, ...]:')
a(' return option_names')
a('')
a(' def __iter__(self) -> typing.Iterator[str]:')
a(' return iter(self._fields)')
a('')
a(' def __len__(self) -> int:')
a(' return len(self._fields)')
a('')
a(' def _copy_of_val(self, name: str) -> typing.Any:')
a(' ans = getattr(self, name)')
a(' if isinstance(ans, dict):\n ans = ans.copy()')
a(' elif isinstance(ans, list):\n ans = ans[:]')
a(' return ans')
a('')
a(' def _asdict(self) -> typing.Dict[str, typing.Any]:')
a(' return {k: self._copy_of_val(k) for k in self}')
a('')
a(' def _replace(self, **kw: typing.Any) -> "Options":')
a(' ans = Options()')
a(' for name in self:')
a(' setattr(ans, name, self._copy_of_val(name))')
a(' for name, val in kw.items():')
a(' setattr(ans, name, val)')
a(' return ans')
a('')
a(' def __getitem__(self, key: typing.Union[int, str]) -> typing.Any:')
a(' k = option_names[key] if isinstance(key, int) else key')
a(' try:')
a(' return getattr(self, k)')
a(' except AttributeError:')
a(' pass')
a(' raise KeyError(f"No option named: {k}")')
if defn.has_color_table:
a('')
a(' def __getattr__(self, key: str) -> typing.Any:')
a(' if key.startswith("color"):')
a(' q = key[5:]')
a(' if q.isdigit():')
a(' k = int(q)')
a(' if 0 <= k <= 255:')
a(' x = self.color_table[k]')
a(' return Color((x >> 16) & 255, (x >> 8) & 255, x & 255)')
a(' raise AttributeError(key)')
a('')
a(' def __setattr__(self, key: str, val: typing.Any) -> typing.Any:')
a(' if key.startswith("color"):')
a(' q = key[5:]')
a(' if q.isdigit():')
a(' k = int(q)')
a(' if 0 <= k <= 255:')
a(' self.color_table[k] = int(val)')
a(' return')
a(' object.__setattr__(self, key, val)')
a('')
a('')
a('defaults = Options()')
for option_name, (typ, mval) in is_mutiple_vars.items():
a(f'defaults.{option_name} = {mval[""]!r}')
if mval['macos']:
imports.add(('kitty.constants', 'is_macos'))
a('if is_macos:')
a(f' defaults.{option_name}.update({mval["macos"]!r}')
if mval['macos']:
imports.add(('kitty.constants', 'is_macos'))
a('if not is_macos:')
a(f' defaults.{option_name}.update({mval["linux"]!r}')
for aname, func in action_parsers.items():
a(f'defaults.{aname} = [')
only: Dict[str, List[Tuple[str, Callable]]] = {}
for sc in defn.iter_all_maps(aname):
if not sc.add_to_default:
continue
text = sc.parseable_text
if sc.only:
only.setdefault(sc.only, []).append((text, func))
else:
for val in func(text):
a(f' # {sc.name}')
a(f' {val!r},')
a(']')
if only:
imports.add(('kitty.constants', 'is_macos'))
for cond, items in only.items():
cond = 'is_macos' if cond == 'macos' else 'not is_macos'
a(f'if {cond}:')
for (text, func) in items:
for val in func(text):
a(f' defaults.{aname}.append({val!r})')
t('')
t('')
t('def create_result_dict() -> typing.Dict[str, typing.Any]:')
t(' return {')
for oname in is_mutiple_vars:
t(f' {oname!r}: {{}},')
for aname in defn.actions:
t(f' {aname!r}: [],')
t(' }')
t('')
t('')
t(f'actions = frozenset({tuple(defn.actions)!r})')
t('')
t('')
t('def merge_result_dicts(defaults: typing.Dict[str, typing.Any], vals: typing.Dict[str, typing.Any]) -> typing.Dict[str, typing.Any]:')
t(' ans = {}')
t(' for k, v in defaults.items():')
t(' if isinstance(v, dict):')
t(' ans[k] = merge_dicts(v, vals.get(k, {}))')
t(' elif k in actions:')
t(' ans[k] = v + vals.get(k, [])')
t(' else:')
t(' ans[k] = vals.get(k, v)')
t(' return ans')
tc_imports.add(('kitty.conf.utils', 'merge_dicts'))
t('')
t('')
t('parser = Parser()')
t('')
t('')
t('def parse_conf_item(key: str, val: str, ans: typing.Dict[str, typing.Any]) -> bool:')
t(' func = getattr(parser, key, None)')
t(' if func is not None:')
t(' func(val, ans)')
t(' return True')
t(' return False')
preamble = ['# generated by gen-config.py DO NOT edit', '# vim:fileencoding=utf-8', '']
a = preamble.append
def output_imports(imports: Set, add_module_imports: bool = True) -> None:
a('import typing')
seen_mods = {'typing'}
mmap: Dict[str, List[str]] = {}
for mod, name in imports:
mmap.setdefault(mod, []).append(name)
for mod in sorted(mmap):
names = sorted(mmap[mod])
lines = textwrap.wrap(', '.join(names), 100)
if len(lines) == 1:
s = lines[0]
else:
s = '\n '.join(lines)
s = f'(\n {s}\n)'
a(f'from {mod} import {s}')
if add_module_imports and mod not in seen_mods and mod != s:
a(f'import {mod}')
seen_mods.add(mod)
output_imports(imports)
a('')
if choices:
a('if typing.TYPE_CHECKING:')
for name, cdefn in choices.items():
a(f' {name} = {cdefn}')
a('else:')
for name in choices:
a(f' {name} = str')
a('')
a('option_names = ( # {{''{')
a(' ' + pprint.pformat(tuple(sorted(option_names, key=natural_keys)))[1:] + ' # }}''}')
class_def = '\n'.join(preamble + ['', ''] + class_lines)
preamble = ['# generated by gen-config.py DO NOT edit', '# vim:fileencoding=utf-8', '']
a = preamble.append
output_imports(tc_imports, False)
return class_def, '\n'.join(preamble + ['', ''] + tc_lines)
def generate_c_conversion(loc: str, ctypes: List[Option]) -> str:
lines: List[str] = []
basic_converters = {
'int': 'PyLong_AsLong', 'uint': 'PyLong_AsUnsignedLong', 'bool': 'PyObject_IsTrue',
'float': 'PyFloat_AsFloat', 'double': 'PyFloat_AsDouble',
'time': 'parse_s_double_to_monotonic_t', 'time-ms': 'parse_ms_long_to_monotonic_t'
}
for opt in ctypes:
lines.append('')
lines.append(f'static void\nconvert_from_python_{opt.name}(PyObject *val, Options *opts) ''{')
is_special = opt.ctype.startswith('!')
if is_special:
func = opt.ctype[1:]
lines.append(f' {func}(val, opts);')
else:
func = basic_converters.get(opt.ctype, opt.ctype)
lines.append(f' opts->{opt.name} = {func}(val);')
lines.append('}')
lines.append('')
lines.append(f'static void\nconvert_from_opts_{opt.name}(PyObject *py_opts, Options *opts) ''{')
lines.append(f' PyObject *ret = PyObject_GetAttrString(py_opts, "{opt.name}");')
lines.append(' if (ret == NULL) return;')
lines.append(f' convert_from_python_{opt.name}(ret, opts);')
lines.append(' Py_DECREF(ret);')
lines.append('}')
lines.append('')
lines.append('static bool\nconvert_opts_from_python_opts(PyObject *py_opts, Options *opts) ''{')
for opt in ctypes:
lines.append(f' convert_from_opts_{opt.name}(py_opts, opts);')
lines.append(' if (PyErr_Occurred()) return false;')
lines.append(' return true;')
lines.append('}')
preamble = ['// generated by gen-config.py DO NOT edit', '// vim:fileencoding=utf-8', '#pragma once', '#include "to-c.h"']
return '\n'.join(preamble + ['', ''] + lines)
def write_output(loc: str, defn: Definition) -> None:
cls, tc = generate_class(defn, loc)
with open(os.path.join(*loc.split('.'), 'options', 'types.py'), 'w') as f:
f.write(cls + '\n')
with open(os.path.join(*loc.split('.'), 'options', 'parse.py'), 'w') as f:
f.write(tc + '\n')
ctypes = []
for opt in defn.root_group.iter_all_non_groups():
if isinstance(opt, Option) and opt.ctype:
ctypes.append(opt)
if ctypes:
c = generate_c_conversion(loc, ctypes)
with open(os.path.join(*loc.split('.'), 'options', 'to-c-generated.h'), 'w') as f:
f.write(c + '\n')
def main() -> None:
from kitty.options.definition import definition
write_output('kitty', definition)
from kittens.diff.options.definition import definition as kd
write_output('kittens.diff', kd)
if __name__ == '__main__':
main()

412
gen-key-constants.py Executable file
View File

@@ -0,0 +1,412 @@
#!/usr/bin/env python
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
import string
from typing import Dict, List, Any
from pprint import pformat
functional_key_defs = '''# {{{
# kitty XKB macVK macU
escape Escape 0x35 -
enter Return 0x24 NSCarriageReturnCharacter
tab Tab 0x30 NSTabCharacter
backspace BackSpace 0x33 NSBackspaceCharacter
insert Insert 0x72 Insert
delete Delete 0x75 Delete
left Left 0x7B LeftArrow
right Right 0x7C RightArrow
up Up 0x7E UpArrow
down Down 0x7D DownArrow
page_up Page_Up 0x74 PageUp
page_down Page_Down 0x79 PageDown
home Home 0x73 Home
end End 0x77 End
caps_lock Caps_Lock 0x39 -
scroll_lock Scroll_Lock - ScrollLock
num_lock Num_Lock 0x47 ClearLine
print_screen Print - PrintScreen
pause Pause - Pause
menu Menu 0x6E Menu
f1 F1 0x7A F1
f2 F2 0x78 F2
f3 F3 0x63 F3
f4 F4 0x76 F4
f5 F5 0x60 F5
f6 F6 0x61 F6
f7 F7 0x62 F7
f8 F8 0x64 F8
f9 F9 0x65 F9
f10 F10 0x6D F10
f11 F11 0x67 F11
f12 F12 0x6F F12
f13 F13 0x69 F13
f14 F14 0x6B F14
f15 F15 0x71 F15
f16 F16 0x6A F16
f17 F17 0x40 F17
f18 F18 0x4F F18
f19 F19 0x50 F19
f20 F20 0x5A F20
f21 F21 - F21
f22 F22 - F22
f23 F23 - F23
f24 F24 - F24
f25 F25 - F25
f26 F26 - F26
f27 F27 - F27
f28 F28 - F28
f29 F29 - F29
f30 F30 - F30
f31 F31 - F31
f32 F32 - F32
f33 F33 - F33
f34 F34 - F34
f35 F35 - F35
kp_0 KP_0 0x52 -
kp_1 KP_1 0x53 -
kp_2 KP_2 0x54 -
kp_3 KP_3 0x55 -
kp_4 KP_4 0x56 -
kp_5 KP_5 0x57 -
kp_6 KP_6 0x58 -
kp_7 KP_7 0x59 -
kp_8 KP_8 0x5B -
kp_9 KP_9 0x5C -
kp_decimal KP_Decimal 0x41 -
kp_divide KP_Divide 0x4B -
kp_multiply KP_Multiply 0x43 -
kp_subtract KP_Subtract 0x4E -
kp_add KP_Add 0x45 -
kp_enter KP_Enter 0x4C NSEnterCharacter
kp_equal KP_Equal 0x51 -
kp_separator KP_Separator - -
kp_left KP_Left - -
kp_right KP_Right - -
kp_up KP_Up - -
kp_down KP_Down - -
kp_page_up KP_Page_Up - -
kp_page_down KP_Page_Down - -
kp_home KP_Home - -
kp_end KP_End - -
kp_insert KP_Insert - -
kp_delete KP_Delete - -
kp_begin KP_Begin - -
media_play XF86AudioPlay - -
media_pause XF86AudioPause - -
media_play_pause - - -
media_reverse - - -
media_stop XF86AudioStop - -
media_fast_forward XF86AudioForward - -
media_rewind XF86AudioRewind - -
media_track_next XF86AudioNext - -
media_track_previous XF86AudioPrev - -
media_record XF86AudioRecord - -
lower_volume XF86AudioLowerVolume - -
raise_volume XF86AudioRaiseVolume - -
mute_volume XF86AudioMute - -
left_shift Shift_L 0x38 -
left_control Control_L 0x3B -
left_alt Alt_L 0x3A -
left_super Super_L 0x37 -
left_hyper Hyper_L - -
left_meta Meta_L - -
right_shift Shift_R 0x3C -
right_control Control_R 0x3E -
right_alt Alt_R 0x3D -
right_super Super_R 0x36 -
right_hyper Hyper_R - -
right_meta Meta_R - -
iso_level3_shift ISO_Level3_Shift - -
iso_level5_shift ISO_Level5_Shift - -
''' # }}}
shift_map = {x[0]: x[1] for x in '`~ 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0) -_ =+ [{ ]} \\| ;: \'" ,< .> /?'.split()}
shift_map.update({x: x.upper() for x in string.ascii_lowercase})
functional_encoding_overrides = {
'insert': 2, 'delete': 3, 'page_up': 5, 'page_down': 6,
'home': 7, 'end': 8, 'tab': 9, 'f1': 11, 'f2': 12, 'f3': 13, 'enter': 13, 'f4': 14,
'f5': 15, 'f6': 17, 'f7': 18, 'f8': 19, 'f9': 20, 'f10': 21,
'f11': 23, 'f12': 24, 'escape': 27, 'backspace': 127
}
different_trailer_functionals = {
'up': 'A', 'down': 'B', 'right': 'C', 'left': 'D', 'kp_begin': 'E', 'end': 'F', 'home': 'H',
'f1': 'P', 'f2': 'Q', 'f3': 'R', 'f4': 'S', 'enter': 'u', 'tab': 'u',
'backspace': 'u', 'escape': 'u'
}
macos_ansi_key_codes = { # {{{
0x1D: ord('0'),
0x12: ord('1'),
0x13: ord('2'),
0x14: ord('3'),
0x15: ord('4'),
0x17: ord('5'),
0x16: ord('6'),
0x1A: ord('7'),
0x1C: ord('8'),
0x19: ord('9'),
0x00: ord('a'),
0x0B: ord('b'),
0x08: ord('c'),
0x02: ord('d'),
0x0E: ord('e'),
0x03: ord('f'),
0x05: ord('g'),
0x04: ord('h'),
0x22: ord('i'),
0x26: ord('j'),
0x28: ord('k'),
0x25: ord('l'),
0x2E: ord('m'),
0x2D: ord('n'),
0x1F: ord('o'),
0x23: ord('p'),
0x0C: ord('q'),
0x0F: ord('r'),
0x01: ord('s'),
0x11: ord('t'),
0x20: ord('u'),
0x09: ord('v'),
0x0D: ord('w'),
0x07: ord('x'),
0x10: ord('y'),
0x06: ord('z'),
0x27: ord('\''),
0x2A: ord('\\'),
0x2B: ord(','),
0x18: ord('='),
0x32: ord('`'),
0x21: ord('['),
0x1B: ord('-'),
0x2F: ord('.'),
0x1E: ord(']'),
0x29: ord(';'),
0x2C: ord('/'),
0x31: ord(' '),
} # }}}
functional_key_names: List[str] = []
name_to_code: Dict[str, int] = {}
name_to_xkb: Dict[str, str] = {}
name_to_vk: Dict[str, int] = {}
name_to_macu: Dict[str, str] = {}
start_code = 0xe000
for line in functional_key_defs.splitlines():
line = line.strip()
if not line or line.startswith('#'):
continue
parts = line.split()
name = parts[0]
functional_key_names.append(name)
name_to_code[name] = len(name_to_code) + start_code
if parts[1] != '-':
name_to_xkb[name] = parts[1]
if parts[2] != '-':
name_to_vk[name] = int(parts[2], 16)
if parts[3] != '-':
val = parts[3]
if not val.startswith('NS'):
val = f'NS{val}FunctionKey'
name_to_macu[name] = val
last_code = start_code + len(functional_key_names) - 1
ctrl_mapping = {
' ': 0, '@': 0, 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7,
'h': 8, 'i': 9, 'j': 10, 'k': 11, 'l': 12, 'm': 13, 'n': 14, 'o': 15, 'p': 16,
'q': 17, 'r': 18, 's': 19, 't': 20, 'u': 21, 'v': 22, 'w': 23, 'x': 24,
'y': 25, 'z': 26, '[': 27, '\\': 28, ']': 29, '^': 30, '~': 30, '/': 31,
'_': 31, '?': 127, '0': 48, '1': 49, '2': 0, '3': 27, '4': 28,
'5': 29, '6': 30, '7': 31, '8': 127, '9': 57
}
def patch_file(path: str, what: str, text: str, start_marker: str = '/* ', end_marker: str = ' */') -> None:
simple_start_q = f'{start_marker}start {what}{end_marker}'
start_q = f'{start_marker}start {what} (auto generated by gen-key-constants.py do not edit){end_marker}'
end_q = f'{start_marker}end {what}{end_marker}'
with open(path, 'r+') as f:
raw = f.read()
try:
start = raw.index(start_q)
except ValueError:
try:
start = raw.index(simple_start_q)
except ValueError:
raise SystemExit(f'Failed to find "{simple_start_q}" in {path}')
try:
end = raw.index(end_q)
except ValueError:
raise SystemExit(f'Failed to find "{end_q}" in {path}')
raw = raw[:start] + start_q + '\n' + text + '\n' + raw[end:]
f.seek(0)
f.truncate(0)
f.write(raw)
def serialize_dict(x: dict) -> str:
return pformat(x, indent=4).replace('{', '{\n ', 1)
def generate_glfw_header() -> None:
lines = [
'typedef enum {',
f' GLFW_FKEY_FIRST = 0x{start_code:x}u,',
]
klines, pyi, names, knames = [], [], [], []
for name, code in name_to_code.items():
lines.append(f' GLFW_FKEY_{name.upper()} = 0x{code:x}u,')
klines.append(f' ADDC(GLFW_FKEY_{name.upper()});')
pyi.append(f'GLFW_FKEY_{name.upper()}: int')
names.append(f' case GLFW_FKEY_{name.upper()}: return "{name.upper()}";')
knames.append(f' case GLFW_FKEY_{name.upper()}: return PyUnicode_FromString("{name}");')
lines.append(f' GLFW_FKEY_LAST = 0x{last_code:x}u')
lines.append('} GLFWFunctionKey;')
patch_file('glfw/glfw3.h', 'functional key names', '\n'.join(lines))
patch_file('kitty/glfw.c', 'glfw functional keys', '\n'.join(klines))
patch_file('kitty/fast_data_types.pyi', 'glfw functional keys', '\n'.join(pyi), start_marker='# ', end_marker='')
patch_file('glfw/input.c', 'functional key names', '\n'.join(names))
patch_file('kitty/glfw.c', 'glfw functional key names', '\n'.join(knames))
def generate_xkb_mapping() -> None:
lines, rlines = [], []
for name, xkb in name_to_xkb.items():
lines.append(f' case XKB_KEY_{xkb}: return GLFW_FKEY_{name.upper()};')
rlines.append(f' case GLFW_FKEY_{name.upper()}: return XKB_KEY_{xkb};')
patch_file('glfw/xkb_glfw.c', 'xkb to glfw', '\n'.join(lines))
patch_file('glfw/xkb_glfw.c', 'glfw to xkb', '\n'.join(rlines))
def generate_functional_table() -> None:
lines = [
'',
'.. csv-table:: Functional key codes',
' :header: "Name", "CSI", "Name", "CSI"',
''
]
line_items = []
enc_lines = []
tilde_trailers = set()
for name, code in name_to_code.items():
if name in functional_encoding_overrides or name in different_trailer_functionals:
trailer = different_trailer_functionals.get(name, '~')
if trailer == '~':
tilde_trailers.add(code)
code = oc = functional_encoding_overrides.get(name, code)
code = code if trailer in '~u' else 1
enc_lines.append((' ' * 8) + f"case GLFW_FKEY_{name.upper()}: S({code}, '{trailer}');")
if code == 1 and name not in ('up', 'down', 'left', 'right'):
trailer += f' or {oc} ~'
else:
trailer = 'u'
line_items.append(name.upper())
line_items.append(f'``{code}\xa0{trailer}``')
for li in chunks(line_items, 4):
lines.append(' ' + ', '.join(f'"{x}"' for x in li))
lines.append('')
patch_file('docs/keyboard-protocol.rst', 'functional key table', '\n'.join(lines), start_marker='.. ', end_marker='')
patch_file('kitty/key_encoding.c', 'special numbers', '\n'.join(enc_lines))
code_to_name = {v: k.upper() for k, v in name_to_code.items()}
csi_map = {v: name_to_code[k] for k, v in functional_encoding_overrides.items()}
letter_trailer_codes = {
v: functional_encoding_overrides.get(k, name_to_code.get(k))
for k, v in different_trailer_functionals.items() if v in 'ABCDEHFPQRSZ'}
text = f'functional_key_number_to_name_map = {serialize_dict(code_to_name)}'
text += f'\ncsi_number_to_functional_number_map = {serialize_dict(csi_map)}'
text += f'\nletter_trailer_to_csi_number_map = {letter_trailer_codes!r}'
text += f'\ntilde_trailers = {tilde_trailers!r}'
patch_file('kitty/key_encoding.py', 'csi mapping', text, start_marker='# ', end_marker='')
def generate_legacy_text_key_maps() -> None:
tests = []
tp = ' ' * 8
shift, alt, ctrl = 1, 2, 4
def simple(c: str) -> None:
shifted = shift_map.get(c, c)
ctrled = chr(ctrl_mapping.get(c, ord(c)))
call = f'enc(ord({c!r}), shifted_key=ord({shifted!r})'
for m in range(16):
if m == 0:
tests.append(f'{tp}ae({call}), {c!r})')
elif m == shift:
tests.append(f'{tp}ae({call}, mods=shift), {shifted!r})')
elif m == alt:
tests.append(f'{tp}ae({call}, mods=alt), "\\x1b" + {c!r})')
elif m == ctrl:
tests.append(f'{tp}ae({call}, mods=ctrl), {ctrled!r})')
elif m == shift | alt:
tests.append(f'{tp}ae({call}, mods=shift | alt), "\\x1b" + {shifted!r})')
elif m == ctrl | alt:
tests.append(f'{tp}ae({call}, mods=ctrl | alt), "\\x1b" + {ctrled!r})')
for k in shift_map:
simple(k)
patch_file('kitty_tests/keys.py', 'legacy letter tests', '\n'.join(tests), start_marker='# ', end_marker='')
def chunks(lst: List, n: int) -> Any:
"""Yield successive n-sized chunks from lst."""
for i in range(0, len(lst), n):
yield lst[i:i + n]
def generate_ctrl_mapping() -> None:
lines = [
'.. csv-table:: Emitted bytes when :kbd:`ctrl` is held down and a key is pressed',
' :header: "Key", "Byte", "Key", "Byte", "Key", "Byte"',
''
]
items = []
mi = []
for k in sorted(ctrl_mapping):
prefix = '\\' if k == '\\' else ('SPC' if k == ' ' else '')
items.append(prefix + k)
val = str(ctrl_mapping[k])
items.append(val)
if k in "\\'":
k = '\\' + k
mi.append(f" case '{k}': return {val};")
for line_items in chunks(items, 6):
lines.append(' ' + ', '.join(f'"{x}"' for x in line_items))
lines.append('')
patch_file('docs/keyboard-protocol.rst', 'ctrl mapping', '\n'.join(lines), start_marker='.. ', end_marker='')
patch_file('kitty/key_encoding.c', 'ctrl mapping', '\n'.join(mi))
def generate_macos_mapping() -> None:
lines = []
for k in sorted(macos_ansi_key_codes):
v = macos_ansi_key_codes[k]
lines.append(f' case 0x{k:x}: return 0x{v:x};')
patch_file('glfw/cocoa_window.m', 'vk to unicode', '\n'.join(lines))
lines = []
for name, vk in name_to_vk.items():
lines.append(f' case 0x{vk:x}: return GLFW_FKEY_{name.upper()};')
patch_file('glfw/cocoa_window.m', 'vk to functional', '\n'.join(lines))
lines = []
for name, mac in name_to_macu.items():
lines.append(f' case {mac}: return GLFW_FKEY_{name.upper()};')
patch_file('glfw/cocoa_window.m', 'macu to functional', '\n'.join(lines))
lines = []
for name, mac in name_to_macu.items():
lines.append(f' case GLFW_FKEY_{name.upper()}: return {mac};')
patch_file('glfw/cocoa_window.m', 'functional to macu', '\n'.join(lines))
def main() -> None:
generate_glfw_header()
generate_xkb_mapping()
generate_functional_table()
generate_legacy_text_key_maps()
generate_ctrl_mapping()
generate_macos_mapping()
if __name__ == '__main__':
main()

View File

@@ -12,6 +12,10 @@ from functools import partial
from html.entities import html5
from itertools import groupby
from operator import itemgetter
from typing import (
Callable, DefaultDict, Dict, FrozenSet, Generator, Iterable, List,
Optional, Set, Tuple, Union
)
from urllib.request import urlopen
os.chdir(os.path.dirname(os.path.abspath(__file__)))
@@ -24,15 +28,17 @@ if len(non_characters) != 66:
emoji_skin_tone_modifiers = frozenset(range(0x1f3fb, 0x1F3FF + 1))
def get_data(fname, folder='UCD'):
def get_data(fname: str, folder: str = 'UCD') -> Iterable[str]:
url = f'https://www.unicode.org/Public/{folder}/latest/{fname}'
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('#'):
@@ -40,23 +46,25 @@ def get_data(fname, folder='UCD'):
# Map of class names to set of codepoints in class
class_maps = {}
name_map = {}
word_search_map = defaultdict(set)
class_maps: Dict[str, Set[int]] = {}
all_symbols: Set[int] = set()
name_map: Dict[int, str] = {}
word_search_map: DefaultDict[str, Set[int]] = defaultdict(set)
zwj = 0x200d
marks = set(emoji_skin_tone_modifiers) | {zwj}
flag_codepoints = frozenset(range(0x1F1E6, 0x1F1E6 + 26))
marks = set(emoji_skin_tone_modifiers) | {zwj} | flag_codepoints
not_assigned = set(range(0, sys.maxunicode))
def parse_ucd():
def parse_ucd() -> None:
def add_word(w, c):
def add_word(w: str, c: int) -> None:
if c <= 32 or c == 127 or 128 <= c <= 159:
return
if len(w) > 1:
word_search_map[w.lower()].add(c)
first = None
first: Optional[int] = None
for word, c in html5.items():
if len(c) == 1:
add_word(word.rstrip(';'), ord(c))
@@ -74,7 +82,7 @@ def parse_ucd():
category = parts[2]
s = class_maps.setdefault(category, set())
desc = parts[1]
codepoints = (codepoint,)
codepoints: Union[Tuple[int, ...], Iterable[int]] = (codepoint,)
if first is None:
if desc.endswith(', First>'):
first = codepoint
@@ -87,50 +95,119 @@ def parse_ucd():
not_assigned.discard(codepoint)
if category.startswith('M'):
marks.add(codepoint)
elif category.startswith('S'):
all_symbols.add(codepoint)
with open('nerd-fonts-glyphs.txt') as f:
for line in f:
line = line.strip()
if not line or line.startswith('#'):
continue
code, category, name = line.split(' ', 2)
codepoint = int(code, 16)
if name and codepoint not in name_map:
name_map[codepoint] = name.upper()
for word in name.lower().split():
add_word(word, codepoint)
# Some common synonyms
word_search_map['bee'] |= word_search_map['honeybee']
word_search_map['lambda'] |= word_search_map['lamda']
word_search_map['lamda'] |= word_search_map['lambda']
word_search_map['diamond'] |= word_search_map['gem']
def split_two(line):
spec, rest = line.split(';', 1)
spec, rest = spec.strip(), rest.strip().split(' ', 1)[0].strip()
def parse_range_spec(spec: str) -> Set[int]:
spec = spec.strip()
if '..' in spec:
chars = tuple(map(lambda x: int(x, 16), filter(None, spec.split('.'))))
chars = set(range(chars[0], chars[1] + 1))
chars_ = tuple(map(lambda x: int(x, 16), filter(None, spec.split('.'))))
chars = set(range(chars_[0], chars_[1] + 1))
else:
chars = {int(spec, 16)}
return chars, rest
return chars
all_emoji = set()
emoji_categories = {}
emoji_presentation_bases = set()
def split_two(line: str) -> Tuple[Set[int], str]:
spec, rest = line.split(';', 1)
spec, rest = spec.strip(), rest.strip().split(' ', 1)[0].strip()
return parse_range_spec(spec), rest
def parse_emoji():
for line in get_data('emoji-data.txt', 'emoji'):
chars, rest = split_two(line)
s = emoji_categories.setdefault(rest, set())
s.update(chars)
all_emoji.update(chars)
for line in get_data('emoji-variation-sequences.txt', 'emoji'):
base, var, *rest = line.split()
if base.startswith('#'):
all_emoji: Set[int] = set()
emoji_presentation_bases: Set[int] = set()
narrow_emoji: Set[int] = set()
wide_emoji: Set[int] = set()
flags: Dict[int, List[int]] = {}
def parse_basic_emoji(spec: str) -> None:
parts = list(filter(None, spec.split()))
has_emoji_presentation = len(parts) < 2
chars = parse_range_spec(parts[0])
all_emoji.update(chars)
emoji_presentation_bases.update(chars)
(wide_emoji if has_emoji_presentation else narrow_emoji).update(chars)
def parse_keycap_sequence(spec: str) -> None:
base, fe0f, cc = list(filter(None, spec.split()))
chars = parse_range_spec(base)
all_emoji.update(chars)
emoji_presentation_bases.update(chars)
narrow_emoji.update(chars)
def parse_flag_emoji_sequence(spec: str) -> None:
a, b = list(filter(None, spec.split()))
left, right = int(a, 16), int(b, 16)
chars = {left, right}
all_emoji.update(chars)
wide_emoji.update(chars)
emoji_presentation_bases.update(chars)
flags.setdefault(left, []).append(right)
def parse_emoji_tag_sequence(spec: str) -> None:
a = int(spec.split()[0], 16)
all_emoji.add(a)
wide_emoji.add(a)
emoji_presentation_bases.add(a)
def parse_emoji_modifier_sequence(spec: str) -> None:
a, b = list(filter(None, spec.split()))
char, mod = int(a, 16), int(b, 16)
mod
all_emoji.add(char)
wide_emoji.add(char)
emoji_presentation_bases.add(char)
def parse_emoji() -> None:
for line in get_data('emoji-sequences.txt', 'emoji'):
parts = [x.strip() for x in line.split(';')]
if len(parts) < 2:
continue
base = int(base, 16)
if var.upper() == 'FE0F':
emoji_presentation_bases.add(base)
data, etype = parts[:2]
if etype == 'Basic_Emoji':
parse_basic_emoji(data)
elif etype == 'Emoji_Keycap_Sequence':
parse_keycap_sequence(data)
elif etype == 'RGI_Emoji_Flag_Sequence':
parse_flag_emoji_sequence(data)
elif etype == 'RGI_Emoji_Tag_Sequence':
parse_emoji_tag_sequence(data)
elif etype == 'RGI_Emoji_Modifier_Sequence':
parse_emoji_modifier_sequence(data)
doublewidth, ambiguous = set(), set()
doublewidth: Set[int] = set()
ambiguous: Set[int] = set()
def parse_eaw():
def parse_eaw() -> None:
global doublewidth, ambiguous
seen = set()
seen: Set[int] = set()
for line in get_data('ucd/EastAsianWidth.txt'):
chars, eaw = split_two(line)
if eaw == 'A':
@@ -146,7 +223,7 @@ def parse_eaw():
doublewidth |= set(range(0x30000, 0x3FFFD + 1)) - seen
def get_ranges(items):
def get_ranges(items: List[int]) -> Generator[Union[int, Tuple[int, int]], None, None]:
items.sort()
for k, g in groupby(enumerate(items), lambda m: m[0]-m[1]):
group = tuple(map(itemgetter(1), g))
@@ -157,7 +234,7 @@ def get_ranges(items):
yield a, b
def write_case(spec, p):
def write_case(spec: Union[Tuple, int], p: Callable) -> None:
if isinstance(spec, tuple):
p('\t\tcase 0x{:x} ... 0x{:x}:'.format(*spec))
else:
@@ -165,25 +242,24 @@ 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()
def create_header(path: str, include_data_types: bool = True) -> Generator[Callable, None, None]:
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():
def gen_emoji() -> None:
with create_header('kitty/emoji.h') as p:
p('static inline bool\nis_emoji(char_type code) {')
p('\tswitch(code) {')
@@ -193,9 +269,10 @@ def gen_emoji():
p('\t\tdefault: return false;')
p('\t}')
p('\treturn false;\n}')
p('static inline bool\nis_emoji_modifier(char_type code) {')
p('static inline bool\nis_symbol(char_type code) {')
p('\tswitch(code) {')
for spec in get_ranges(list(emoji_categories['Emoji_Modifier'])):
for spec in get_ranges(list(all_symbols)):
write_case(spec, p)
p('\t\t\treturn true;')
p('\t\tdefault: return false;')
@@ -203,24 +280,39 @@ def gen_emoji():
p('\treturn false;\n}')
def category_test(name, p, classes, comment, static=False, extra_chars=frozenset(), exclude=frozenset()):
static = 'static inline ' if static else ''
chars = set()
def category_test(
name: str,
p: Callable,
classes: Iterable[str],
comment: str,
use_static: bool = False,
extra_chars: Union[FrozenSet[int], Set[int]] = frozenset(),
exclude: Union[Set[int], FrozenSet[int]] = frozenset(),
least_check_return: Optional[str] = None,
ascii_range: Optional[str] = None
) -> None:
static = 'static inline ' if use_static else ''
chars: Set[int] = set()
for c in classes:
chars |= class_maps[c]
chars |= extra_chars
chars -= exclude
p(f'{static}bool\n{name}(char_type code) {{')
p(f'\t// {comment} ({len(chars)} codepoints)' + ' {{' '{')
if least_check_return is not None:
least = min(chars)
p(f'\tif (LIKELY(code < {least})) return {least_check_return};')
if ascii_range is not None:
p(f'\tif (LIKELY(0x20 <= code && code <= 0x7e)) return {ascii_range};')
p('\tswitch(code) {')
for spec in get_ranges(list(chars)):
write_case(spec, p)
p(f'\t\t\treturn true;')
p('\t\t\treturn true;')
p('\t} // }}}\n')
p('\treturn false;\n}\n')
def codepoint_to_mark_map(p, mark_map):
def codepoint_to_mark_map(p: Callable, mark_map: List[int]) -> Dict[int, int]:
p('\tswitch(c) { // {{{')
rmap = {c: m for m, c in enumerate(mark_map)}
for spec in get_ranges(mark_map):
@@ -235,14 +327,14 @@ def codepoint_to_mark_map(p, mark_map):
return rmap
def classes_to_regex(classes, exclude=''):
chars = set()
def classes_to_regex(classes: Iterable[str], exclude: str = '') -> Iterable[str]:
chars: Set[int] = set()
for c in classes:
chars |= class_maps[c]
for c in map(ord, exclude):
chars.discard(c)
for x in map(ord, exclude):
chars.discard(x)
def as_string(codepoint):
def as_string(codepoint: int) -> str:
if codepoint < 256:
return r'\x{:02x}'.format(codepoint)
if codepoint <= 0xffff:
@@ -256,7 +348,7 @@ def classes_to_regex(classes, exclude=''):
yield as_string(spec)
def gen_ucd():
def gen_ucd() -> None:
cz = {c for c in class_maps if c[0] in 'CZ'}
with create_header('kitty/unicode-data.c') as p:
p('#include "unicode-data.h"')
@@ -265,11 +357,15 @@ def gen_ucd():
{c for c in class_maps if c.startswith('M')},
'M category (marks)',
# See https://github.com/harfbuzz/harfbuzz/issues/169
extra_chars=emoji_skin_tone_modifiers | {zwj}
extra_chars=emoji_skin_tone_modifiers | {zwj},
least_check_return='false'
)
category_test(
'is_ignored_char', p, 'Cc Cf Cs'.split(),
'Control characters and non-characters', extra_chars=non_characters, exclude={zwj})
'Control characters and non-characters',
extra_chars=non_characters, exclude={zwj},
ascii_range='false'
)
category_test('is_word_char', p, {c for c in class_maps if c[0] in 'LN'}, 'L and N categories')
category_test('is_CZ_category', p, cz, 'C and Z categories')
category_test('is_P_category', p, {c for c in class_maps if c[0] == 'P'}, 'P category (punctuation)')
@@ -282,7 +378,11 @@ 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()
m = re.search(r'^#define VS15 (\d+)', unicode_data, re.M)
if m is not None:
expected = int(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]
@@ -291,7 +391,7 @@ def gen_ucd():
f.write("url_delimiters = '{}' # noqa".format(''.join(classes_to_regex(cz, exclude='\n'))))
def gen_names():
def gen_names() -> None:
with create_header('kittens/unicode_input/names.h') as p:
mark_to_cp = list(sorted(name_map))
cp_to_mark = {cp: m for m, cp in enumerate(mark_to_cp)}
@@ -345,29 +445,29 @@ def gen_names():
p('}; // }}}\n')
# The trie
p(f'typedef struct {{ uint32_t children_offset; uint32_t match_offset; }} word_trie;\n')
all_trie_nodes = []
p('typedef struct { uint32_t children_offset; uint32_t match_offset; } word_trie;\n')
all_trie_nodes: List['TrieNode'] = [] # noqa
class TrieNode:
def __init__(self):
def __init__(self) -> None:
self.match_offset = 0
self.children_offset = 0
self.children = {}
self.children: Dict[int, int] = {}
def add_letter(self, letter):
def add_letter(self, letter: int) -> int:
if letter not in self.children:
self.children[letter] = len(all_trie_nodes)
all_trie_nodes.append(TrieNode())
return self.children[letter]
def __str__(self):
def __str__(self) -> str:
return f'{{ .children_offset={self.children_offset}, .match_offset={self.match_offset} }}'
root = TrieNode()
all_trie_nodes.append(root)
def add_word(word_idx, word):
def add_word(word_idx: int, word: str) -> None:
parent = root
for letter in map(ord, word):
idx = parent.add_letter(letter)
@@ -392,10 +492,10 @@ def gen_names():
p('}; // }}}\n')
def gen_wcwidth():
seen = set()
def gen_wcwidth() -> None:
seen: Set[int] = set()
def add(p, comment, chars_, ret):
def add(p: Callable, comment: str, chars_: Union[Set[int], FrozenSet[int]], ret: int) -> None:
chars = chars_ - seen
seen.update(chars)
p(f'\t\t// {comment} ({len(chars)} codepoints)' + ' {{' '{')
@@ -405,17 +505,19 @@ def gen_wcwidth():
p('\t\t// }}}\n')
with create_header('kitty/wcwidth-std.h') as p:
p('static int\nwcwidth_std(int32_t code) {')
p('static inline int\nwcwidth_std(int32_t code) {')
p('\tif (LIKELY(0x20 <= code && code <= 0x7e)) return 1;')
p('\tswitch(code) {')
non_printing = class_maps['Cc'] | class_maps['Cf'] | class_maps['Cs']
add(p, 'Flags', flag_codepoints, 2)
add(p, 'Marks', marks | {0}, 0)
add(p, 'Non-printing characters', non_printing, -1)
add(p, 'Private use', class_maps['Co'], -3)
add(p, 'Text Presentation', emoji_categories['Emoji'] - emoji_categories['Emoji_Presentation'], 1)
add(p, 'Text Presentation', narrow_emoji, 1)
add(p, 'East Asian ambiguous width', ambiguous, -2)
add(p, 'East Asian double width', doublewidth, 2)
add(p, 'Emoji Presentation', emoji_categories['Emoji_Presentation'], 2)
add(p, 'Emoji Presentation', wide_emoji, 2)
add(p, 'Not assigned in the unicode character database', not_assigned, -4)
@@ -423,7 +525,7 @@ def gen_wcwidth():
p('\t}')
p('\treturn 1;\n}')
p('static bool\nis_emoji_presentation_base(uint32_t code) {')
p('static inline bool\nis_emoji_presentation_base(uint32_t code) {')
p('\tswitch(code) {')
for spec in get_ranges(list(emoji_presentation_bases)):
write_case(spec, p)

View File

@@ -8,9 +8,11 @@ import shlex
import shutil
import subprocess
cmdline = (
'glad --profile core --out-path {dest} --api gl=3.3 --generator {generator} --spec gl'
' --extensions GL_ARB_texture_storage,GL_ARB_copy_image,GL_ARB_multisample,GL_ARB_robustness,GL_KHR_debug'
'glad --out-path {dest} --api gl:core=3.3 '
' --extensions GL_ARB_texture_storage,GL_ARB_copy_image,GL_ARB_multisample,GL_ARB_robustness,GL_KHR_debug '
'c --header-only --debug'
)
@@ -23,7 +25,7 @@ def regenerate():
clean('out')
subprocess.check_call(
shlex.split(cmdline.format(dest='out', generator='c-debug'))
shlex.split(cmdline.format(dest='out'))
)
@@ -32,33 +34,12 @@ def strip_trailing_whitespace(c):
def export():
c = open('out/src/glad.c', 'rb').read().decode('utf-8')
functions = []
with open('out/include/glad/gl.h', 'r', encoding='utf-8') as source:
data = source.read()
data = strip_trailing_whitespace(data)
def sub(m):
functions.append(m.group(2))
return m.group()
c = re.sub(r'^([A-Z0-9]+) glad_debug_([a-zA-Z0-9]+) = glad_debug_impl_\2;$', sub, c, flags=re.M)
switch = ['glad_debug_{0} = glad_{0}'.format(f) for f in functions]
c = c.replace('<glad/glad.h>', '"gl-wrapper.h"', 1)
c = '#pragma GCC diagnostic ignored "-Wpedantic"\n' + c
c += '''
int
init_glad(GLADloadproc load, int debug) {
int ret = gladLoadGLLoader(load);
if (ret && !debug) {
SUB;
}
return ret;
}'''.replace('SUB', ';\n '.join(switch), 1)
open('../kitty/gl-wrapper.c', 'w').write(strip_trailing_whitespace(c))
raw = open('out/include/glad/glad.h').read()
raw = raw.replace('<KHR/khrplatform.h>', '"khrplatform.h"')
raw += '\nint init_glad(GLADloadproc, int);\n'
open('../kitty/gl-wrapper.h', 'w').write(strip_trailing_whitespace(raw))
raw = open('out/include/KHR/khrplatform.h', 'rb').read().decode('utf-8')
open('../kitty/khrplatform.h', 'w').write(strip_trailing_whitespace(raw))
with open('../kitty/gl-wrapper.h', 'w', encoding='utf-8') as dest:
dest.write(data)
if __name__ == '__main__':

261
glfw/backend_utils.c vendored
View File

@@ -8,9 +8,12 @@
#define _GNU_SOURCE
#include "backend_utils.h"
#include "internal.h"
#include "memfd.h"
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <float.h>
#include <time.h>
@@ -20,19 +23,6 @@
#define ppoll pollts
#endif
static inline double
monotonic(void) {
struct timespec ts = {0};
#ifdef CLOCK_HIGHRES
clock_gettime(CLOCK_HIGHRES, &ts);
#elif CLOCK_MONOTONIC_RAW
clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
#else
clock_gettime(CLOCK_MONOTONIC, &ts);
#endif
return (((double)ts.tv_nsec) / 1e9) + (double)ts.tv_sec;
}
void
update_fds(EventLoopData *eld) {
for (nfds_t i = 0; i < eld->watches_count; i++) {
@@ -107,7 +97,7 @@ update_timers(EventLoopData *eld) {
}
id_type
addTimer(EventLoopData *eld, const char *name, double interval, int enabled, bool repeats, timer_callback_func cb, void *cb_data, GLFWuserdatafreefun free) {
addTimer(EventLoopData *eld, const char *name, monotonic_t interval, int enabled, bool repeats, timer_callback_func cb, void *cb_data, GLFWuserdatafreefun free) {
if (eld->timers_count >= sizeof(eld->timers)/sizeof(eld->timers[0])) {
_glfwInputError(GLFW_PLATFORM_ERROR, "Too many timers added");
return 0;
@@ -115,7 +105,7 @@ addTimer(EventLoopData *eld, const char *name, double interval, int enabled, boo
Timer *t = eld->timers + eld->timers_count++;
t->interval = interval;
t->name = name;
t->trigger_at = enabled ? monotonic() + interval : DBL_MAX;
t->trigger_at = enabled ? monotonic() + interval : MONOTONIC_T_MAX;
t->repeats = repeats;
t->callback = cb;
t->callback_data = cb_data;
@@ -142,7 +132,7 @@ void
toggleTimer(EventLoopData *eld, id_type timer_id, int enabled) {
for (nfds_t i = 0; i < eld->timers_count; i++) {
if (eld->timers[i].id == timer_id) {
double trigger_at = enabled ? (monotonic() + eld->timers[i].interval) : DBL_MAX;
monotonic_t trigger_at = enabled ? (monotonic() + eld->timers[i].interval) : MONOTONIC_T_MAX;
if (trigger_at != eld->timers[i].trigger_at) {
eld->timers[i].trigger_at = trigger_at;
update_timers(eld);
@@ -153,7 +143,7 @@ toggleTimer(EventLoopData *eld, id_type timer_id, int enabled) {
}
void
changeTimerInterval(EventLoopData *eld, id_type timer_id, double interval) {
changeTimerInterval(EventLoopData *eld, id_type timer_id, monotonic_t interval) {
for (nfds_t i = 0; i < eld->timers_count; i++) {
if (eld->timers[i].id == timer_id) {
eld->timers[i].interval = interval;
@@ -163,22 +153,28 @@ changeTimerInterval(EventLoopData *eld, id_type timer_id, double interval) {
}
double
prepareForPoll(EventLoopData *eld, double timeout) {
monotonic_t
prepareForPoll(EventLoopData *eld, monotonic_t timeout) {
for (nfds_t i = 0; i < eld->watches_count; i++) eld->fds[i].revents = 0;
if (!eld->timers_count || eld->timers[0].trigger_at == DBL_MAX) return timeout;
double now = monotonic(), next_repeat_at = eld->timers[0].trigger_at;
if (!eld->timers_count || eld->timers[0].trigger_at == MONOTONIC_T_MAX) return timeout;
monotonic_t now = monotonic(), next_repeat_at = eld->timers[0].trigger_at;
if (timeout < 0 || now + timeout > next_repeat_at) {
timeout = next_repeat_at <= now ? 0 : next_repeat_at - now;
}
return timeout;
}
static inline struct timespec
calc_time(monotonic_t nsec) {
struct timespec result;
result.tv_sec = nsec / (1000LL * 1000LL * 1000LL);
result.tv_nsec = nsec % (1000LL * 1000LL * 1000LL);
return result;
}
int
pollWithTimeout(struct pollfd *fds, nfds_t nfds, double timeout) {
const long seconds = (long) timeout;
const long nanoseconds = (long) ((timeout - seconds) * 1e9);
struct timespec tv = { seconds, nanoseconds };
pollWithTimeout(struct pollfd *fds, nfds_t nfds, monotonic_t timeout) {
struct timespec tv = calc_time(timeout);
return ppoll(fds, nfds, &tv, NULL);
}
@@ -196,10 +192,10 @@ dispatchEvents(EventLoopData *eld) {
unsigned
dispatchTimers(EventLoopData *eld) {
if (!eld->timers_count || eld->timers[0].trigger_at == DBL_MAX) return 0;
if (!eld->timers_count || eld->timers[0].trigger_at == MONOTONIC_T_MAX) return 0;
static struct { timer_callback_func func; id_type id; void* data; bool repeats; } dispatches[sizeof(eld->timers)/sizeof(eld->timers[0])];
unsigned num_dispatches = 0;
double now = monotonic();
monotonic_t now = monotonic();
for (nfds_t i = 0; i < eld->timers_count && eld->timers[i].trigger_at <= now; i++) {
eld->timers[i].trigger_at = now + eld->timers[i].interval;
dispatches[num_dispatches].func = eld->timers[i].callback;
@@ -220,30 +216,97 @@ dispatchTimers(EventLoopData *eld) {
}
static void
drain_wakeup_fd(int fd, int events, void* data) {
drain_wakeup_fd(int fd, EventLoopData* eld) {
static char drain_buf[64];
while(read(fd, drain_buf, sizeof(drain_buf)) < 0 && errno == EINTR);
eld->wakeup_data_read = false;
while(true) {
ssize_t ret = read(fd, drain_buf, sizeof(drain_buf));
if (ret < 0) {
if (errno == EINTR) continue;
break;
}
if (ret > 0) { eld->wakeup_data_read = true; continue; }
break;
}
}
static void
mark_wakep_fd_ready(int fd UNUSED, int events UNUSED, void *data) {
((EventLoopData*)(data))->wakeup_fd_ready = true;
}
bool
initPollData(EventLoopData *eld, int display_fd) {
if (!addWatch(eld, "display", display_fd, POLLIN, 1, NULL, NULL)) return false;
#ifdef HAS_EVENT_FD
eld->wakeupFd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
if (eld->wakeupFd == -1) return false;
const int wakeup_fd = eld->wakeupFd;
#else
if (pipe2(eld->wakeupFds, O_CLOEXEC | O_NONBLOCK) != 0) return false;
const int wakeup_fd = eld->wakeupFds[0];
#endif
if (!addWatch(eld, "wakeup", wakeup_fd, POLLIN, 1, mark_wakep_fd_ready, eld)) return false;
return true;
}
void
initPollData(EventLoopData *eld, int wakeup_fd, int display_fd) {
addWatch(eld, "display", display_fd, POLLIN, 1, NULL, NULL);
addWatch(eld, "wakeup", wakeup_fd, POLLIN, 1, drain_wakeup_fd, NULL);
check_for_wakeup_events(EventLoopData *eld) {
#ifdef HAS_EVENT_FD
int fd = eld->wakeupFd;
#else
int fd = eld->wakeupFds[0];
#endif
drain_wakeup_fd(fd, eld);
}
void
wakeupEventLoop(EventLoopData *eld) {
#ifdef HAS_EVENT_FD
static const uint64_t value = 1;
while (write(eld->wakeupFd, &value, sizeof value) < 0 && (errno == EINTR || errno == EAGAIN));
#else
while (write(eld->wakeupFds[1], "w", 1) < 0 && (errno == EINTR || errno == EAGAIN));
#endif
}
#ifndef HAS_EVENT_FD
static inline void
closeFds(int *fds, size_t count) {
while(count--) {
if (*fds > 0) {
close(*fds);
*fds = -1;
}
fds++;
}
}
#endif
void
finalizePollData(EventLoopData *eld) {
#ifdef HAS_EVENT_FD
close(eld->wakeupFd); eld->wakeupFd = -1;
#else
closeFds(eld->wakeupFds, arraysz(eld->wakeupFds));
#endif
}
int
pollForEvents(EventLoopData *eld, double timeout) {
pollForEvents(EventLoopData *eld, monotonic_t timeout, watch_callback_func display_callback) {
int read_ok = 0;
timeout = prepareForPoll(eld, timeout);
EVDBG("pollForEvents final timeout: %.3f", monotonic_t_to_s_double(timeout));
int result;
double end_time = monotonic() + timeout;
monotonic_t end_time = monotonic() + timeout;
eld->wakeup_fd_ready = false;
while(1) {
if (timeout >= 0) {
errno = 0;
result = pollWithTimeout(eld->fds, eld->watches_count, timeout);
int saved_errno = errno;
if (display_callback) display_callback(result, eld->fds[0].revents && eld->watches[0].events, NULL);
dispatchTimers(eld);
if (result > 0) {
dispatchEvents(eld);
@@ -258,6 +321,7 @@ pollForEvents(EventLoopData *eld, double timeout) {
errno = 0;
result = poll(eld->fds, eld->watches_count, -1);
int saved_errno = errno;
if (display_callback) display_callback(result, eld->fds[0].revents && eld->watches[0].events, NULL);
dispatchTimers(eld);
if (result > 0) {
dispatchEvents(eld);
@@ -270,64 +334,89 @@ pollForEvents(EventLoopData *eld, double timeout) {
return read_ok;
}
void
closeFds(int *fds, size_t count) {
while(count--) {
if (*fds > 0) {
close(*fds);
*fds = -1;
// Duplicate a UTF-8 encoded string
// but cut it so that it has at most max_length bytes plus the null byte.
// This does not take combining characters into account.
GLFWAPI char* utf_8_strndup(const char* source, size_t max_length) {
if (!source) return NULL;
size_t length = strnlen(source, max_length);
if (length >= max_length) {
for (length = max_length; length > 0; length--) {
if ((source[length] & 0xC0) != 0x80) break;
}
fds++;
}
char* result = malloc(length + 1);
memcpy(result, source, length);
result[length] = 0;
return result;
}
// Splits and translates a text/uri-list into separate file paths
// NOTE: This function destroys the provided string
//
char** parseUriList(char* text, int* count)
{
const char* prefix = "file://";
char** paths = NULL;
char* line;
/*
* Create a new, unique, anonymous file of the given size, and
* return the file descriptor for it. The file descriptor is set
* CLOEXEC. The file is immediately suitable for mmap()'ing
* the given size at offset zero.
*
* The file should not have a permanent backing store like a disk,
* but may have if XDG_RUNTIME_DIR is not properly implemented in OS.
*
* The file name is deleted from the file system.
*
* The file is suitable for buffer sharing between processes by
* transmitting the file descriptor over Unix sockets using the
* 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 insufficient, errno
* is set to ENOSPC. If posix_fallocate() is not supported, program may
* receive SIGBUS on accessing mmap()'ed file contents instead.
*/
int createAnonymousFile(off_t size) {
int ret, fd = -1, shm_anon = 0;
#ifdef HAS_MEMFD_CREATE
fd = memfd_create("glfw-shared", MFD_CLOEXEC | MFD_ALLOW_SEALING);
if (fd < 0) return -1;
// We can add this seal before calling posix_fallocate(), as the file
// is currently zero-sized anyway.
//
// There is also no need to check for the return value, we couldnt do
// anything with it anyway.
fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
#elif defined(SHM_ANON)
fd = shm_open(SHM_ANON, O_RDWR | O_CLOEXEC, 0600);
if (fd < 0) return -1;
shm_anon = 1;
#else
static const char template[] = "/glfw-shared-XXXXXX";
const char* path;
char* name;
*count = 0;
while ((line = strtok(text, "\r\n")))
path = getenv("XDG_RUNTIME_DIR");
if (!path)
{
text = NULL;
if (line[0] == '#')
continue;
if (strncmp(line, prefix, strlen(prefix)) == 0)
{
line += strlen(prefix);
// TODO: Validate hostname
while (*line != '/')
line++;
}
(*count)++;
char* path = calloc(strlen(line) + 1, 1);
paths = realloc(paths, *count * sizeof(char*));
paths[*count - 1] = path;
while (*line)
{
if (line[0] == '%' && line[1] && line[2])
{
const char digits[3] = { line[1], line[2], '\0' };
*path = strtol(digits, NULL, 16);
line += 2;
}
else
*path = *line;
path++;
line++;
}
errno = ENOENT;
return -1;
}
return paths;
name = calloc(strlen(path) + sizeof(template), 1);
strcpy(name, path);
strcat(name, template);
fd = createTmpfileCloexec(name);
free(name);
if (fd < 0)
return -1;
#endif
// posix_fallocate does not work on SHM descriptors
ret = shm_anon ? ftruncate(fd, size) : posix_fallocate(fd, 0, size);
if (ret != 0)
{
close(fd);
errno = ret;
return -1;
}
return fd;
}

42
glfw/backend_utils.h vendored
View File

@@ -1,7 +1,7 @@
//========================================================================
// GLFW 3.3 Wayland - www.glfw.org
// GLFW 3.4
//------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
// Copyright (c) 2014 Kovid Goyal
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
@@ -25,9 +25,21 @@
//========================================================================
#pragma once
#include "../kitty/monotonic.h"
#include <poll.h>
#include <unistd.h>
#include <stdbool.h>
#include <sys/types.h>
#ifdef __has_include
#if __has_include(<sys/eventfd.h>)
#define HAS_EVENT_FD
#include <sys/eventfd.h>
#endif
#else
#define HAS_EVENT_FD
#include <sys/eventfd.h>
#endif
typedef unsigned long long id_type;
typedef void(*watch_callback_func)(int, int, void*);
@@ -45,7 +57,7 @@ typedef struct {
typedef struct {
id_type id;
double interval, trigger_at;
monotonic_t interval, trigger_at;
timer_callback_func callback;
void *callback_data;
GLFWuserdatafreefun free;
@@ -56,25 +68,33 @@ typedef struct {
typedef struct {
struct pollfd fds[32];
#ifdef HAS_EVENT_FD
int wakeupFd;
#else
int wakeupFds[2];
#endif
bool wakeup_data_read, wakeup_fd_ready;
nfds_t watches_count, timers_count;
Watch watches[32];
Timer timers[128];
} EventLoopData;
void check_for_wakeup_events(EventLoopData *eld);
id_type addWatch(EventLoopData *eld, const char *name, int fd, int events, int enabled, watch_callback_func cb, void *cb_data);
void removeWatch(EventLoopData *eld, id_type watch_id);
void toggleWatch(EventLoopData *eld, id_type watch_id, int enabled);
id_type addTimer(EventLoopData *eld, const char *name, double interval, int enabled, bool repeats, timer_callback_func cb, void *cb_data, GLFWuserdatafreefun free);
id_type addTimer(EventLoopData *eld, const char *name, monotonic_t interval, int enabled, bool repeats, timer_callback_func cb, void *cb_data, GLFWuserdatafreefun free);
void removeTimer(EventLoopData *eld, id_type timer_id);
void removeAllTimers(EventLoopData *eld);
void toggleTimer(EventLoopData *eld, id_type timer_id, int enabled);
void changeTimerInterval(EventLoopData *eld, id_type timer_id, double interval);
double prepareForPoll(EventLoopData *eld, double timeout);
int pollWithTimeout(struct pollfd *fds, nfds_t nfds, double timeout);
int pollForEvents(EventLoopData *eld, double timeout);
void changeTimerInterval(EventLoopData *eld, id_type timer_id, monotonic_t interval);
monotonic_t prepareForPoll(EventLoopData *eld, monotonic_t timeout);
int pollWithTimeout(struct pollfd *fds, nfds_t nfds, monotonic_t timeout);
int pollForEvents(EventLoopData *eld, monotonic_t timeout, watch_callback_func);
unsigned dispatchTimers(EventLoopData *eld);
void closeFds(int *fds, size_t count);
void initPollData(EventLoopData *eld, int wakeup_fd, int display_fd);
char** parseUriList(char* text, int* count);
void finalizePollData(EventLoopData *eld);
bool initPollData(EventLoopData *eld, int display_fd);
void wakeupEventLoop(EventLoopData *eld);
char* utf_8_strndup(const char* source, size_t max_length);
int createAnonymousFile(off_t size);

View File

@@ -1,7 +1,7 @@
//========================================================================
// GLFW 3.3 macOS - www.glfw.org
// GLFW 3.4 macOS - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
@@ -23,9 +23,16 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
#include "../kitty/monotonic.h"
#include <sys/param.h> // For MAXPATHLEN
#include <pthread.h>
// Needed for _NSGetProgname
#include <crt_externs.h>
// Change to our application bundle's resources directory, if present
//
@@ -63,141 +70,114 @@ static void changeToResourcesDirectory(void)
chdir(resourcesPath);
}
// Create key code translation tables
// Set up the menu bar (manually)
// This is nasty, nasty stuff -- calls to undocumented semi-private APIs that
// could go away at any moment, lots of stuff that really should be
// localize(d|able), etc. Add a nib to save us this horror.
//
static void createKeyTables(void)
static void createMenuBar(void)
{
int scancode;
memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes));
memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes));
_glfw.ns.keycodes[0x1D] = GLFW_KEY_0;
_glfw.ns.keycodes[0x12] = GLFW_KEY_1;
_glfw.ns.keycodes[0x13] = GLFW_KEY_2;
_glfw.ns.keycodes[0x14] = GLFW_KEY_3;
_glfw.ns.keycodes[0x15] = GLFW_KEY_4;
_glfw.ns.keycodes[0x17] = GLFW_KEY_5;
_glfw.ns.keycodes[0x16] = GLFW_KEY_6;
_glfw.ns.keycodes[0x1A] = GLFW_KEY_7;
_glfw.ns.keycodes[0x1C] = GLFW_KEY_8;
_glfw.ns.keycodes[0x19] = GLFW_KEY_9;
_glfw.ns.keycodes[0x00] = GLFW_KEY_A;
_glfw.ns.keycodes[0x0B] = GLFW_KEY_B;
_glfw.ns.keycodes[0x08] = GLFW_KEY_C;
_glfw.ns.keycodes[0x02] = GLFW_KEY_D;
_glfw.ns.keycodes[0x0E] = GLFW_KEY_E;
_glfw.ns.keycodes[0x03] = GLFW_KEY_F;
_glfw.ns.keycodes[0x05] = GLFW_KEY_G;
_glfw.ns.keycodes[0x04] = GLFW_KEY_H;
_glfw.ns.keycodes[0x22] = GLFW_KEY_I;
_glfw.ns.keycodes[0x26] = GLFW_KEY_J;
_glfw.ns.keycodes[0x28] = GLFW_KEY_K;
_glfw.ns.keycodes[0x25] = GLFW_KEY_L;
_glfw.ns.keycodes[0x2E] = GLFW_KEY_M;
_glfw.ns.keycodes[0x2D] = GLFW_KEY_N;
_glfw.ns.keycodes[0x1F] = GLFW_KEY_O;
_glfw.ns.keycodes[0x23] = GLFW_KEY_P;
_glfw.ns.keycodes[0x0C] = GLFW_KEY_Q;
_glfw.ns.keycodes[0x0F] = GLFW_KEY_R;
_glfw.ns.keycodes[0x01] = GLFW_KEY_S;
_glfw.ns.keycodes[0x11] = GLFW_KEY_T;
_glfw.ns.keycodes[0x20] = GLFW_KEY_U;
_glfw.ns.keycodes[0x09] = GLFW_KEY_V;
_glfw.ns.keycodes[0x0D] = GLFW_KEY_W;
_glfw.ns.keycodes[0x07] = GLFW_KEY_X;
_glfw.ns.keycodes[0x10] = GLFW_KEY_Y;
_glfw.ns.keycodes[0x06] = GLFW_KEY_Z;
_glfw.ns.keycodes[0x27] = GLFW_KEY_APOSTROPHE;
_glfw.ns.keycodes[0x2A] = GLFW_KEY_BACKSLASH;
_glfw.ns.keycodes[0x2B] = GLFW_KEY_COMMA;
_glfw.ns.keycodes[0x18] = GLFW_KEY_EQUAL;
_glfw.ns.keycodes[0x32] = GLFW_KEY_GRAVE_ACCENT;
_glfw.ns.keycodes[0x21] = GLFW_KEY_LEFT_BRACKET;
_glfw.ns.keycodes[0x1B] = GLFW_KEY_MINUS;
_glfw.ns.keycodes[0x2F] = GLFW_KEY_PERIOD;
_glfw.ns.keycodes[0x1E] = GLFW_KEY_RIGHT_BRACKET;
_glfw.ns.keycodes[0x29] = GLFW_KEY_SEMICOLON;
_glfw.ns.keycodes[0x2C] = GLFW_KEY_SLASH;
_glfw.ns.keycodes[0x0A] = GLFW_KEY_WORLD_1;
_glfw.ns.keycodes[0x33] = GLFW_KEY_BACKSPACE;
_glfw.ns.keycodes[0x39] = GLFW_KEY_CAPS_LOCK;
_glfw.ns.keycodes[0x75] = GLFW_KEY_DELETE;
_glfw.ns.keycodes[0x7D] = GLFW_KEY_DOWN;
_glfw.ns.keycodes[0x77] = GLFW_KEY_END;
_glfw.ns.keycodes[0x24] = GLFW_KEY_ENTER;
_glfw.ns.keycodes[0x35] = GLFW_KEY_ESCAPE;
_glfw.ns.keycodes[0x7A] = GLFW_KEY_F1;
_glfw.ns.keycodes[0x78] = GLFW_KEY_F2;
_glfw.ns.keycodes[0x63] = GLFW_KEY_F3;
_glfw.ns.keycodes[0x76] = GLFW_KEY_F4;
_glfw.ns.keycodes[0x60] = GLFW_KEY_F5;
_glfw.ns.keycodes[0x61] = GLFW_KEY_F6;
_glfw.ns.keycodes[0x62] = GLFW_KEY_F7;
_glfw.ns.keycodes[0x64] = GLFW_KEY_F8;
_glfw.ns.keycodes[0x65] = GLFW_KEY_F9;
_glfw.ns.keycodes[0x6D] = GLFW_KEY_F10;
_glfw.ns.keycodes[0x67] = GLFW_KEY_F11;
_glfw.ns.keycodes[0x6F] = GLFW_KEY_F12;
_glfw.ns.keycodes[0x69] = GLFW_KEY_F13;
_glfw.ns.keycodes[0x6B] = GLFW_KEY_F14;
_glfw.ns.keycodes[0x71] = GLFW_KEY_F15;
_glfw.ns.keycodes[0x6A] = GLFW_KEY_F16;
_glfw.ns.keycodes[0x40] = GLFW_KEY_F17;
_glfw.ns.keycodes[0x4F] = GLFW_KEY_F18;
_glfw.ns.keycodes[0x50] = GLFW_KEY_F19;
_glfw.ns.keycodes[0x5A] = GLFW_KEY_F20;
_glfw.ns.keycodes[0x73] = GLFW_KEY_HOME;
_glfw.ns.keycodes[0x72] = GLFW_KEY_INSERT;
_glfw.ns.keycodes[0x7B] = GLFW_KEY_LEFT;
_glfw.ns.keycodes[0x3A] = GLFW_KEY_LEFT_ALT;
_glfw.ns.keycodes[0x3B] = GLFW_KEY_LEFT_CONTROL;
_glfw.ns.keycodes[0x38] = GLFW_KEY_LEFT_SHIFT;
_glfw.ns.keycodes[0x37] = GLFW_KEY_LEFT_SUPER;
_glfw.ns.keycodes[0x6E] = GLFW_KEY_MENU;
_glfw.ns.keycodes[0x47] = GLFW_KEY_NUM_LOCK;
_glfw.ns.keycodes[0x79] = GLFW_KEY_PAGE_DOWN;
_glfw.ns.keycodes[0x74] = GLFW_KEY_PAGE_UP;
_glfw.ns.keycodes[0x7C] = GLFW_KEY_RIGHT;
_glfw.ns.keycodes[0x3D] = GLFW_KEY_RIGHT_ALT;
_glfw.ns.keycodes[0x3E] = GLFW_KEY_RIGHT_CONTROL;
_glfw.ns.keycodes[0x3C] = GLFW_KEY_RIGHT_SHIFT;
_glfw.ns.keycodes[0x36] = GLFW_KEY_RIGHT_SUPER;
_glfw.ns.keycodes[0x31] = GLFW_KEY_SPACE;
_glfw.ns.keycodes[0x30] = GLFW_KEY_TAB;
_glfw.ns.keycodes[0x7E] = GLFW_KEY_UP;
_glfw.ns.keycodes[0x52] = GLFW_KEY_KP_0;
_glfw.ns.keycodes[0x53] = GLFW_KEY_KP_1;
_glfw.ns.keycodes[0x54] = GLFW_KEY_KP_2;
_glfw.ns.keycodes[0x55] = GLFW_KEY_KP_3;
_glfw.ns.keycodes[0x56] = GLFW_KEY_KP_4;
_glfw.ns.keycodes[0x57] = GLFW_KEY_KP_5;
_glfw.ns.keycodes[0x58] = GLFW_KEY_KP_6;
_glfw.ns.keycodes[0x59] = GLFW_KEY_KP_7;
_glfw.ns.keycodes[0x5B] = GLFW_KEY_KP_8;
_glfw.ns.keycodes[0x5C] = GLFW_KEY_KP_9;
_glfw.ns.keycodes[0x45] = GLFW_KEY_KP_ADD;
_glfw.ns.keycodes[0x41] = GLFW_KEY_KP_DECIMAL;
_glfw.ns.keycodes[0x4B] = GLFW_KEY_KP_DIVIDE;
_glfw.ns.keycodes[0x4C] = GLFW_KEY_KP_ENTER;
_glfw.ns.keycodes[0x51] = GLFW_KEY_KP_EQUAL;
_glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY;
_glfw.ns.keycodes[0x4E] = GLFW_KEY_KP_SUBTRACT;
for (scancode = 0; scancode < 256; scancode++)
size_t i;
NSString* appName = nil;
NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
NSString* nameKeys[] =
{
// Store the reverse translation for faster key name lookup
if (_glfw.ns.keycodes[scancode] >= 0)
_glfw.ns.scancodes[_glfw.ns.keycodes[scancode]] = scancode;
@"CFBundleDisplayName",
@"CFBundleName",
@"CFBundleExecutable",
};
// Try to figure out what the calling application is called
for (i = 0; i < sizeof(nameKeys) / sizeof(nameKeys[0]); i++)
{
id name = bundleInfo[nameKeys[i]];
if (name &&
[name isKindOfClass:[NSString class]] &&
![name isEqualToString:@""])
{
appName = name;
break;
}
}
if (!appName)
{
char** progname = _NSGetProgname();
if (progname && *progname)
appName = @(*progname);
else
appName = @"GLFW Application";
}
NSMenu* bar = [[NSMenu alloc] init];
[NSApp setMainMenu:bar];
NSMenuItem* appMenuItem =
[bar addItemWithTitle:@"" action:NULL keyEquivalent:@""];
NSMenu* appMenu = [[NSMenu alloc] init];
[appMenuItem setSubmenu:appMenu];
[appMenu addItemWithTitle:[NSString stringWithFormat:@"About %@", appName]
action:@selector(orderFrontStandardAboutPanel:)
keyEquivalent:@""];
[appMenu addItem:[NSMenuItem separatorItem]];
NSMenu* servicesMenu = [[NSMenu alloc] init];
[NSApp setServicesMenu:servicesMenu];
[[appMenu addItemWithTitle:@"Services"
action:NULL
keyEquivalent:@""] setSubmenu:servicesMenu];
[servicesMenu release];
[appMenu addItem:[NSMenuItem separatorItem]];
[appMenu addItemWithTitle:[NSString stringWithFormat:@"Hide %@", appName]
action:@selector(hide:)
keyEquivalent:@"h"];
[[appMenu addItemWithTitle:@"Hide Others"
action:@selector(hideOtherApplications:)
keyEquivalent:@"h"]
setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand];
[appMenu addItemWithTitle:@"Show All"
action:@selector(unhideAllApplications:)
keyEquivalent:@""];
[appMenu addItem:[NSMenuItem separatorItem]];
[appMenu addItemWithTitle:[NSString stringWithFormat:@"Quit %@", appName]
action:@selector(terminate:)
keyEquivalent:@"q"];
NSMenuItem* windowMenuItem =
[bar addItemWithTitle:@"" action:NULL keyEquivalent:@""];
[bar release];
NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
[NSApp setWindowsMenu:windowMenu];
[windowMenuItem setSubmenu:windowMenu];
[windowMenu addItemWithTitle:@"Minimize"
action:@selector(performMiniaturize:)
keyEquivalent:@"m"];
[windowMenu addItemWithTitle:@"Zoom"
action:@selector(performZoom:)
keyEquivalent:@""];
[windowMenu addItem:[NSMenuItem separatorItem]];
[windowMenu addItemWithTitle:@"Bring All to Front"
action:@selector(arrangeInFront:)
keyEquivalent:@""];
// TODO: Make this appear at the bottom of the menu (for consistency)
[windowMenu addItem:[NSMenuItem separatorItem]];
[[windowMenu addItemWithTitle:@"Enter Full Screen"
action:@selector(toggleFullScreen:)
keyEquivalent:@"f"]
setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
// Prior to Snow Leopard, we need to use this oddly-named semi-private API
// to get the application menu working properly.
SEL setAppleMenuSelector = NSSelectorFromString(@"setAppleMenu:");
[NSApp performSelector:setAppleMenuSelector withObject:appMenu];
}
// Retrieve Unicode data for the current keyboard layout
//
static GLFWbool updateUnicodeDataNS(void)
static bool updateUnicodeDataNS(void)
{
if (_glfw.ns.inputSource)
{
@@ -214,7 +194,7 @@ static GLFWbool updateUnicodeDataNS(void)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to retrieve keyboard layout input source");
return GLFW_FALSE;
return false;
}
_glfw.ns.unicodeData =
@@ -224,15 +204,15 @@ static GLFWbool updateUnicodeDataNS(void)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to retrieve keyboard layout Unicode data");
return GLFW_FALSE;
return false;
}
return GLFW_TRUE;
return true;
}
// Load HIToolbox.framework and the TIS symbols we need from it
//
static GLFWbool initializeTIS(void)
static bool initializeTIS(void)
{
// This works only because Cocoa has already loaded it properly
_glfw.ns.tis.bundle =
@@ -241,19 +221,19 @@ static GLFWbool initializeTIS(void)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to load HIToolbox.framework");
return GLFW_FALSE;
return false;
}
CFStringRef* kPropertyUnicodeKeyLayoutData =
CFBundleGetDataPointerForName(_glfw.ns.tis.bundle,
CFSTR("kTISPropertyUnicodeKeyLayoutData"));
_glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource =
*(void **)&_glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource =
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
CFSTR("TISCopyCurrentKeyboardLayoutInputSource"));
_glfw.ns.tis.GetInputSourceProperty =
*(void **)&_glfw.ns.tis.GetInputSourceProperty =
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
CFSTR("TISGetInputSourceProperty"));
_glfw.ns.tis.GetKbdType =
*(void **)&_glfw.ns.tis.GetKbdType =
CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
CFSTR("LMGetKbdType"));
@@ -264,7 +244,7 @@ static GLFWbool initializeTIS(void)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to load TIS API symbols");
return GLFW_FALSE;
return false;
}
_glfw.ns.tis.kPropertyUnicodeKeyLayoutData =
@@ -273,6 +253,17 @@ static GLFWbool initializeTIS(void)
return updateUnicodeDataNS();
}
static void
display_reconfigured(CGDirectDisplayID display UNUSED, CGDisplayChangeSummaryFlags flags, void *userInfo UNUSED)
{
if (flags & kCGDisplayBeginConfigurationFlag) {
return;
}
if (flags & kCGDisplaySetModeFlag) {
// GPU possibly changed
}
}
@interface GLFWHelper : NSObject
@end
@@ -280,14 +271,138 @@ static GLFWbool initializeTIS(void)
- (void)selectedKeyboardInputSourceChanged:(NSObject* )object
{
(void)object;
updateUnicodeDataNS();
}
- (void)doNothing:(id)object
{
(void)object;
}
@end // GLFWHelper
@end // GLFWHelper
// Delegate for application related notifications {{{
@interface GLFWApplicationDelegate : NSObject <NSApplicationDelegate>
@end
@implementation GLFWApplicationDelegate
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
(void)sender;
if (_glfw.callbacks.application_close) _glfw.callbacks.application_close(0);
return NSTerminateCancel;
}
static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL;
- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag
{
(void)sender;
if (!handle_reopen_callback) return YES;
if (handle_reopen_callback(flag)) return YES;
return NO;
}
- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
{
(void)notification;
_GLFWwindow* window;
for (window = _glfw.windowListHead; window; window = window->next)
{
if (window->context.client != GLFW_NO_API)
[window->context.nsgl.object update];
}
_glfwPollMonitorsNS();
}
static GLFWapplicationwillfinishlaunchingfun finish_launching_callback = NULL;
- (void)applicationWillFinishLaunching:(NSNotification *)notification
{
(void)notification;
if (_glfw.hints.init.ns.menubar)
{
// In case we are unbundled, make us a proper UI application
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
// Menu bar setup must go between sharedApplication and finishLaunching
// in order to properly emulate the behavior of NSApplicationMain
if ([[NSBundle mainBundle] pathForResource:@"MainMenu" ofType:@"nib"])
{
[[NSBundle mainBundle] loadNibNamed:@"MainMenu"
owner:NSApp
topLevelObjects:&_glfw.ns.nibObjects];
}
else
createMenuBar();
}
if (finish_launching_callback)
finish_launching_callback();
}
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename {
(void)theApplication;
if (!filename || !_glfw.ns.file_open_callback) return NO;
const char *path = NULL;
@try {
path = [[NSFileManager defaultManager] fileSystemRepresentationWithPath: filename];
} @catch(NSException *exc) {
NSLog(@"Converting openFile filename: %@ failed with error: %@", filename, exc.reason);
return NO;
}
if (!path) return NO;
return _glfw.ns.file_open_callback(path);
}
- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames {
(void)sender;
if (!_glfw.ns.file_open_callback || !filenames) return;
for (id x in filenames) {
NSString *filename = x;
const char *path = NULL;
@try {
path = [[NSFileManager defaultManager] fileSystemRepresentationWithPath: filename];
} @catch(NSException *exc) {
NSLog(@"Converting openFiles filename: %@ failed with error: %@", filename, exc.reason);
}
if (path) _glfw.ns.file_open_callback(path);
}
}
- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
(void)notification;
[NSApp stop:nil];
if (_glfw.ns.file_open_callback) _glfw.ns.file_open_callback(":cocoa::application launched::");
CGDisplayRegisterReconfigurationCallback(display_reconfigured, NULL);
_glfwCocoaPostEmptyEvent();
}
- (void)applicationWillTerminate:(NSNotification *)aNotification
{
(void)aNotification;
CGDisplayRemoveReconfigurationCallback(display_reconfigured, NULL);
}
- (void)applicationDidHide:(NSNotification *)notification
{
(void)notification;
int i;
for (i = 0; i < _glfw.monitorCount; i++)
_glfwRestoreVideoModeNS(_glfw.monitors[i]);
}
@end // GLFWApplicationDelegate
// }}}
@interface GLFWApplication : NSApplication
- (void)tick_callback;
@@ -307,16 +422,45 @@ static GLFWbool initializeTIS(void)
}
@end
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
void* _glfwLoadLocalVulkanLoaderNS(void)
{
CFBundleRef bundle = CFBundleGetMainBundle();
if (!bundle)
return NULL;
CFURLRef url =
CFBundleCopyAuxiliaryExecutableURL(bundle, CFSTR("libvulkan.1.dylib"));
if (!url)
return NULL;
char path[PATH_MAX];
void* handle = NULL;
if (CFURLGetFileSystemRepresentation(url, true, (UInt8*) path, sizeof(path) - 1))
handle = _glfw_dlopen(path);
CFRelease(url);
return handle;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
static inline bool
is_ctrl_tab(NSEvent *event, NSEventModifierFlags modifierFlags) {
if (modifierFlags == NSEventModifierFlagControl || modifierFlags == (
NSEventModifierFlagControl | NSEventModifierFlagShift)) {
if ([event.charactersIgnoringModifiers isEqualToString:@"\t"]) return true;
}
if (
(modifierFlags == NSEventModifierFlagControl &&
[event.charactersIgnoringModifiers isEqualToString:@"\t"]) ||
(modifierFlags == (NSEventModifierFlagControl | NSEventModifierFlagShift) &&
[event.charactersIgnoringModifiers isEqualToString:@"\x19"])
) return true;
return false;
}
@@ -327,17 +471,43 @@ is_cmd_period(NSEvent *event, NSEventModifierFlags modifierFlags) {
return false;
}
GLFWAPI GLFWapplicationshouldhandlereopenfun glfwSetApplicationShouldHandleReopen(GLFWapplicationshouldhandlereopenfun callback) {
GLFWapplicationshouldhandlereopenfun previous = handle_reopen_callback;
handle_reopen_callback = callback;
return previous;
}
GLFWAPI GLFWapplicationwillfinishlaunchingfun glfwSetApplicationWillFinishLaunching(GLFWapplicationwillfinishlaunchingfun callback) {
GLFWapplicationwillfinishlaunchingfun previous = finish_launching_callback;
finish_launching_callback = callback;
return previous;
}
int _glfwPlatformInit(void)
{
@autoreleasepool {
_glfw.ns.helper = [[GLFWHelper alloc] init];
[NSThread detachNewThreadSelector:@selector(doNothing:)
toTarget:_glfw.ns.helper
withObject:nil];
if (NSApp)
_glfw.ns.finishedLaunching = true;
[GLFWApplication sharedApplication];
_glfw.ns.delegate = [[GLFWApplicationDelegate alloc] init];
if (_glfw.ns.delegate == nil)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to create application delegate");
return false;
}
[NSApp setDelegate:_glfw.ns.delegate];
NSEvent* (^keydown_block)(NSEvent*) = ^ NSEvent* (NSEvent* event)
{
NSEventModifierFlags modifierFlags = [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
@@ -372,44 +542,44 @@ int _glfwPlatformInit(void)
_glfw.ns.keyDownMonitor =
[NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyDown
handler:keydown_block];
if (_glfw.hints.init.ns.chdir)
changeToResourcesDirectory();
NSDictionary* defaults = @{
// Press and Hold prevents some keys from emitting repeated characters
@"ApplePressAndHoldEnabled": @NO,
// Dont generate openFile events from command line arguments
@"NSTreatUnknownArgumentsAsOpen": @"NO",
};
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
[[NSNotificationCenter defaultCenter]
addObserver:_glfw.ns.helper
selector:@selector(selectedKeyboardInputSourceChanged:)
name:NSTextInputContextKeyboardSelectionDidChangeNotification
object:nil];
createKeyTables();
_glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
if (!_glfw.ns.eventSource)
return GLFW_FALSE;
return false;
CGEventSourceSetLocalEventsSuppressionInterval(_glfw.ns.eventSource, 0.0);
if (!initializeTIS())
return GLFW_FALSE;
_glfw.ns.displayLinks.lock = [NSLock new];
_glfwInitTimerNS();
_glfwInitJoysticksNS();
return false;
_glfwPollMonitorsNS();
}
return GLFW_TRUE;
return true;
} // autoreleasepool
}
void _glfwPlatformTerminate(void)
{
@autoreleasepool {
if (_glfw.ns.displayLinks.lock) {
_glfwClearDisplayLinks();
[_glfw.ns.displayLinks.lock release];
_glfw.ns.displayLinks.lock = nil;
}
_glfwClearDisplayLinks();
if (_glfw.ns.inputSource)
{
@@ -442,6 +612,7 @@ void _glfwPlatformTerminate(void)
[_glfw.ns.helper release];
_glfw.ns.helper = nil;
}
if (_glfw.ns.keyUpMonitor)
[NSEvent removeMonitor:_glfw.ns.keyUpMonitor];
if (_glfw.ns.keyDownMonitor)
@@ -450,8 +621,8 @@ void _glfwPlatformTerminate(void)
free(_glfw.ns.clipboardString);
_glfwTerminateNSGL();
_glfwTerminateJoysticksNS();
}
} // autoreleasepool
}
const char* _glfwPlatformGetVersionString(void)
@@ -466,32 +637,56 @@ const char* _glfwPlatformGetVersionString(void)
static GLFWtickcallback tick_callback = NULL;
static void* tick_callback_data = NULL;
static bool tick_callback_requested = false;
static pthread_t main_thread;
static NSLock *tick_lock = NULL;
void _glfwDispatchTickCallback() {
if (tick_callback) {
tick_callback_requested = false;
tick_callback(tick_callback_data);
if (tick_lock && tick_callback) {
[tick_lock lock];
while(tick_callback_requested) {
tick_callback_requested = false;
tick_callback(tick_callback_data);
}
[tick_lock unlock];
}
}
void _glfwPlatformRequestTickCallback() {
static void
request_tick_callback() {
if (!tick_callback_requested) {
tick_callback_requested = true;
[NSApp performSelectorOnMainThread:@selector(tick_callback) withObject:nil waitUntilDone:NO];
}
}
void _glfwPlatformPostEmptyEvent(void)
{
if (pthread_equal(pthread_self(), main_thread)) {
request_tick_callback();
} else if (tick_lock) {
[tick_lock lock];
request_tick_callback();
[tick_lock unlock];
}
}
void _glfwPlatformStopMainLoop(void) {
tick_callback = NULL;
[NSApp stop:nil];
_glfwPlatformPostEmptyEvent();
_glfwCocoaPostEmptyEvent();
}
void _glfwPlatformRunMainLoop(GLFWtickcallback callback, void* data) {
main_thread = pthread_self();
tick_callback = callback;
tick_callback_data = data;
tick_lock = [NSLock new];
[NSApp run];
[tick_lock release];
tick_lock = NULL;
tick_callback = NULL;
tick_callback_data = NULL;
}
@@ -499,7 +694,7 @@ typedef struct {
NSTimer *os_timer;
unsigned long long id;
bool repeats;
double interval;
monotonic_t interval;
GLFWuserdatafun callback;
void *callback_data;
GLFWuserdatafun free_callback_data;
@@ -514,15 +709,12 @@ remove_timer_at(size_t idx) {
Timer *t = timers + idx;
if (t->os_timer) { [t->os_timer invalidate]; t->os_timer = NULL; }
if (t->callback_data && t->free_callback_data) { t->free_callback_data(t->id, t->callback_data); t->callback_data = NULL; }
num_timers--;
if (idx < num_timers) {
memmove(timers + idx, timers + idx + 1, sizeof(timers[0]) * (num_timers - idx));
}
remove_i_from_array(timers, idx, num_timers);
}
}
static void schedule_timer(Timer *t) {
t->os_timer = [NSTimer scheduledTimerWithTimeInterval:t->interval repeats:(t->repeats ? YES: NO) block:^(NSTimer *os_timer) {
t->os_timer = [NSTimer scheduledTimerWithTimeInterval:monotonic_t_to_s_double(t->interval) repeats:(t->repeats ? YES: NO) block:^(NSTimer *os_timer) {
for (size_t i = 0; i < num_timers; i++) {
if (timers[i].os_timer == os_timer) {
timers[i].callback(timers[i].id, timers[i].callback_data);
@@ -533,7 +725,7 @@ static void schedule_timer(Timer *t) {
}];
}
unsigned long long _glfwPlatformAddTimer(double interval, bool repeats, GLFWuserdatafun callback, void *callback_data, GLFWuserdatafun free_callback) {
unsigned long long _glfwPlatformAddTimer(monotonic_t interval, bool repeats, GLFWuserdatafun callback, void *callback_data, GLFWuserdatafun free_callback) {
static unsigned long long timer_counter = 0;
if (num_timers >= sizeof(timers)/sizeof(timers[0]) - 1) {
_glfwInputError(GLFW_PLATFORM_ERROR, "Too many timers added");
@@ -559,7 +751,7 @@ void _glfwPlatformRemoveTimer(unsigned long long timer_id) {
}
}
void _glfwPlatformUpdateTimer(unsigned long long timer_id, double interval, GLFWbool enabled) {
void _glfwPlatformUpdateTimer(unsigned long long timer_id, monotonic_t interval, bool enabled) {
for (size_t i = 0; i < num_timers; i++) {
if (timers[i].id == timer_id) {
Timer *t = timers + i;

View File

@@ -1,7 +1,7 @@
//========================================================================
// GLFW 3.3 Cocoa - www.glfw.org
// GLFW 3.4 Cocoa - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
@@ -44,7 +44,3 @@ typedef struct _GLFWjoystickNS
CFMutableArrayRef hats;
} _GLFWjoystickNS;
void _glfwInitJoysticksNS(void);
void _glfwTerminateJoysticksNS(void);

View File

@@ -1,7 +1,7 @@
//========================================================================
// GLFW 3.3 Cocoa - www.glfw.org
// GLFW 3.4 Cocoa - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
//
// This software is provided 'as-is', without any express or implied
@@ -24,6 +24,8 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
@@ -75,7 +77,7 @@ static long getElementValue(_GLFWjoystick* js, _GLFWjoyelementNS* element)
//
static CFComparisonResult compareElements(const void* fp,
const void* sp,
void* user)
void* user UNUSED)
{
const _GLFWjoyelementNS* fe = fp;
const _GLFWjoyelementNS* se = sp;
@@ -117,9 +119,9 @@ static void closeJoystick(_GLFWjoystick* js)
// Callback for user-initiated joystick addition
//
static void matchCallback(void* context,
IOReturn result,
void* sender,
static void matchCallback(void* context UNUSED,
IOReturn result UNUSED,
void* sender UNUSED,
IOHIDDeviceRef device)
{
int jid;
@@ -231,6 +233,19 @@ static void matchCallback(void* context,
break;
}
}
else if (page == kHIDPage_Simulation)
{
switch (usage)
{
case kHIDUsage_Sim_Accelerator:
case kHIDUsage_Sim_Brake:
case kHIDUsage_Sim_Throttle:
case kHIDUsage_Sim_Rudder:
case kHIDUsage_Sim_Steering:
target = axes;
break;
}
}
else if (page == kHIDPage_Button || page == kHIDPage_Consumer)
target = buttons;
@@ -270,9 +285,9 @@ static void matchCallback(void* context,
// Callback for user-initiated joystick removal
//
static void removeCallback(void* context,
IOReturn result,
void* sender,
static void removeCallback(void* context UNUSED,
IOReturn result UNUSED,
void* sender UNUSED,
IOHIDDeviceRef device)
{
int jid;
@@ -289,12 +304,10 @@ static void removeCallback(void* context,
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
// Initialize joystick interface
//
void _glfwInitJoysticksNS(void)
bool _glfwPlatformInitJoysticks(void)
{
CFMutableArrayRef matching;
const long usages[] =
@@ -313,10 +326,10 @@ void _glfwInitJoysticksNS(void)
if (!matching)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to create array");
return;
return false;
}
for (int i = 0; i < sizeof(usages) / sizeof(long); i++)
for (size_t i = 0; i < sizeof(usages) / sizeof(long); i++)
{
const long page = kHIDPage_GenericDesktop;
@@ -368,26 +381,24 @@ void _glfwInitJoysticksNS(void)
// Execute the run loop once in order to register any initially-attached
// joysticks
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);
return true;
}
// Close all opened joystick handles
//
void _glfwTerminateJoysticksNS(void)
void _glfwPlatformTerminateJoysticks(void)
{
int jid;
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
closeJoystick(_glfw.joysticks + jid);
CFRelease(_glfw.ns.hidManager);
_glfw.ns.hidManager = NULL;
if (_glfw.ns.hidManager)
{
CFRelease(_glfw.ns.hidManager);
_glfw.ns.hidManager = NULL;
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
{
if (mode & _GLFW_POLL_AXES)

View File

@@ -1,8 +1,8 @@
//========================================================================
// GLFW 3.3 macOS - www.glfw.org
// GLFW 3.4 macOS - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
@@ -24,6 +24,8 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
@@ -45,7 +47,7 @@ static char* getDisplayName(CGDirectDisplayID displayID)
io_service_t service;
CFDictionaryRef info;
if (IOServiceGetMatchingServices(kIOMasterPortDefault,
if (IOServiceGetMatchingServices(kIOMainPortDefault,
IOServiceMatching("IODisplayConnect"),
&it) != 0)
{
@@ -87,7 +89,7 @@ static char* getDisplayName(CGDirectDisplayID displayID)
if (!service)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to find service port for display");
"Cocoa: Failed to find service port for display, cannot get its name, using Unknown");
return NULL;
}
@@ -116,16 +118,16 @@ static char* getDisplayName(CGDirectDisplayID displayID)
// Check whether the display mode should be included in enumeration
//
static GLFWbool modeIsGood(CGDisplayModeRef mode)
static bool modeIsGood(CGDisplayModeRef mode)
{
uint32_t flags = CGDisplayModeGetIOFlags(mode);
if (!(flags & kDisplayModeValidFlag) || !(flags & kDisplayModeSafeFlag))
return GLFW_FALSE;
return false;
if (flags & kDisplayModeInterlacedFlag)
return GLFW_FALSE;
return false;
if (flags & kDisplayModeStretchedFlag)
return GLFW_FALSE;
return false;
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
@@ -133,18 +135,18 @@ static GLFWbool modeIsGood(CGDisplayModeRef mode)
CFStringCompare(format, CFSTR(IO32BitDirectPixels), 0))
{
CFRelease(format);
return GLFW_FALSE;
return false;
}
CFRelease(format);
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
return GLFW_TRUE;
return true;
}
// Convert Core Graphics display mode to GLFW video mode
//
static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
CVDisplayLinkRef link)
double fallbackRefreshRate)
{
GLFWvidmode result;
result.width = (int) CGDisplayModeGetWidth(mode);
@@ -152,11 +154,7 @@ static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
result.refreshRate = (int) round(CGDisplayModeGetRefreshRate(mode));
if (result.refreshRate == 0)
{
const CVTime time = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link);
if (!(time.flags & kCVTimeIsIndefinite))
result.refreshRate = (int) (time.timeScale / (double) time.timeValue);
}
result.refreshRate = (int) round(fallbackRefreshRate);
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
@@ -215,12 +213,12 @@ static void endFadeReservation(CGDisplayFadeReservationToken token)
// Finds and caches the NSScreen corresponding to the specified monitor
//
GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor)
static bool refreshMonitorScreen(_GLFWmonitor* monitor)
{
if (monitor->ns.screen)
return GLFW_TRUE;
return true;
for (NSScreen* screen in [NSScreen screens])
for (NSScreen* screen in [NSScreen screens])
{
NSNumber* displayID = [screen deviceDescription][@"NSScreenNumber"];
@@ -230,62 +228,120 @@ GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor)
if (monitor->ns.unitNumber == CGDisplayUnitNumber([displayID unsignedIntValue]))
{
monitor->ns.screen = screen;
return GLFW_TRUE;
return true;
}
}
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to find a screen for monitor");
return GLFW_FALSE;
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to find a screen for monitor");
return false;
}
// Returns the display refresh rate queried from the I/O registry
//
static double getFallbackRefreshRate(CGDirectDisplayID displayID)
{
double refreshRate = 60.0;
io_iterator_t it;
io_service_t service;
if (IOServiceGetMatchingServices(kIOMainPortDefault,
IOServiceMatching("IOFramebuffer"),
&it) != 0)
{
return refreshRate;
}
while ((service = IOIteratorNext(it)) != 0)
{
const CFNumberRef indexRef =
IORegistryEntryCreateCFProperty(service,
CFSTR("IOFramebufferOpenGLIndex"),
kCFAllocatorDefault,
kNilOptions);
if (!indexRef)
continue;
uint32_t index = 0;
CFNumberGetValue(indexRef, kCFNumberIntType, &index);
CFRelease(indexRef);
if (CGOpenGLDisplayMaskToDisplayID(1 << index) != displayID)
continue;
const CFNumberRef clockRef =
IORegistryEntryCreateCFProperty(service,
CFSTR("IOFBCurrentPixelClock"),
kCFAllocatorDefault,
kNilOptions);
const CFNumberRef countRef =
IORegistryEntryCreateCFProperty(service,
CFSTR("IOFBCurrentPixelCount"),
kCFAllocatorDefault,
kNilOptions);
uint32_t clock = 0, count = 0;
if (clockRef)
{
CFNumberGetValue(clockRef, kCFNumberIntType, &clock);
CFRelease(clockRef);
}
if (countRef)
{
CFNumberGetValue(countRef, kCFNumberIntType, &count);
CFRelease(countRef);
}
if (clock > 0 && count > 0)
refreshRate = clock / (double) count;
break;
}
IOObjectRelease(it);
return refreshRate;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
void _glfwClearDisplayLinks() {
[_glfw.ns.displayLinks.lock lock];
for (size_t i = 0; i < _glfw.ns.displayLinks.count; i++) {
if (_glfw.ns.displayLinks.entries[i].displayLinkStarted) {
CVDisplayLinkStop(_glfw.ns.displayLinks.entries[i].displayLink);
_glfw.ns.displayLinks.entries[i].displayLinkStarted = GLFW_FALSE;
}
if (_glfw.ns.displayLinks.entries[i].displayLink) {
CVDisplayLinkStop(_glfw.ns.displayLinks.entries[i].displayLink);
CVDisplayLinkRelease(_glfw.ns.displayLinks.entries[i].displayLink);
_glfw.ns.displayLinks.entries[i].displayLink = nil;
_glfw.ns.displayLinks.entries[i].lastRenderFrameRequestedAt = 0;
_glfw.ns.displayLinks.entries[i].first_unserviced_render_frame_request_at = 0;
}
}
_glfw.ns.displayLinks.count = 0;
[_glfw.ns.displayLinks.lock unlock];
}
static CVReturn displayLinkCallback(
CVDisplayLinkRef displayLink,
const CVTimeStamp* now, const CVTimeStamp* outputTime,
CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* userInfo)
CVDisplayLinkRef displayLink UNUSED,
const CVTimeStamp* now UNUSED, const CVTimeStamp* outputTime UNUSED,
CVOptionFlags flagsIn UNUSED, CVOptionFlags* flagsOut UNUSED, void* userInfo)
{
CGDirectDisplayID displayID = (CGDirectDisplayID)userInfo;
[_glfw.ns.displayLinks.lock lock];
GLFWbool notify = GLFW_FALSE;
for (size_t i = 0; i < _glfw.ns.displayLinks.count; i++) {
if (_glfw.ns.displayLinks.entries[i].displayID == displayID) {
if (_glfw.ns.displayLinks.entries[i].renderFrameRequested) {
notify = GLFW_TRUE;
_glfw.ns.displayLinks.entries[i].renderFrameRequested = GLFW_FALSE;
}
break;
}
}
[_glfw.ns.displayLinks.lock unlock];
if (notify) {
NSNumber *arg = [NSNumber numberWithUnsignedInt:displayID];
[NSApp performSelectorOnMainThread:@selector(render_frame_received:) withObject:arg waitUntilDone:NO];
[arg release];
}
CGDirectDisplayID displayID = (uintptr_t)userInfo;
NSNumber *arg = [NSNumber numberWithUnsignedInt:displayID];
[NSApp performSelectorOnMainThread:@selector(render_frame_received:) withObject:arg waitUntilDone:NO];
[arg release];
return kCVReturnSuccess;
}
static inline void createDisplayLink(CGDirectDisplayID displayID) {
[_glfw.ns.displayLinks.lock lock];
void
_glfw_create_cv_display_link(_GLFWDisplayLinkNS *entry) {
CVDisplayLinkCreateWithCGDisplay(entry->displayID, &entry->displayLink);
CVDisplayLinkSetOutputCallback(entry->displayLink, &displayLinkCallback, (void*)(uintptr_t)entry->displayID);
}
static void
createDisplayLink(CGDirectDisplayID displayID) {
if (_glfw.ns.displayLinks.count >= sizeof(_glfw.ns.displayLinks.entries)/sizeof(_glfw.ns.displayLinks.entries[0]) - 1) return;
for (size_t i = 0; i < _glfw.ns.displayLinks.count; i++) {
if (_glfw.ns.displayLinks.entries[i].displayID == displayID) return;
@@ -293,28 +349,25 @@ static inline void createDisplayLink(CGDirectDisplayID displayID) {
_GLFWDisplayLinkNS *entry = &_glfw.ns.displayLinks.entries[_glfw.ns.displayLinks.count++];
memset(entry, 0, sizeof(_GLFWDisplayLinkNS));
entry->displayID = displayID;
CVDisplayLinkCreateWithCGDisplay(displayID, &entry->displayLink);
CVDisplayLinkSetOutputCallback(entry->displayLink, &displayLinkCallback, (void*)(uintptr_t)displayID);
[_glfw.ns.displayLinks.lock unlock];
_glfw_create_cv_display_link(entry);
}
// Poll for changes in the set of connected monitors
//
void _glfwPollMonitorsNS(void)
{
uint32_t i, j, displayCount, disconnectedCount;
CGDirectDisplayID* displays;
_GLFWmonitor** disconnected = NULL;
uint32_t displayCount;
CGGetOnlineDisplayList(0, NULL, &displayCount);
displays = calloc(displayCount, sizeof(CGDirectDisplayID));
CGDirectDisplayID* displays = calloc(displayCount, sizeof(CGDirectDisplayID));
CGGetOnlineDisplayList(displayCount, displays, &displayCount);
_glfwClearDisplayLinks();
for (i = 0; i < _glfw.monitorCount; i++)
for (int i = 0; i < _glfw.monitorCount; i++)
_glfw.monitors[i]->ns.screen = nil;
disconnectedCount = _glfw.monitorCount;
_GLFWmonitor** disconnected = NULL;
uint32_t disconnectedCount = _glfw.monitorCount;
if (disconnectedCount)
{
disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
@@ -323,19 +376,18 @@ void _glfwPollMonitorsNS(void)
_glfw.monitorCount * sizeof(_GLFWmonitor*));
}
for (i = 0; i < displayCount; i++)
for (uint32_t i = 0; i < displayCount; i++)
{
_GLFWmonitor* monitor;
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
if (CGDisplayIsAsleep(displays[i]))
continue;
for (j = 0; j < disconnectedCount; j++)
// HACK: Compare unit numbers instead of display IDs to work around
// display replacement on machines with automatic graphics
// switching
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
for (uint32_t j = 0; j < disconnectedCount; j++)
{
// HACK: Compare unit numbers instead of display IDs to work around
// display replacement on machines with automatic graphics
// switching
if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
{
disconnected[j] = NULL;
@@ -348,17 +400,22 @@ void _glfwPollMonitorsNS(void)
if (!name)
name = _glfw_strdup("Unknown");
monitor = _glfwAllocMonitor(name, size.width, size.height);
_GLFWmonitor* monitor = _glfwAllocMonitor(name, (int)size.width, (int)size.height);
monitor->ns.displayID = displays[i];
monitor->ns.unitNumber = unitNumber;
createDisplayLink(monitor->ns.displayID);
free(name);
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displays[i]);
if (CGDisplayModeGetRefreshRate(mode) == 0.0)
monitor->ns.fallbackRefreshRate = getFallbackRefreshRate(displays[i]);
CGDisplayModeRelease(mode);
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
}
for (i = 0; i < disconnectedCount; i++)
for (uint32_t i = 0; i < disconnectedCount; i++)
{
if (disconnected[i])
_glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
@@ -373,30 +430,25 @@ void _glfwPollMonitorsNS(void)
//
void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
{
CFArrayRef modes;
CFIndex count, i;
CVDisplayLinkRef link;
CGDisplayModeRef native = NULL;
GLFWvidmode current;
const GLFWvidmode* best;
best = _glfwChooseVideoMode(monitor, desired);
_glfwPlatformGetVideoMode(monitor, &current);
const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
if (_glfwCompareVideoModes(&current, best) == 0)
return;
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
const CFIndex count = CFArrayGetCount(modes);
CGDisplayModeRef native = NULL;
modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
count = CFArrayGetCount(modes);
for (i = 0; i < count; i++)
for (CFIndex i = 0; i < count; i++)
{
CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
if (!modeIsGood(dm))
continue;
const GLFWvidmode mode = vidmodeFromCGDisplayMode(dm, link);
const GLFWvidmode mode =
vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate);
if (_glfwCompareVideoModes(best, &mode) == 0)
{
native = dm;
@@ -415,7 +467,6 @@ void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
}
CFRelease(modes);
CVDisplayLinkRelease(link);
}
// Restore the previously saved (original) video mode
@@ -439,7 +490,7 @@ void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor)
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor UNUSED)
{
}
@@ -468,7 +519,9 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
*yscale = (float) (pixels.size.height / points.size.height);
}
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos, int *width, int *height)
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
int* xpos, int* ypos,
int* width, int* height)
{
if (!refreshMonitorScreen(monitor))
return;
@@ -476,40 +529,33 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos
const NSRect frameRect = [monitor->ns.screen visibleFrame];
if (xpos)
*xpos = frameRect.origin.x;
*xpos = (int)frameRect.origin.x;
if (ypos)
*ypos = _glfwTransformYNS(frameRect.origin.y + frameRect.size.height - 1);
*ypos = (int)_glfwTransformYNS(frameRect.origin.y + frameRect.size.height - 1);
if (width)
*width = frameRect.size.width;
*width = (int)frameRect.size.width;
if (height)
*height = frameRect.size.height;
*height = (int)frameRect.size.height;
}
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
{
CFArrayRef modes;
CFIndex found, i, j;
GLFWvidmode* result;
CVDisplayLinkRef link;
*count = 0;
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
const CFIndex found = CFArrayGetCount(modes);
GLFWvidmode* result = calloc(found, sizeof(GLFWvidmode));
modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
found = CFArrayGetCount(modes);
result = calloc(found, sizeof(GLFWvidmode));
for (i = 0; i < found; i++)
for (CFIndex i = 0; i < found; i++)
{
CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
if (!modeIsGood(dm))
continue;
const GLFWvidmode mode = vidmodeFromCGDisplayMode(dm, link);
const GLFWvidmode mode =
vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate);
for (j = 0; j < *count; j++)
for (CFIndex j = 0; j < *count; j++)
{
if (_glfwCompareVideoModes(result + j, &mode) == 0)
break;
@@ -524,27 +570,19 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
}
CFRelease(modes);
CVDisplayLinkRelease(link);
return result;
}
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
{
CGDisplayModeRef displayMode;
CVDisplayLinkRef link;
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
displayMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);
*mode = vidmodeFromCGDisplayMode(displayMode, link);
CGDisplayModeRelease(displayMode);
CVDisplayLinkRelease(link);
CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID);
*mode = vidmodeFromCGDisplayMode(native, monitor->ns.fallbackRefreshRate);
CGDisplayModeRelease(native);
}
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
bool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
{
uint32_t i, size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
uint32_t size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue));
CGGetDisplayTransferByTable(monitor->ns.displayID,
@@ -556,7 +594,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
_glfwAllocGammaArrays(ramp, size);
for (i = 0; i < size; i++)
for (uint32_t i = 0; i < size; i++)
{
ramp->red[i] = (unsigned short) (values[i] * 65535);
ramp->green[i] = (unsigned short) (values[i + size] * 65535);
@@ -564,15 +602,14 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
}
free(values);
return GLFW_TRUE;
return true;
}
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
{
int i;
CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue));
for (i = 0; i < ramp->size; i++)
for (unsigned int i = 0; i < ramp->size; i++)
{
values[i] = ramp->red[i] / 65535.f;
values[i + ramp->size] = ramp->green[i] / 65535.f;

66
glfw/cocoa_platform.h vendored
View File

@@ -1,7 +1,7 @@
//========================================================================
// GLFW 3.3 macOS - www.glfw.org
// GLFW 3.4 macOS - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
@@ -36,6 +36,12 @@ typedef void* id;
typedef void* CVDisplayLinkRef;
#endif
// NOTE: Many Cocoa enum values have been renamed and we need to build across
// SDK versions where one is unavailable or the other deprecated
// We use the newer names in code and these macros to handle compatibility
#if (MAC_OS_X_VERSION_MAX_ALLOWED < 120000) // Before macOS 12 Monterey
#define kIOMainPortDefault kIOMasterPortDefault
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
#define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat
#define NSEventMaskAny NSAnyEventMask
@@ -62,12 +68,16 @@ typedef void* CVDisplayLinkRef;
#endif
typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
typedef int (* GLFWcocoatextinputfilterfun)(int,int,unsigned int, unsigned long);
typedef int (* GLFWapplicationshouldhandlereopenfun)(int);
typedef int (* GLFWcocoatogglefullscreenfun)(GLFWwindow*);
typedef bool (* GLFWapplicationshouldhandlereopenfun)(int);
typedef bool (* GLFWhandlefileopen)(const char*);
typedef void (* GLFWapplicationwillfinishlaunchingfun)(void);
typedef bool (* GLFWcocoatogglefullscreenfun)(GLFWwindow*);
typedef void (* GLFWcocoarenderframefun)(GLFWwindow*);
typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
typedef VkFlags VkMetalSurfaceCreateFlagsEXT;
typedef struct VkMacOSSurfaceCreateInfoMVK
{
VkStructureType sType;
@@ -76,21 +86,25 @@ typedef struct VkMacOSSurfaceCreateInfoMVK
const void* pView;
} VkMacOSSurfaceCreateInfoMVK;
typedef struct VkMetalSurfaceCreateInfoEXT
{
VkStructureType sType;
const void* pNext;
VkMetalSurfaceCreateFlagsEXT flags;
const void* pLayer;
} VkMetalSurfaceCreateInfoEXT;
typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacOSSurfaceCreateInfoMVK*,const VkAllocationCallbacks*,VkSurfaceKHR*);
typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMetalSurfaceCreateInfoEXT*,const VkAllocationCallbacks*,VkSurfaceKHR*);
#include "posix_thread.h"
#include "cocoa_joystick.h"
#include "nsgl_context.h"
#include "egl_context.h"
#include "osmesa_context.h"
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
#define _glfw_dlclose(handle) dlclose(handle)
#define _glfw_dlsym(handle, name) dlsym(handle, name)
#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->ns.view)
#define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns
#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerNS ns
@@ -116,8 +130,11 @@ typedef struct _GLFWwindowNS
id view;
id layer;
GLFWbool maximized;
GLFWbool retina;
bool maximized;
bool retina;
bool in_traditional_fullscreen;
bool titlebar_hidden;
unsigned long pre_full_screen_style_mask;
// Cached window properties to filter out duplicate events
int width, height;
@@ -136,7 +153,7 @@ typedef struct _GLFWwindowNS
// Dead key state
UInt32 deadKeyState;
// Whether a render frame has been requested for this window
GLFWbool renderFrameRequested;
bool renderFrameRequested;
GLFWcocoarenderframefun renderFrameCallback;
} _GLFWwindowNS;
@@ -144,8 +161,7 @@ typedef struct _GLFWDisplayLinkNS
{
CVDisplayLinkRef displayLink;
CGDirectDisplayID displayID;
GLFWbool displayLinkStarted;
GLFWbool renderFrameRequested;
monotonic_t lastRenderFrameRequestedAt, first_unserviced_render_frame_request_at;
} _GLFWDisplayLinkNS;
// Cocoa-specific global data
@@ -154,18 +170,18 @@ typedef struct _GLFWlibraryNS
{
CGEventSourceRef eventSource;
id delegate;
GLFWbool cursorHidden;
bool finishedLaunching;
bool cursorHidden;
TISInputSourceRef inputSource;
IOHIDManagerRef hidManager;
id unicodeData;
id helper;
id keyUpMonitor;
id keyDownMonitor;
id nibObjects;
char keyName[64];
char text[256];
short int keycodes[256];
short int scancodes[GLFW_KEY_LAST + 1];
char* clipboardString;
CGPoint cascadePoint;
// Where to place the cursor when re-enabled
@@ -184,8 +200,9 @@ typedef struct _GLFWlibraryNS
struct {
_GLFWDisplayLinkNS entries[256];
size_t count;
id lock;
} displayLinks;
// the callback to handle file open events
GLFWhandlefileopen file_open_callback;
} _GLFWlibraryNS;
@@ -197,6 +214,7 @@ typedef struct _GLFWmonitorNS
CGDisplayModeRef previousMode;
uint32_t unitNumber;
id screen;
double fallbackRefreshRate;
} _GLFWmonitorNS;
@@ -217,14 +235,18 @@ typedef struct _GLFWtimerNS
} _GLFWtimerNS;
void _glfwInitTimerNS(void);
void _glfwPollMonitorsNS(void);
void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor);
float _glfwTransformYNS(float y);
void* _glfwLoadLocalVulkanLoaderNS(void);
void _glfwClearDisplayLinks(void);
void _glfwRestartDisplayLinks(void);
void _glfwCocoaPostEmptyEvent(short subtype, long data1, bool at_start);
void _glfwDispatchTickCallback(void);
void _glfwDispatchRenderFrame(CGDirectDisplayID);
void _glfwShutdownCVDisplayLink(unsigned long long, void*);
void _glfwCocoaPostEmptyEvent(void);
void _glfw_create_cv_display_link(_GLFWDisplayLinkNS *entry);

60
glfw/cocoa_time.c vendored
View File

@@ -1,60 +0,0 @@
//========================================================================
// GLFW 3.3 macOS - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
#include "internal.h"
#include <mach/mach_time.h>
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
// Initialise timer
//
void _glfwInitTimerNS(void)
{
mach_timebase_info_data_t info;
mach_timebase_info(&info);
_glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
uint64_t _glfwPlatformGetTimerValue(void)
{
return mach_absolute_time();
}
uint64_t _glfwPlatformGetTimerFrequency(void)
{
return _glfw.timer.ns.frequency;
}

File diff suppressed because it is too large Load Diff

238
glfw/context.c vendored
View File

@@ -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>
@@ -24,6 +24,8 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
@@ -44,7 +46,7 @@
// exists and whether all relevant options have supported and non-conflicting
// values
//
GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
bool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
{
if (ctxconfig->share)
{
@@ -52,7 +54,7 @@ GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
ctxconfig->share->context.client == GLFW_NO_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return GLFW_FALSE;
return false;
}
}
@@ -63,7 +65,7 @@ GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid context creation API 0x%08X",
ctxconfig->source);
return GLFW_FALSE;
return false;
}
if (ctxconfig->client != GLFW_NO_API &&
@@ -73,7 +75,7 @@ GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid client API 0x%08X",
ctxconfig->client);
return GLFW_FALSE;
return false;
}
if (ctxconfig->client == GLFW_OPENGL_API)
@@ -92,7 +94,7 @@ GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
_glfwInputError(GLFW_INVALID_VALUE,
"Invalid OpenGL version %i.%i",
ctxconfig->major, ctxconfig->minor);
return GLFW_FALSE;
return false;
}
if (ctxconfig->profile)
@@ -103,7 +105,7 @@ GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid OpenGL profile 0x%08X",
ctxconfig->profile);
return GLFW_FALSE;
return false;
}
if (ctxconfig->major <= 2 ||
@@ -114,7 +116,7 @@ GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
_glfwInputError(GLFW_INVALID_VALUE,
"Context profiles are only defined for OpenGL version 3.2 and above");
return GLFW_FALSE;
return false;
}
}
@@ -123,7 +125,7 @@ GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
// Forward-compatible contexts are only defined for OpenGL version 3.0 and above
_glfwInputError(GLFW_INVALID_VALUE,
"Forward-compatibility is only defined for OpenGL version 3.0 and above");
return GLFW_FALSE;
return false;
}
}
else if (ctxconfig->client == GLFW_OPENGL_ES_API)
@@ -140,7 +142,7 @@ GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
_glfwInputError(GLFW_INVALID_VALUE,
"Invalid OpenGL ES version %i.%i",
ctxconfig->major, ctxconfig->minor);
return GLFW_FALSE;
return false;
}
}
@@ -152,7 +154,7 @@ GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid context robustness mode 0x%08X",
ctxconfig->robustness);
return GLFW_FALSE;
return false;
}
}
@@ -164,184 +166,16 @@ GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid context release behavior 0x%08X",
ctxconfig->release);
return GLFW_FALSE;
return false;
}
}
return GLFW_TRUE;
}
// Chooses the framebuffer config that best matches the desired one
//
const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
const _GLFWfbconfig* alternatives,
unsigned int count)
{
unsigned int i;
unsigned int missing, leastMissing = UINT_MAX;
unsigned int colorDiff, leastColorDiff = UINT_MAX;
unsigned int extraDiff, leastExtraDiff = UINT_MAX;
const _GLFWfbconfig* current;
const _GLFWfbconfig* closest = NULL;
for (i = 0; i < count; i++)
{
current = alternatives + i;
if (desired->stereo > 0 && current->stereo == 0)
{
// Stereo is a hard constraint
continue;
}
if (desired->doublebuffer != current->doublebuffer)
{
// Double buffering is a hard constraint
continue;
}
// Count number of missing buffers
{
missing = 0;
if (desired->alphaBits > 0 && current->alphaBits == 0)
missing++;
if (desired->depthBits > 0 && current->depthBits == 0)
missing++;
if (desired->stencilBits > 0 && current->stencilBits == 0)
missing++;
if (desired->auxBuffers > 0 &&
current->auxBuffers < desired->auxBuffers)
{
missing += desired->auxBuffers - current->auxBuffers;
}
if (desired->samples > 0 && current->samples == 0)
{
// Technically, several multisampling buffers could be
// involved, but that's a lower level implementation detail and
// not important to us here, so we count them as one
missing++;
}
if (desired->transparent != current->transparent)
missing++;
}
// These polynomials make many small channel size differences matter
// less than one large channel size difference
// Calculate color channel size difference value
{
colorDiff = 0;
if (desired->redBits != GLFW_DONT_CARE)
{
colorDiff += (desired->redBits - current->redBits) *
(desired->redBits - current->redBits);
}
if (desired->greenBits != GLFW_DONT_CARE)
{
colorDiff += (desired->greenBits - current->greenBits) *
(desired->greenBits - current->greenBits);
}
if (desired->blueBits != GLFW_DONT_CARE)
{
colorDiff += (desired->blueBits - current->blueBits) *
(desired->blueBits - current->blueBits);
}
}
// Calculate non-color channel size difference value
{
extraDiff = 0;
if (desired->alphaBits != GLFW_DONT_CARE)
{
extraDiff += (desired->alphaBits - current->alphaBits) *
(desired->alphaBits - current->alphaBits);
}
if (desired->depthBits != GLFW_DONT_CARE)
{
extraDiff += (desired->depthBits - current->depthBits) *
(desired->depthBits - current->depthBits);
}
if (desired->stencilBits != GLFW_DONT_CARE)
{
extraDiff += (desired->stencilBits - current->stencilBits) *
(desired->stencilBits - current->stencilBits);
}
if (desired->accumRedBits != GLFW_DONT_CARE)
{
extraDiff += (desired->accumRedBits - current->accumRedBits) *
(desired->accumRedBits - current->accumRedBits);
}
if (desired->accumGreenBits != GLFW_DONT_CARE)
{
extraDiff += (desired->accumGreenBits - current->accumGreenBits) *
(desired->accumGreenBits - current->accumGreenBits);
}
if (desired->accumBlueBits != GLFW_DONT_CARE)
{
extraDiff += (desired->accumBlueBits - current->accumBlueBits) *
(desired->accumBlueBits - current->accumBlueBits);
}
if (desired->accumAlphaBits != GLFW_DONT_CARE)
{
extraDiff += (desired->accumAlphaBits - current->accumAlphaBits) *
(desired->accumAlphaBits - current->accumAlphaBits);
}
if (desired->samples != GLFW_DONT_CARE)
{
extraDiff += (desired->samples - current->samples) *
(desired->samples - current->samples);
}
if (desired->sRGB && !current->sRGB)
extraDiff++;
}
// Figure out if the current one is better than the best one found so far
// Least number of missing buffers is the most important heuristic,
// then color buffer size match and lastly size match for other buffers
if (missing < leastMissing)
closest = current;
else if (missing == leastMissing)
{
if ((colorDiff < leastColorDiff) ||
(colorDiff == leastColorDiff && extraDiff < leastExtraDiff))
{
closest = current;
}
}
if (current == closest)
{
leastMissing = missing;
leastColorDiff = colorDiff;
leastExtraDiff = extraDiff;
}
}
return closest;
return true;
}
// Retrieves the attributes of the current context
//
GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
bool _glfwRefreshContextAttribs(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig)
{
int i;
@@ -369,7 +203,7 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Entry point retrieval is broken");
glfwMakeContextCurrent((GLFWwindow*) previous);
return GLFW_FALSE;
return false;
}
version = (const char*) window->context.GetString(GL_VERSION);
@@ -387,7 +221,7 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
}
glfwMakeContextCurrent((GLFWwindow*) previous);
return GLFW_FALSE;
return false;
}
for (i = 0; prefixes[i]; i++)
@@ -419,7 +253,7 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
}
glfwMakeContextCurrent((GLFWwindow*) previous);
return GLFW_FALSE;
return false;
}
if (window->context.major < ctxconfig->major ||
@@ -449,7 +283,7 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
}
glfwMakeContextCurrent((GLFWwindow*) previous);
return GLFW_FALSE;
return false;
}
if (window->context.major >= 3)
@@ -465,7 +299,7 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
_glfwInputError(GLFW_PLATFORM_ERROR,
"Entry point retrieval is broken");
glfwMakeContextCurrent((GLFWwindow*) previous);
return GLFW_FALSE;
return false;
}
}
@@ -478,21 +312,21 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
window->context.GetIntegerv(GL_CONTEXT_FLAGS, &flags);
if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
window->context.forward = GLFW_TRUE;
window->context.forward = true;
if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
window->context.debug = GLFW_TRUE;
window->context.debug = true;
else if (glfwExtensionSupported("GL_ARB_debug_output") &&
ctxconfig->debug)
{
// HACK: This is a workaround for older drivers (pre KHR_debug)
// not setting the debug bit in the context flags for
// debug contexts
window->context.debug = GLFW_TRUE;
window->context.debug = true;
}
if (flags & GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR)
window->context.noerror = GLFW_TRUE;
window->context.noerror = true;
}
// Read back OpenGL context profile (OpenGL 3.2 and above)
@@ -572,12 +406,12 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
}
glfwMakeContextCurrent((GLFWwindow*) previous);
return GLFW_TRUE;
return true;
}
// Searches an extension string for the specified extension
//
GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions)
bool _glfwStringInExtensionString(const char* string, const char* extensions)
{
const char* start = extensions;
@@ -588,7 +422,7 @@ GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions
where = strstr(start, string);
if (!where)
return GLFW_FALSE;
return false;
terminator = where + strlen(string);
if (where == start || *(where - 1) == ' ')
@@ -600,7 +434,7 @@ GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions
start = terminator;
}
return GLFW_TRUE;
return true;
}
@@ -677,20 +511,20 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
_GLFWwindow* window;
assert(extension != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
_GLFW_REQUIRE_INIT_OR_RETURN(false);
window = _glfwPlatformGetTls(&_glfw.contextSlot);
if (!window)
{
_glfwInputError(GLFW_NO_CURRENT_CONTEXT,
"Cannot query extension without a current OpenGL or OpenGL ES context");
return GLFW_FALSE;
return false;
}
if (*extension == '\0')
{
_glfwInputError(GLFW_INVALID_VALUE, "Extension name cannot be an empty string");
return GLFW_FALSE;
return false;
}
if (window->context.major >= 3)
@@ -710,11 +544,11 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Extension string retrieval is broken");
return GLFW_FALSE;
return false;
}
if (strcmp(en, extension) == 0)
return GLFW_TRUE;
return true;
}
}
else
@@ -727,11 +561,11 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Extension string retrieval is broken");
return GLFW_FALSE;
return false;
}
if (_glfwStringInExtensionString(extension, extensions))
return GLFW_TRUE;
return true;
}
// Check if extension is in the platform-specific string

55
glfw/dbus_glfw.c vendored
View File

@@ -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>
//
@@ -27,6 +27,7 @@
#include "internal.h"
#include "dbus_glfw.h"
#include "../kitty/monotonic.h"
#include <stdlib.h>
#include <string.h>
@@ -45,15 +46,15 @@ report_error(DBusError *err, const char *fmt, ...) {
static _GLFWDBUSData *dbus_data = NULL;
static DBusConnection *session_bus = NULL;
GLFWbool
bool
glfw_dbus_init(_GLFWDBUSData *dbus, EventLoopData *eld) {
dbus->eld = eld;
dbus_data = dbus;
return GLFW_TRUE;
return true;
}
static void
on_dbus_watch_ready(int fd, int events, void *data) {
on_dbus_watch_ready(int fd UNUSED, int events, void *data) {
DBusWatch *watch = (DBusWatch*)data;
unsigned int flags = 0;
if (events & POLLERR) flags |= DBUS_WATCH_ERROR;
@@ -84,19 +85,19 @@ add_dbus_watch(DBusWatch *watch, void *data) {
}
static void
remove_dbus_watch(DBusWatch *watch, void *data) {
remove_dbus_watch(DBusWatch *watch, void *data UNUSED) {
id_type *idp = dbus_watch_get_data(watch);
if (idp) removeWatch(dbus_data->eld, *idp);
}
static void
toggle_dbus_watch(DBusWatch *watch, void *data) {
toggle_dbus_watch(DBusWatch *watch, void *data UNUSED) {
id_type *idp = dbus_watch_get_data(watch);
if (idp) toggleWatch(dbus_data->eld, *idp, dbus_watch_get_enabled(watch));
}
static void
on_dbus_timer_ready(id_type timer_id, void *data) {
on_dbus_timer_ready(id_type timer_id UNUSED, void *data) {
if (data) {
DBusTimeout *t = (DBusTimeout*)data;
dbus_timeout_handle(t);
@@ -107,7 +108,7 @@ on_dbus_timer_ready(id_type timer_id, void *data) {
static dbus_bool_t
add_dbus_timeout(DBusTimeout *timeout, void *data) {
int enabled = dbus_timeout_get_enabled(timeout) ? 1 : 0;
double interval = ((double)dbus_timeout_get_interval(timeout)) / 1000.0;
monotonic_t interval = ms_to_monotonic_t(dbus_timeout_get_interval(timeout));
if (interval < 0) return FALSE;
id_type timer_id = addTimer(dbus_data->eld, data, interval, enabled, true, on_dbus_timer_ready, timeout, NULL);
if (!timer_id) return FALSE;
@@ -123,20 +124,20 @@ add_dbus_timeout(DBusTimeout *timeout, void *data) {
}
static void
remove_dbus_timeout(DBusTimeout *timeout, void *data) {
remove_dbus_timeout(DBusTimeout *timeout, void *data UNUSED) {
id_type *idp = dbus_timeout_get_data(timeout);
if (idp) removeTimer(dbus_data->eld, *idp);
}
static void
toggle_dbus_timeout(DBusTimeout *timeout, void *data) {
toggle_dbus_timeout(DBusTimeout *timeout, void *data UNUSED) {
id_type *idp = dbus_timeout_get_data(timeout);
if (idp) toggleTimer(dbus_data->eld, *idp, dbus_timeout_get_enabled(timeout));
}
DBusConnection*
glfw_dbus_connect_to(const char *path, const char* err_msg, const char *name, GLFWbool register_on_bus) {
glfw_dbus_connect_to(const char *path, const char* err_msg, const char *name, bool register_on_bus) {
DBusError err;
dbus_error_init(&err);
DBusConnection *ans = dbus_connection_open_private(path, &err);
@@ -178,7 +179,7 @@ glfw_dbus_session_bus_dispatch() {
}
void
glfw_dbus_terminate(_GLFWDBUSData *dbus) {
glfw_dbus_terminate(_GLFWDBUSData *dbus UNUSED) {
if (dbus_data) {
dbus_data->eld = NULL;
dbus_data = NULL;
@@ -195,14 +196,14 @@ glfw_dbus_close_connection(DBusConnection *conn) {
dbus_connection_unref(conn);
}
GLFWbool
bool
glfw_dbus_get_args(DBusMessage *msg, const char *failmsg, ...) {
DBusError err;
dbus_error_init(&err);
va_list ap;
va_start(ap, failmsg);
int firstarg = va_arg(ap, int);
GLFWbool ret = dbus_message_get_args_valist(msg, &err, firstarg, ap) ? GLFW_TRUE : GLFW_FALSE;
bool ret = dbus_message_get_args_valist(msg, &err, firstarg, ap) ? true : false;
va_end(ap);
if (!ret) report_error(&err, failmsg);
return ret;
@@ -233,25 +234,25 @@ method_reply_received(DBusPendingCall *pending, void *user_data) {
}
}
GLFWbool
bool
call_method_with_msg(DBusConnection *conn, DBusMessage *msg, int timeout, dbus_pending_callback callback, void *user_data) {
GLFWbool retval = GLFW_FALSE;
bool retval = false;
#define REPORT(errs) _glfwInputError(GLFW_PLATFORM_ERROR, "Failed to call DBUS method: node=%s path=%s interface=%s method=%s, with error: %s", dbus_message_get_destination(msg), dbus_message_get_path(msg), dbus_message_get_interface(msg), dbus_message_get_member(msg), errs)
if (callback) {
DBusPendingCall *pending = NULL;
if (dbus_connection_send_with_reply(conn, msg, &pending, timeout)) {
MethodResponse *res = malloc(sizeof(MethodResponse));
if (!res) return GLFW_FALSE;
if (!res) return false;
res->callback = callback;
res->user_data = user_data;
dbus_pending_call_set_notify(pending, method_reply_received, res, free);
retval = GLFW_TRUE;
retval = true;
} else {
REPORT("out of memory");
}
} else {
if (dbus_connection_send(conn, msg, NULL)) {
retval = GLFW_TRUE;
retval = true;
} else {
REPORT("out of memory");
}
@@ -260,12 +261,12 @@ call_method_with_msg(DBusConnection *conn, DBusMessage *msg, int timeout, dbus_p
#undef REPORT
}
static GLFWbool
static bool
call_method(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, int timeout, dbus_pending_callback callback, void *user_data, va_list ap) {
if (!conn) return GLFW_FALSE;
if (!conn) return false;
DBusMessage *msg = dbus_message_new_method_call(node, path, interface, method);
if (!msg) return GLFW_FALSE;
GLFWbool retval = GLFW_FALSE;
if (!msg) return false;
bool retval = false;
int firstarg = va_arg(ap, int);
if ((firstarg == DBUS_TYPE_INVALID) || dbus_message_append_args_valist(msg, firstarg, ap)) {
@@ -278,9 +279,9 @@ call_method(DBusConnection *conn, const char *node, const char *path, const char
return retval;
}
GLFWbool
bool
glfw_dbus_call_method_with_reply(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, int timeout, dbus_pending_callback callback, void* user_data, ...) {
GLFWbool retval;
bool retval;
va_list ap;
va_start(ap, user_data);
retval = call_method(conn, node, path, interface, method, timeout, callback, user_data, ap);
@@ -288,9 +289,9 @@ glfw_dbus_call_method_with_reply(DBusConnection *conn, const char *node, const c
return retval;
}
GLFWbool
bool
glfw_dbus_call_method_no_reply(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...) {
GLFWbool retval;
bool retval;
va_list ap;
va_start(ap, method);
retval = call_method(conn, node, path, interface, method, DBUS_TIMEOUT_USE_DEFAULT, NULL, NULL, ap);

14
glfw/dbus_glfw.h vendored
View File

@@ -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,18 +37,18 @@ typedef struct {
} _GLFWDBUSData;
GLFWbool glfw_dbus_init(_GLFWDBUSData *dbus, EventLoopData *eld);
bool glfw_dbus_init(_GLFWDBUSData *dbus, EventLoopData *eld);
void glfw_dbus_terminate(_GLFWDBUSData *dbus);
DBusConnection* glfw_dbus_connect_to(const char *path, const char* err_msg, const char* name, GLFWbool register_on_bus);
DBusConnection* glfw_dbus_connect_to(const char *path, const char* err_msg, const char* name, bool register_on_bus);
void glfw_dbus_close_connection(DBusConnection *conn);
GLFWbool
bool
call_method_with_msg(DBusConnection *conn, DBusMessage *msg, int timeout, dbus_pending_callback callback, void *user_data);
GLFWbool
bool
glfw_dbus_call_method_no_reply(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...);
GLFWbool
bool
glfw_dbus_call_method_with_reply(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, int timeout_ms, dbus_pending_callback callback, void *user_data, ...);
void glfw_dbus_dispatch(DBusConnection *);
void glfw_dbus_session_bus_dispatch(void);
GLFWbool glfw_dbus_get_args(DBusMessage *msg, const char *failmsg, ...);
bool glfw_dbus_get_args(DBusMessage *msg, const char *failmsg, ...);
int glfw_dbus_match_signal(DBusMessage *msg, const char *interface, ...);
DBusConnection* glfw_dbus_session_bus(void);

321
glfw/egl_context.c vendored
View File

@@ -1,8 +1,8 @@
//========================================================================
// GLFW 3.3 EGL - www.glfw.org
// GLFW 3.4 EGL - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
@@ -24,6 +24,8 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
@@ -74,6 +76,7 @@ static const char* getEGLErrorString(EGLint error)
}
}
#ifdef _GLFW_X11
// Returns the specified attribute of the specified EGLConfig
//
static int getEGLConfigAttrib(EGLConfig config, int attrib)
@@ -82,108 +85,78 @@ static int getEGLConfigAttrib(EGLConfig config, int attrib)
eglGetConfigAttrib(_glfw.egl.display, config, attrib, &value);
return value;
}
#endif
// Return the EGLConfig most closely matching the specified hints
//
static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
static bool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* desired,
EGLConfig* result)
{
EGLConfig* nativeConfigs;
_GLFWfbconfig* usableConfigs;
const _GLFWfbconfig* closest;
int i, nativeCount, usableCount;
EGLConfig configs[512];
int i = 0, nativeCount = 0, ans_idx = 0;
EGLint attributes[64];
#define ATTR(k, v) { attributes[i++] = k; attributes[i++] = v; }
ATTR(EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER);
ATTR(EGL_SURFACE_TYPE, EGL_WINDOW_BIT);
if (ctxconfig->client == GLFW_OPENGL_ES_API) {
if (ctxconfig->major == 1) ATTR(EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT)
else ATTR(EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT);
}
else if (ctxconfig->client == GLFW_OPENGL_API) ATTR(EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT);
if (desired->samples > 0) ATTR(EGL_SAMPLES, desired->samples);
if (desired->depthBits > 0) ATTR(EGL_DEPTH_SIZE, desired->depthBits);
if (desired->stencilBits > 0) ATTR(EGL_STENCIL_SIZE, desired->stencilBits);
if (desired->redBits > 0) ATTR(EGL_RED_SIZE, desired->redBits);
if (desired->greenBits > 0) ATTR(EGL_GREEN_SIZE, desired->greenBits);
if (desired->blueBits > 0) ATTR(EGL_BLUE_SIZE, desired->blueBits);
if (desired->alphaBits > 0) ATTR(EGL_ALPHA_SIZE, desired->alphaBits);
ATTR(EGL_NONE, EGL_NONE);
#undef ATTR
if (!eglChooseConfig(_glfw.egl.display, attributes, configs, sizeof(configs)/sizeof(configs[0]), &nativeCount)) {
_glfwInputError(GLFW_API_UNAVAILABLE, "EGL: eglChooseConfig failed");
return false;
}
eglGetConfigs(_glfw.egl.display, NULL, 0, &nativeCount);
if (!nativeCount)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "EGL: No EGLConfigs returned");
return GLFW_FALSE;
return false;
}
nativeConfigs = calloc(nativeCount, sizeof(EGLConfig));
eglGetConfigs(_glfw.egl.display, nativeConfigs, nativeCount, &nativeCount);
usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
usableCount = 0;
for (i = 0; i < nativeCount; i++)
{
const EGLConfig n = nativeConfigs[i];
_GLFWfbconfig* u = usableConfigs + usableCount;
// Only consider RGB(A) EGLConfigs
if (getEGLConfigAttrib(n, EGL_COLOR_BUFFER_TYPE) != EGL_RGB_BUFFER)
continue;
// Only consider window EGLConfigs
if (!(getEGLConfigAttrib(n, EGL_SURFACE_TYPE) & EGL_WINDOW_BIT))
continue;
#if defined(_GLFW_X11)
XVisualInfo vi = {0};
// Only consider EGLConfigs with associated Visuals
vi.visualid = getEGLConfigAttrib(n, EGL_NATIVE_VISUAL_ID);
if (!vi.visualid)
continue;
if (desired->transparent)
{
int count;
XVisualInfo* vis = XGetVisualInfo(_glfw.x11.display,
VisualIDMask, &vi,
&count);
if (vis)
const EGLConfig n = configs[i];
XVisualInfo vi = {0};
// Only consider EGLConfigs with associated Visuals
vi.visualid = getEGLConfigAttrib(n, EGL_NATIVE_VISUAL_ID);
if (!vi.visualid)
continue;
if (desired->transparent)
{
u->transparent = _glfwIsVisualTransparentX11(vis[0].visual);
XFree(vis);
int count;
XVisualInfo* vis =
XGetVisualInfo(_glfw.x11.display, VisualIDMask, &vi, &count);
if (vis)
{
bool transparent = _glfwIsVisualTransparentX11(vis[0].visual);
XFree(vis);
if (!transparent) continue;
}
}
}
#endif // _GLFW_X11
if (ctxconfig->client == GLFW_OPENGL_ES_API)
{
if (ctxconfig->major == 1)
{
if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES_BIT))
continue;
}
else
{
if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES2_BIT))
continue;
}
}
else if (ctxconfig->client == GLFW_OPENGL_API)
{
if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_BIT))
continue;
}
u->redBits = getEGLConfigAttrib(n, EGL_RED_SIZE);
u->greenBits = getEGLConfigAttrib(n, EGL_GREEN_SIZE);
u->blueBits = getEGLConfigAttrib(n, EGL_BLUE_SIZE);
u->alphaBits = getEGLConfigAttrib(n, EGL_ALPHA_SIZE);
u->depthBits = getEGLConfigAttrib(n, EGL_DEPTH_SIZE);
u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE);
u->samples = getEGLConfigAttrib(n, EGL_SAMPLES);
u->doublebuffer = GLFW_TRUE;
u->handle = (uintptr_t) n;
usableCount++;
ans_idx = i;
break;
}
closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);
if (closest)
*result = (EGLConfig) closest->handle;
free(nativeConfigs);
free(usableConfigs);
return closest != NULL;
*result = configs[ans_idx];
return true;
}
static void makeContextCurrentEGL(_GLFWwindow* window)
@@ -241,10 +214,10 @@ static int extensionSupportedEGL(const char* extension)
if (extensions)
{
if (_glfwStringInExtensionString(extension, extensions))
return GLFW_TRUE;
return true;
}
return GLFW_FALSE;
return false;
}
static GLFWglproc getProcAddressEGL(const char* procname)
@@ -253,8 +226,8 @@ static GLFWglproc getProcAddressEGL(const char* procname)
if (window->context.egl.client)
{
GLFWglproc proc = (GLFWglproc) _glfw_dlsym(window->context.egl.client,
procname);
GLFWglproc proc = NULL;
glfw_dlsym(proc, window->context.egl.client, procname);
if (proc)
return proc;
}
@@ -297,9 +270,11 @@ static void destroyContextEGL(_GLFWwindow* window)
// Initialize EGL
//
GLFWbool _glfwInitEGL(void)
bool _glfwInitEGL(void)
{
int i;
EGLint* attribs = NULL;
const char* extensions;
const char* sonames[] =
{
#if defined(_GLFW_EGL_LIBRARY)
@@ -318,7 +293,7 @@ GLFWbool _glfwInitEGL(void)
};
if (_glfw.egl.handle)
return GLFW_TRUE;
return true;
for (i = 0; sonames[i]; i++)
{
@@ -330,46 +305,32 @@ GLFWbool _glfwInitEGL(void)
if (!_glfw.egl.handle)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Library not found");
return GLFW_FALSE;
return false;
}
_glfw.egl.prefix = (strncmp(sonames[i], "lib", 3) == 0);
_glfw.egl.GetConfigAttrib = (PFN_eglGetConfigAttrib)
_glfw_dlsym(_glfw.egl.handle, "eglGetConfigAttrib");
_glfw.egl.GetConfigs = (PFN_eglGetConfigs)
_glfw_dlsym(_glfw.egl.handle, "eglGetConfigs");
_glfw.egl.GetDisplay = (PFN_eglGetDisplay)
_glfw_dlsym(_glfw.egl.handle, "eglGetDisplay");
_glfw.egl.GetError = (PFN_eglGetError)
_glfw_dlsym(_glfw.egl.handle, "eglGetError");
_glfw.egl.Initialize = (PFN_eglInitialize)
_glfw_dlsym(_glfw.egl.handle, "eglInitialize");
_glfw.egl.Terminate = (PFN_eglTerminate)
_glfw_dlsym(_glfw.egl.handle, "eglTerminate");
_glfw.egl.BindAPI = (PFN_eglBindAPI)
_glfw_dlsym(_glfw.egl.handle, "eglBindAPI");
_glfw.egl.CreateContext = (PFN_eglCreateContext)
_glfw_dlsym(_glfw.egl.handle, "eglCreateContext");
_glfw.egl.DestroySurface = (PFN_eglDestroySurface)
_glfw_dlsym(_glfw.egl.handle, "eglDestroySurface");
_glfw.egl.DestroyContext = (PFN_eglDestroyContext)
_glfw_dlsym(_glfw.egl.handle, "eglDestroyContext");
_glfw.egl.CreateWindowSurface = (PFN_eglCreateWindowSurface)
_glfw_dlsym(_glfw.egl.handle, "eglCreateWindowSurface");
_glfw.egl.MakeCurrent = (PFN_eglMakeCurrent)
_glfw_dlsym(_glfw.egl.handle, "eglMakeCurrent");
_glfw.egl.SwapBuffers = (PFN_eglSwapBuffers)
_glfw_dlsym(_glfw.egl.handle, "eglSwapBuffers");
_glfw.egl.SwapInterval = (PFN_eglSwapInterval)
_glfw_dlsym(_glfw.egl.handle, "eglSwapInterval");
_glfw.egl.QueryString = (PFN_eglQueryString)
_glfw_dlsym(_glfw.egl.handle, "eglQueryString");
_glfw.egl.GetProcAddress = (PFN_eglGetProcAddress)
_glfw_dlsym(_glfw.egl.handle, "eglGetProcAddress");
glfw_dlsym(_glfw.egl.GetConfigAttrib, _glfw.egl.handle, "eglGetConfigAttrib");
glfw_dlsym(_glfw.egl.GetConfigs, _glfw.egl.handle, "eglGetConfigs");
glfw_dlsym(_glfw.egl.ChooseConfig, _glfw.egl.handle, "eglChooseConfig");
glfw_dlsym(_glfw.egl.GetDisplay, _glfw.egl.handle, "eglGetDisplay");
glfw_dlsym(_glfw.egl.GetError, _glfw.egl.handle, "eglGetError");
glfw_dlsym(_glfw.egl.Initialize, _glfw.egl.handle, "eglInitialize");
glfw_dlsym(_glfw.egl.Terminate, _glfw.egl.handle, "eglTerminate");
glfw_dlsym(_glfw.egl.BindAPI, _glfw.egl.handle, "eglBindAPI");
glfw_dlsym(_glfw.egl.CreateContext, _glfw.egl.handle, "eglCreateContext");
glfw_dlsym(_glfw.egl.DestroySurface, _glfw.egl.handle, "eglDestroySurface");
glfw_dlsym(_glfw.egl.DestroyContext, _glfw.egl.handle, "eglDestroyContext");
glfw_dlsym(_glfw.egl.CreateWindowSurface, _glfw.egl.handle, "eglCreateWindowSurface");
glfw_dlsym(_glfw.egl.MakeCurrent, _glfw.egl.handle, "eglMakeCurrent");
glfw_dlsym(_glfw.egl.SwapBuffers, _glfw.egl.handle, "eglSwapBuffers");
glfw_dlsym(_glfw.egl.SwapInterval, _glfw.egl.handle, "eglSwapInterval");
glfw_dlsym(_glfw.egl.QueryString, _glfw.egl.handle, "eglQueryString");
glfw_dlsym(_glfw.egl.GetProcAddress, _glfw.egl.handle, "eglGetProcAddress");
if (!_glfw.egl.GetConfigAttrib ||
!_glfw.egl.GetConfigs ||
!_glfw.egl.ChooseConfig ||
!_glfw.egl.GetDisplay ||
!_glfw.egl.GetError ||
!_glfw.egl.Initialize ||
@@ -389,10 +350,54 @@ GLFWbool _glfwInitEGL(void)
"EGL: Failed to load required entry points");
_glfwTerminateEGL();
return GLFW_FALSE;
return false;
}
_glfw.egl.display = eglGetDisplay(_GLFW_EGL_NATIVE_DISPLAY);
extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
if (extensions && eglGetError() == EGL_SUCCESS)
_glfw.egl.EXT_client_extensions = true;
if (_glfw.egl.EXT_client_extensions)
{
_glfw.egl.EXT_platform_base =
_glfwStringInExtensionString("EGL_EXT_platform_base", extensions);
_glfw.egl.EXT_platform_x11 =
_glfwStringInExtensionString("EGL_EXT_platform_x11", extensions);
_glfw.egl.EXT_platform_wayland =
_glfwStringInExtensionString("EGL_EXT_platform_wayland", extensions);
_glfw.egl.ANGLE_platform_angle =
_glfwStringInExtensionString("EGL_ANGLE_platform_angle", extensions);
_glfw.egl.ANGLE_platform_angle_opengl =
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_opengl", extensions);
_glfw.egl.ANGLE_platform_angle_d3d =
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_d3d", extensions);
_glfw.egl.ANGLE_platform_angle_vulkan =
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_vulkan", extensions);
_glfw.egl.ANGLE_platform_angle_metal =
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_metal", extensions);
}
if (_glfw.egl.EXT_platform_base)
{
_glfw.egl.GetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)
eglGetProcAddress("eglGetPlatformDisplayEXT");
_glfw.egl.CreatePlatformWindowSurfaceEXT = (PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)
eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
}
_glfw.egl.platform = _glfwPlatformGetEGLPlatform(&attribs);
if (_glfw.egl.platform)
{
_glfw.egl.display =
eglGetPlatformDisplayEXT(_glfw.egl.platform,
_glfwPlatformGetEGLNativeDisplay(),
attribs);
}
else
_glfw.egl.display = eglGetDisplay(_glfwPlatformGetEGLNativeDisplay());
free(attribs);
if (_glfw.egl.display == EGL_NO_DISPLAY)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
@@ -400,7 +405,7 @@ GLFWbool _glfwInitEGL(void)
getEGLErrorString(eglGetError()));
_glfwTerminateEGL();
return GLFW_FALSE;
return false;
}
if (!eglInitialize(_glfw.egl.display, &_glfw.egl.major, &_glfw.egl.minor))
@@ -410,7 +415,7 @@ GLFWbool _glfwInitEGL(void)
getEGLErrorString(eglGetError()));
_glfwTerminateEGL();
return GLFW_FALSE;
return false;
}
_glfw.egl.KHR_create_context =
@@ -424,7 +429,7 @@ GLFWbool _glfwInitEGL(void)
_glfw.egl.KHR_context_flush_control =
extensionSupportedEGL("EGL_KHR_context_flush_control");
return GLFW_TRUE;
return true;
}
// Terminate EGL
@@ -446,26 +451,27 @@ void _glfwTerminateEGL(void)
#define setAttrib(a, v) \
{ \
assert((size_t) (index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
attribs[index++] = a; \
attribs[index++] = v; \
}
// Create the OpenGL or OpenGL ES context
//
GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
bool _glfwCreateContextEGL(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
EGLint attribs[40];
EGLConfig config;
EGLContext share = NULL;
EGLNativeWindowType native;
int index = 0;
if (!_glfw.egl.display)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "EGL: API not available");
return GLFW_FALSE;
return false;
}
if (ctxconfig->share)
@@ -475,7 +481,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"EGL: Failed to find a suitable EGLConfig");
return GLFW_FALSE;
return false;
}
if (ctxconfig->client == GLFW_OPENGL_ES_API)
@@ -485,7 +491,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
_glfwInputError(GLFW_API_UNAVAILABLE,
"EGL: Failed to bind OpenGL ES: %s",
getEGLErrorString(eglGetError()));
return GLFW_FALSE;
return false;
}
}
else
@@ -495,7 +501,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
_glfwInputError(GLFW_API_UNAVAILABLE,
"EGL: Failed to bind OpenGL: %s",
getEGLErrorString(eglGetError()));
return GLFW_FALSE;
return false;
}
}
@@ -536,7 +542,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
if (ctxconfig->noerror)
{
if (_glfw.egl.KHR_create_context_no_error)
setAttrib(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE);
setAttrib(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, true);
}
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
@@ -581,33 +587,40 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"EGL: Failed to create context: %s",
getEGLErrorString(eglGetError()));
return GLFW_FALSE;
return false;
}
// Set up attributes for surface creation
index = 0;
if (fbconfig->sRGB)
{
int index = 0;
if (fbconfig->sRGB)
{
if (_glfw.egl.KHR_gl_colorspace)
setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
}
setAttrib(EGL_NONE, EGL_NONE);
if (_glfw.egl.KHR_gl_colorspace)
setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
}
setAttrib(EGL_NONE, EGL_NONE);
native = _glfwPlatformGetEGLNativeWindow(window);
// HACK: ANGLE does not implement eglCreatePlatformWindowSurfaceEXT
// despite reporting EGL_EXT_platform_base
if (_glfw.egl.platform && _glfw.egl.platform != EGL_PLATFORM_ANGLE_ANGLE)
{
window->context.egl.surface =
eglCreatePlatformWindowSurfaceEXT(_glfw.egl.display, config, native, attribs);
}
else
{
window->context.egl.surface =
eglCreateWindowSurface(_glfw.egl.display, config, native, attribs);
}
window->context.egl.surface =
eglCreateWindowSurface(_glfw.egl.display,
config,
_GLFW_EGL_NATIVE_WINDOW,
attribs);
if (window->context.egl.surface == EGL_NO_SURFACE)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: Failed to create window surface: %s",
getEGLErrorString(eglGetError()));
return GLFW_FALSE;
return false;
}
window->context.egl.config = config;
@@ -695,7 +708,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"EGL: Failed to load client library");
return GLFW_FALSE;
return false;
}
}
@@ -706,7 +719,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
window->context.getProcAddress = getProcAddressEGL;
window->context.destroy = destroyContextEGL;
return GLFW_TRUE;
return true;
}
#undef setAttrib
@@ -714,7 +727,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
// Returns the Visual and depth of the chosen EGLConfig
//
#if defined(_GLFW_X11)
GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
bool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig UNUSED,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig,
Visual** visual, int* depth)
@@ -729,7 +742,7 @@ GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"EGL: Failed to find a suitable EGLConfig");
return GLFW_FALSE;
return false;
}
eglGetConfigAttrib(_glfw.egl.display, native,
@@ -743,14 +756,14 @@ GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: Failed to retrieve Visual for EGLConfig");
return GLFW_FALSE;
return false;
}
*visual = result->visual;
*depth = result->depth;
XFree(result);
return GLFW_TRUE;
return true;
}
#endif // _GLFW_X11

79
glfw/egl_context.h vendored
View File

@@ -1,8 +1,8 @@
//========================================================================
// GLFW 3.3 EGL - www.glfw.org
// GLFW 3.4 EGL - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
@@ -25,26 +25,10 @@
//
//========================================================================
#if defined(_GLFW_USE_EGLPLATFORM_H)
#include <EGL/eglplatform.h>
#elif defined(_GLFW_WIN32)
#if defined(_GLFW_WIN32)
#define EGLAPIENTRY __stdcall
typedef HDC EGLNativeDisplayType;
typedef HWND EGLNativeWindowType;
#elif defined(_GLFW_COCOA)
#define EGLAPIENTRY
typedef void* EGLNativeDisplayType;
typedef id EGLNativeWindowType;
#elif defined(_GLFW_X11)
#define EGLAPIENTRY
typedef Display* EGLNativeDisplayType;
typedef Window EGLNativeWindowType;
#elif defined(_GLFW_WAYLAND)
#define EGLAPIENTRY
typedef struct wl_display* EGLNativeDisplayType;
typedef struct wl_egl_window* EGLNativeWindowType;
#else
#error "No supported EGL platform selected"
#define EGLAPIENTRY
#endif
#define EGL_SUCCESS 0x3000
@@ -108,6 +92,17 @@ typedef struct wl_egl_window* EGLNativeWindowType;
#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097
#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0
#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098
#define EGL_PLATFORM_X11_EXT 0x31d5
#define EGL_PLATFORM_WAYLAND_EXT 0x31d8
#define EGL_PLATFORM_ANGLE_ANGLE 0x3202
#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320d
#define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320e
#define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207
#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208
#define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450
#define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE 0x3489
#define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348f
typedef int EGLint;
typedef unsigned int EGLBoolean;
@@ -117,9 +112,13 @@ typedef void* EGLContext;
typedef void* EGLDisplay;
typedef void* EGLSurface;
typedef void* EGLNativeDisplayType;
typedef void* EGLNativeWindowType;
// EGL function pointer typedefs
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglChooseConfig)(EGLDisplay,EGLint const*,EGLConfig*,EGLint,EGLint*);
typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType);
typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*);
@@ -136,6 +135,7 @@ typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
#define eglGetConfigs _glfw.egl.GetConfigs
#define eglChooseConfig _glfw.egl.ChooseConfig
#define eglGetDisplay _glfw.egl.GetDisplay
#define eglGetError _glfw.egl.GetError
#define eglInitialize _glfw.egl.Initialize
@@ -151,9 +151,10 @@ typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
#define eglQueryString _glfw.egl.QueryString
#define eglGetProcAddress _glfw.egl.GetProcAddress
#define _GLFW_EGL_CONTEXT_STATE _GLFWcontextEGL egl
#define _GLFW_EGL_LIBRARY_CONTEXT_STATE _GLFWlibraryEGL egl
typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*);
typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*);
#define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT
#define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT
// EGL-specific per-context data
//
@@ -171,20 +172,31 @@ typedef struct _GLFWcontextEGL
//
typedef struct _GLFWlibraryEGL
{
EGLenum platform;
EGLDisplay display;
EGLint major, minor;
GLFWbool prefix;
bool prefix;
GLFWbool KHR_create_context;
GLFWbool KHR_create_context_no_error;
GLFWbool KHR_gl_colorspace;
GLFWbool KHR_get_all_proc_addresses;
GLFWbool KHR_context_flush_control;
bool KHR_create_context;
bool KHR_create_context_no_error;
bool KHR_gl_colorspace;
bool KHR_get_all_proc_addresses;
bool KHR_context_flush_control;
bool EXT_client_extensions;
bool EXT_platform_base;
bool EXT_platform_x11;
bool EXT_platform_wayland;
bool ANGLE_platform_angle;
bool ANGLE_platform_angle_opengl;
bool ANGLE_platform_angle_d3d;
bool ANGLE_platform_angle_vulkan;
bool ANGLE_platform_angle_metal;
void* handle;
PFN_eglGetConfigAttrib GetConfigAttrib;
PFN_eglGetConfigs GetConfigs;
PFN_eglChooseConfig ChooseConfig;
PFN_eglGetDisplay GetDisplay;
PFN_eglGetError GetError;
PFN_eglInitialize Initialize;
@@ -200,16 +212,19 @@ typedef struct _GLFWlibraryEGL
PFN_eglQueryString QueryString;
PFN_eglGetProcAddress GetProcAddress;
PFNEGLGETPLATFORMDISPLAYEXTPROC GetPlatformDisplayEXT;
PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC CreatePlatformWindowSurfaceEXT;
} _GLFWlibraryEGL;
GLFWbool _glfwInitEGL(void);
bool _glfwInitEGL(void);
void _glfwTerminateEGL(void);
GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
bool _glfwCreateContextEGL(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig);
#if defined(_GLFW_X11)
GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
bool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig,
Visual** visual, int* depth);

View File

@@ -6,53 +6,81 @@ import json
import os
import re
import sys
from typing import Callable, Dict, List, Optional, Tuple
_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
is_openbsd = 'openbsd' in _plat
base = os.path.dirname(os.path.abspath(__file__))
def wayland_protocol_file_name(base, ext='c'):
class Env:
cc: str = ''
cppflags: List[str] = []
cflags: List[str] = []
ldflags: List[str] = []
library_paths: Dict[str, List[str]] = {}
ldpaths: List[str] = []
ccver: Tuple[int, int]
# glfw stuff
all_headers: List[str] = []
sources: List[str] = []
wayland_packagedir: str = ''
wayland_scanner: str = ''
wayland_scanner_code: str = ''
wayland_protocols: Tuple[str, ...] = ()
def __init__(
self, cc: str = '', cppflags: List[str] = [], cflags: List[str] = [], ldflags: List[str] = [],
library_paths: Dict[str, List[str]] = {}, ldpaths: Optional[List[str]] = None, ccver: Tuple[int, int] = (0, 0)
):
self.cc, self.cppflags, self.cflags, self.ldflags, self.library_paths = cc, cppflags, cflags, ldflags, library_paths
self.ldpaths, self.ccver = [] if ldpaths is None else ldpaths, ccver
def copy(self) -> 'Env':
ans = Env(self.cc, list(self.cppflags), list(self.cflags), list(self.ldflags), dict(self.library_paths), list(self.ldpaths), self.ccver)
ans.all_headers = list(self.all_headers)
ans.sources = list(self.sources)
ans.wayland_packagedir = self.wayland_packagedir
ans.wayland_scanner = self.wayland_scanner
ans.wayland_scanner_code = self.wayland_scanner_code
ans.wayland_protocols = self.wayland_protocols
return ans
def wayland_protocol_file_name(base: str, ext: str = 'c') -> str:
base = os.path.basename(base).rpartition('.')[0]
return 'wayland-{}-client-protocol.{}'.format(base, ext)
def init_env(env, pkg_config, at_least_version, test_compile, module='x11'):
def init_env(env: Env, pkg_config: Callable, pkg_version: Callable, at_least_version: Callable, test_compile: Callable, module: str = 'x11') -> Env:
ans = env.copy()
ans.cflags = [
x for x in ans.cflags
if x not in '-Wpedantic -Wextra -pedantic-errors'.split()
]
if not is_macos:
ans.cflags.append('-pthread')
ans.ldpaths.append('-pthread')
ans.cflags.append('-fpic')
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'):
at_least_version('xkbcommon', 0, 5)
ans.cflags.append('-pthread')
ans.ldpaths.extend('-pthread -lm'.split())
if not is_openbsd:
ans.ldpaths.extend('-lrt -ldl'.split())
major, minor = pkg_version('xkbcommon')
if (major, minor) < (0, 5):
raise SystemExit('libxkbcommon >= 0.5 required')
if major < 1:
ans.cflags.append('-DXKB_HAS_NO_UTF32')
if module == 'x11':
for dep in 'x11 xrandr xinerama xcursor xkbcommon xkbcommon-x11 x11-xcb dbus-1'.split():
@@ -60,8 +88,9 @@ def init_env(env, pkg_config, at_least_version, test_compile, module='x11'):
ans.ldpaths.extend(pkg_config(dep, '--libs'))
elif module == 'cocoa':
for f in 'Cocoa IOKit CoreFoundation CoreVideo'.split():
ans.ldpaths.extend(('-framework', f))
ans.cppflags.append('-DGL_SILENCE_DEPRECATION')
for f_ in 'Cocoa Carbon IOKit CoreFoundation CoreVideo'.split():
ans.ldpaths.extend(('-framework', f_))
elif module == 'wayland':
at_least_version('wayland-protocols', *sinfo['wayland_protocols'])
@@ -73,7 +102,7 @@ def init_env(env, pkg_config, at_least_version, test_compile, module='x11'):
for p in ans.wayland_protocols:
ans.sources.append(wayland_protocol_file_name(p))
ans.all_headers.append(wayland_protocol_file_name(p, 'h'))
for dep in 'wayland-egl wayland-client wayland-cursor xkbcommon dbus-1'.split():
for dep in 'wayland-client wayland-cursor xkbcommon dbus-1'.split():
ans.cflags.extend(pkg_config(dep, '--cflags-only-I'))
ans.ldpaths.extend(pkg_config(dep, '--libs'))
has_memfd_create = test_compile(env.cc, '-Werror', src='''#define _GNU_SOURCE
@@ -88,7 +117,8 @@ def init_env(env, pkg_config, at_least_version, test_compile, module='x11'):
return ans
def build_wayland_protocols(env, run_tool, emphasis, newer, dest_dir):
def build_wayland_protocols(env: Env, Command: Callable, parallel_run: Callable, emphasis: Callable, newer: Callable, dest_dir: str) -> None:
items = []
for protocol in env.wayland_protocols:
src = os.path.join(env.wayland_packagedir, protocol)
if not os.path.exists(src):
@@ -98,13 +128,17 @@ def build_wayland_protocols(env, run_tool, emphasis, newer, dest_dir):
dest = os.path.join(dest_dir, dest)
if newer(dest, src):
q = 'client-header' if ext == 'h' else env.wayland_scanner_code
run_tool([env.wayland_scanner, q, src, dest],
desc='Generating {} ...'.format(emphasis(os.path.basename(dest))))
items.append(Command(
'Generating {} ...'.format(emphasis(os.path.basename(dest))),
[env.wayland_scanner, q, src, dest],
lambda: True, None, None, None))
if items:
parallel_run(items)
class Arg:
def __init__(self, decl):
def __init__(self, decl: str):
self.type, self.name = decl.rsplit(' ', 1)
self.type = self.type.strip()
self.name = self.name.strip()
@@ -112,13 +146,13 @@ class Arg:
self.name = self.name[1:]
self.type = self.type + '*'
def __repr__(self):
def __repr__(self) -> str:
return 'Arg({}, {})'.format(self.type, self.name)
class Function:
def __init__(self, declaration, check_fail=True):
def __init__(self, declaration: str, check_fail: bool = True):
self.check_fail = check_fail
m = re.match(
r'(.+?)\s+(glfw[A-Z][a-zA-Z0-9]+)[(](.+)[)]$', declaration
@@ -137,26 +171,26 @@ class Function:
if not self.args:
self.args = [Arg('void v')]
def declaration(self):
return 'typedef {restype} (*{name}_func)({args});\n{name}_func {name}_impl;\n#define {name} {name}_impl'.format(
def declaration(self) -> str:
return 'typedef {restype} (*{name}_func)({args});\nGFW_EXTERN {name}_func {name}_impl;\n#define {name} {name}_impl'.format(
restype=self.restype,
name=self.name,
args=', '.join(a.type for a in self.args)
)
def load(self):
ans = '*(void **) (&{name}_impl) = dlsym(handle, "{name}");'.format(
name=self.name
)
def load(self) -> str:
ans = f'*(void **) (&{self.name}_impl) = dlsym(handle, "{self.name}");'
ans += f'\n if ({self.name}_impl == NULL) '
if self.check_fail:
ans += '\n if ({name}_impl == NULL) fail("Failed to load glfw function {name} with error: %s", dlerror());'.format(
name=self.name
)
ans += f'fail("Failed to load glfw function {self.name} with error: %s", dlerror());'
else:
ans += 'dlerror(); // clear error indicator'
return ans
def generate_wrappers(glfw_header):
src = open(glfw_header).read()
def generate_wrappers(glfw_header: str) -> None:
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):
@@ -168,19 +202,23 @@ def generate_wrappers(glfw_header):
functions.append(Function(decl))
for line in '''\
void* glfwGetCocoaWindow(GLFWwindow* window)
void glfwHideCocoaTitlebar(GLFWwindow* window, bool yes)
void* glfwGetNSGLContext(GLFWwindow *window)
uint32_t glfwGetCocoaMonitor(GLFWmonitor* monitor)
GLFWcocoatextinputfilterfun glfwSetCocoaTextInputFilter(GLFWwindow* window, GLFWcocoatextinputfilterfun callback)
GLFWhandlefileopen glfwSetCocoaFileOpenCallback(GLFWhandlefileopen callback)
GLFWcocoatogglefullscreenfun glfwSetCocoaToggleFullscreenIntercept(GLFWwindow *window, GLFWcocoatogglefullscreenfun callback)
GLFWapplicationshouldhandlereopenfun glfwSetApplicationShouldHandleReopen(GLFWapplicationshouldhandlereopenfun callback)
void glfwGetCocoaKeyEquivalent(int glfw_key, int glfw_mods, void* cocoa_key, void* cocoa_mods)
GLFWapplicationwillfinishlaunchingfun glfwSetApplicationWillFinishLaunching(GLFWapplicationwillfinishlaunchingfun callback)
uint32_t glfwGetCocoaKeyEquivalent(uint32_t glfw_key, int glfw_mods, int* cocoa_mods)
void glfwCocoaRequestRenderFrame(GLFWwindow *w, GLFWcocoarenderframefun callback)
void* glfwGetX11Display(void)
int32_t glfwGetX11Window(GLFWwindow* window)
void glfwSetPrimarySelectionString(GLFWwindow* window, const char* string)
const char* glfwGetPrimarySelectionString(GLFWwindow* window, void)
int glfwGetXKBScancode(const char* key_name, int case_sensitive)
int glfwGetNativeKeyForName(const char* key_name, int case_sensitive)
void glfwRequestWaylandFrameEvent(GLFWwindow *handle, unsigned long long id, GLFWwaylandframecallbackfunc callback)
bool glfwWaylandSetTitlebarColor(GLFWwindow *handle, uint32_t color, bool use_system_color)
unsigned long long glfwDBusUserNotify(const char *app_name, const char* icon, const char *summary, const char *body, \
const char *action_text, int32_t timeout, GLFWDBusnotificationcreatedfun callback, void *data)
void glfwDBusSetUserNotificationHandler(GLFWDBusnotificationactivatedfun handler)
@@ -193,15 +231,27 @@ const char *action_text, int32_t timeout, GLFWDBusnotificationcreatedfun callbac
p = src.find('*/', p)
preamble = src[p + 2:first]
header = '''\
//
// THIS FILE IS GENERATED BY glfw.py
//
// SAVE YOURSELF SOME TIME, DO NOT MANUALLY EDIT
//
#pragma once
#include <stddef.h>
#include <stdint.h>
#include "monotonic.h"
#ifndef GFW_EXTERN
#define GFW_EXTERN extern
#endif
{}
typedef int (* GLFWcocoatextinputfilterfun)(int,int,unsigned int,unsigned long);
typedef int (* GLFWapplicationshouldhandlereopenfun)(int);
typedef int (* GLFWcocoatogglefullscreenfun)(GLFWwindow*);
typedef bool (* GLFWapplicationshouldhandlereopenfun)(int);
typedef bool (* GLFWhandlefileopen)(const char*);
typedef void (* GLFWapplicationwillfinishlaunchingfun)(void);
typedef bool (* GLFWcocoatogglefullscreenfun)(GLFWwindow*);
typedef void (* GLFWcocoarenderframefun)(GLFWwindow*);
typedef void (*GLFWwaylandframecallbackfunc)(unsigned long long id);
typedef void (*GLFWDBusnotificationcreatedfun)(unsigned long long, uint32_t, void*);
@@ -214,6 +264,7 @@ const char* load_glfw(const char* path);
f.write(header)
code = '''
#define GFW_EXTERN
#include "data-types.h"
#include "glfw-wrapper.h"
#include <dlfcn.h>
@@ -243,7 +294,7 @@ unload_glfw(void) {
f.write(code)
def main():
def main() -> None:
os.chdir(os.path.dirname(os.path.abspath(__file__)))
generate_wrappers('glfw3.h')

1496
glfw/glfw3.h vendored

File diff suppressed because it is too large Load Diff

255
glfw/glx_context.c vendored
View File

@@ -1,8 +1,8 @@
//========================================================================
// GLFW 3.3 GLX - www.glfw.org
// GLFW 3.4 GLX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
@@ -24,6 +24,8 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
@@ -45,104 +47,92 @@ static int getGLXFBConfigAttrib(GLXFBConfig fbconfig, int attrib)
return value;
}
static GLXFBConfig*
choose_fb_config(const _GLFWfbconfig* desired, bool trust_window_bit, int *nelements) {
int attrib_list[64];
int pos = 0;
#define ATTR(x, y) { attrib_list[pos++] = x; attrib_list[pos++] = y; }
ATTR(GLX_DOUBLEBUFFER, desired->doublebuffer ? True : False);
if (desired->stereo > 0) ATTR(GLX_STEREO, desired->stereo ? True : False);
if (desired->auxBuffers > 0) ATTR(GLX_AUX_BUFFERS, desired->auxBuffers);
if (_glfw.glx.ARB_multisample && desired->samples > 0) ATTR(GLX_SAMPLES, desired->samples);
if (desired->depthBits != GLFW_DONT_CARE) ATTR(GLX_DEPTH_SIZE, desired->depthBits);
if (desired->stencilBits != GLFW_DONT_CARE) ATTR(GLX_STENCIL_SIZE, desired->stencilBits);
if (desired->redBits != GLFW_DONT_CARE) ATTR(GLX_RED_SIZE, desired->redBits);
if (desired->greenBits != GLFW_DONT_CARE) ATTR(GLX_GREEN_SIZE, desired->greenBits);
if (desired->blueBits != GLFW_DONT_CARE) ATTR(GLX_BLUE_SIZE, desired->blueBits);
if (desired->alphaBits != GLFW_DONT_CARE) ATTR(GLX_ALPHA_SIZE, desired->alphaBits);
if (desired->accumRedBits != GLFW_DONT_CARE) ATTR(GLX_ACCUM_RED_SIZE, desired->accumRedBits);
if (desired->accumGreenBits != GLFW_DONT_CARE) ATTR(GLX_ACCUM_GREEN_SIZE, desired->accumGreenBits);
if (desired->accumBlueBits != GLFW_DONT_CARE) ATTR(GLX_ACCUM_BLUE_SIZE, desired->accumBlueBits);
if (desired->accumAlphaBits != GLFW_DONT_CARE) ATTR(GLX_ACCUM_ALPHA_SIZE, desired->accumAlphaBits);
if (!trust_window_bit) ATTR(GLX_DRAWABLE_TYPE, 0);
ATTR(None, None);
return glXChooseFBConfig(_glfw.x11.display, _glfw.x11.screen, attrib_list, nelements);
#undef ATTR
}
// Return the GLXFBConfig most closely matching the specified hints
//
static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
static bool chooseGLXFBConfig(const _GLFWfbconfig* desired,
GLXFBConfig* result)
{
GLXFBConfig* nativeConfigs;
_GLFWfbconfig* usableConfigs;
const _GLFWfbconfig* closest;
int i, nativeCount, usableCount;
int i, nativeCount, ans_idx = 0;
const char* vendor;
GLFWbool trustWindowBit = GLFW_TRUE;
bool trustWindowBit = true;
static _GLFWfbconfig prev_desired = {0};
static GLXFBConfig prev_result = 0;
if (prev_result != 0 && memcmp(&prev_desired, desired, sizeof(_GLFWfbconfig)) == 0) {
*result = prev_result;
return true;
}
prev_desired = *desired;
// HACK: This is a (hopefully temporary) workaround for Chromium
// (VirtualBox GL) not setting the window bit on any GLXFBConfigs
vendor = glXGetClientString(_glfw.x11.display, GLX_VENDOR);
if (vendor && strcmp(vendor, "Chromium") == 0)
trustWindowBit = GLFW_FALSE;
nativeConfigs =
glXGetFBConfigs(_glfw.x11.display, _glfw.x11.screen, &nativeCount);
trustWindowBit = false;
nativeConfigs = choose_fb_config(desired, trustWindowBit, &nativeCount);
if (!nativeConfigs || !nativeCount)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: No GLXFBConfigs returned");
return GLFW_FALSE;
return false;
}
usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
usableCount = 0;
for (i = 0; i < nativeCount; i++)
{
const GLXFBConfig n = nativeConfigs[i];
_GLFWfbconfig* u = usableConfigs + usableCount;
// Only consider RGBA GLXFBConfigs
if (!(getGLXFBConfigAttrib(n, GLX_RENDER_TYPE) & GLX_RGBA_BIT))
continue;
// Only consider window GLXFBConfigs
if (!(getGLXFBConfigAttrib(n, GLX_DRAWABLE_TYPE) & GLX_WINDOW_BIT))
{
if (trustWindowBit)
continue;
}
if (desired->transparent)
{
bool transparency_matches = true, srgb_matches = true;
if (desired->transparent) {
transparency_matches = false;
XVisualInfo* vi = glXGetVisualFromFBConfig(_glfw.x11.display, n);
if (vi)
{
u->transparent = _glfwIsVisualTransparentX11(vi->visual);
XFree(vi);
}
if (vi && _glfwIsVisualTransparentX11(vi->visual)) transparency_matches = true;
}
u->redBits = getGLXFBConfigAttrib(n, GLX_RED_SIZE);
u->greenBits = getGLXFBConfigAttrib(n, GLX_GREEN_SIZE);
u->blueBits = getGLXFBConfigAttrib(n, GLX_BLUE_SIZE);
if (desired->sRGB && (_glfw.glx.ARB_framebuffer_sRGB || _glfw.glx.EXT_framebuffer_sRGB)) {
srgb_matches = getGLXFBConfigAttrib(n, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB) ? true : false;
}
u->alphaBits = getGLXFBConfigAttrib(n, GLX_ALPHA_SIZE);
u->depthBits = getGLXFBConfigAttrib(n, GLX_DEPTH_SIZE);
u->stencilBits = getGLXFBConfigAttrib(n, GLX_STENCIL_SIZE);
if (transparency_matches && srgb_matches) {
ans_idx = i; break;
}
u->accumRedBits = getGLXFBConfigAttrib(n, GLX_ACCUM_RED_SIZE);
u->accumGreenBits = getGLXFBConfigAttrib(n, GLX_ACCUM_GREEN_SIZE);
u->accumBlueBits = getGLXFBConfigAttrib(n, GLX_ACCUM_BLUE_SIZE);
u->accumAlphaBits = getGLXFBConfigAttrib(n, GLX_ACCUM_ALPHA_SIZE);
u->auxBuffers = getGLXFBConfigAttrib(n, GLX_AUX_BUFFERS);
if (getGLXFBConfigAttrib(n, GLX_STEREO))
u->stereo = GLFW_TRUE;
if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER))
u->doublebuffer = GLFW_TRUE;
if (_glfw.glx.ARB_multisample)
u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);
if (_glfw.glx.ARB_framebuffer_sRGB || _glfw.glx.EXT_framebuffer_sRGB)
u->sRGB = getGLXFBConfigAttrib(n, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB);
u->handle = (uintptr_t) n;
usableCount++;
}
closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);
if (closest)
*result = (GLXFBConfig) closest->handle;
*result = nativeConfigs[ans_idx];
prev_result = nativeConfigs[ans_idx];
XFree(nativeConfigs);
free(usableConfigs);
return closest != NULL;
return true;
}
// Create the OpenGL context using legacy API
//
static GLXContext createLegacyContextGLX(_GLFWwindow* window,
static GLXContext createLegacyContextGLX(_GLFWwindow* window UNUSED,
GLXFBConfig fbconfig,
GLXContext share)
{
@@ -210,10 +200,10 @@ static int extensionSupportedGLX(const char* extension)
if (extensions)
{
if (_glfwStringInExtensionString(extension, extensions))
return GLFW_TRUE;
return true;
}
return GLFW_FALSE;
return false;
}
static GLFWglproc getProcAddressGLX(const char* procname)
@@ -222,8 +212,11 @@ static GLFWglproc getProcAddressGLX(const char* procname)
return _glfw.glx.GetProcAddress((const GLubyte*) procname);
else if (_glfw.glx.GetProcAddressARB)
return _glfw.glx.GetProcAddressARB((const GLubyte*) procname);
else
return _glfw_dlsym(_glfw.glx.handle, procname);
else {
GLFWglproc ans = NULL;
glfw_dlsym(ans, _glfw.glx.handle, procname);
return ans;
}
}
static void destroyContextGLX(_GLFWwindow* window)
@@ -248,7 +241,7 @@ static void destroyContextGLX(_GLFWwindow* window)
// Initialize GLX
//
GLFWbool _glfwInitGLX(void)
bool _glfwInitGLX(void)
{
int i;
const char* sonames[] =
@@ -265,7 +258,7 @@ GLFWbool _glfwInitGLX(void)
};
if (_glfw.glx.handle)
return GLFW_TRUE;
return true;
for (i = 0; sonames[i]; i++)
{
@@ -277,39 +270,25 @@ GLFWbool _glfwInitGLX(void)
if (!_glfw.glx.handle)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: Failed to load GLX");
return GLFW_FALSE;
return false;
}
_glfw.glx.GetFBConfigs =
_glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigs");
_glfw.glx.GetFBConfigAttrib =
_glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigAttrib");
_glfw.glx.GetClientString =
_glfw_dlsym(_glfw.glx.handle, "glXGetClientString");
_glfw.glx.QueryExtension =
_glfw_dlsym(_glfw.glx.handle, "glXQueryExtension");
_glfw.glx.QueryVersion =
_glfw_dlsym(_glfw.glx.handle, "glXQueryVersion");
_glfw.glx.DestroyContext =
_glfw_dlsym(_glfw.glx.handle, "glXDestroyContext");
_glfw.glx.MakeCurrent =
_glfw_dlsym(_glfw.glx.handle, "glXMakeCurrent");
_glfw.glx.SwapBuffers =
_glfw_dlsym(_glfw.glx.handle, "glXSwapBuffers");
_glfw.glx.QueryExtensionsString =
_glfw_dlsym(_glfw.glx.handle, "glXQueryExtensionsString");
_glfw.glx.CreateNewContext =
_glfw_dlsym(_glfw.glx.handle, "glXCreateNewContext");
_glfw.glx.CreateWindow =
_glfw_dlsym(_glfw.glx.handle, "glXCreateWindow");
_glfw.glx.DestroyWindow =
_glfw_dlsym(_glfw.glx.handle, "glXDestroyWindow");
_glfw.glx.GetProcAddress =
_glfw_dlsym(_glfw.glx.handle, "glXGetProcAddress");
_glfw.glx.GetProcAddressARB =
_glfw_dlsym(_glfw.glx.handle, "glXGetProcAddressARB");
_glfw.glx.GetVisualFromFBConfig =
_glfw_dlsym(_glfw.glx.handle, "glXGetVisualFromFBConfig");
glfw_dlsym(_glfw.glx.GetFBConfigs, _glfw.glx.handle, "glXGetFBConfigs");
glfw_dlsym(_glfw.glx.GetFBConfigAttrib, _glfw.glx.handle, "glXGetFBConfigAttrib");
glfw_dlsym(_glfw.glx.ChooseFBConfig, _glfw.glx.handle, "glXChooseFBConfig");
glfw_dlsym(_glfw.glx.GetClientString, _glfw.glx.handle, "glXGetClientString");
glfw_dlsym(_glfw.glx.QueryExtension, _glfw.glx.handle, "glXQueryExtension");
glfw_dlsym(_glfw.glx.QueryVersion, _glfw.glx.handle, "glXQueryVersion");
glfw_dlsym(_glfw.glx.DestroyContext, _glfw.glx.handle, "glXDestroyContext");
glfw_dlsym(_glfw.glx.MakeCurrent, _glfw.glx.handle, "glXMakeCurrent");
glfw_dlsym(_glfw.glx.SwapBuffers, _glfw.glx.handle, "glXSwapBuffers");
glfw_dlsym(_glfw.glx.QueryExtensionsString, _glfw.glx.handle, "glXQueryExtensionsString");
glfw_dlsym(_glfw.glx.CreateNewContext, _glfw.glx.handle, "glXCreateNewContext");
glfw_dlsym(_glfw.glx.CreateWindow, _glfw.glx.handle, "glXCreateWindow");
glfw_dlsym(_glfw.glx.DestroyWindow, _glfw.glx.handle, "glXDestroyWindow");
glfw_dlsym(_glfw.glx.GetProcAddress, _glfw.glx.handle, "glXGetProcAddress");
glfw_dlsym(_glfw.glx.GetProcAddressARB, _glfw.glx.handle, "glXGetProcAddressARB");
glfw_dlsym(_glfw.glx.GetVisualFromFBConfig, _glfw.glx.handle, "glXGetVisualFromFBConfig");
if (!_glfw.glx.GetFBConfigs ||
!_glfw.glx.GetFBConfigAttrib ||
@@ -329,7 +308,7 @@ GLFWbool _glfwInitGLX(void)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"GLX: Failed to load required entry points");
return GLFW_FALSE;
return false;
}
if (!glXQueryExtension(_glfw.x11.display,
@@ -337,21 +316,21 @@ GLFWbool _glfwInitGLX(void)
&_glfw.glx.eventBase))
{
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: GLX extension not found");
return GLFW_FALSE;
return false;
}
if (!glXQueryVersion(_glfw.x11.display, &_glfw.glx.major, &_glfw.glx.minor))
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"GLX: Failed to query GLX version");
return GLFW_FALSE;
return false;
}
if (_glfw.glx.major == 1 && _glfw.glx.minor < 3)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"GLX: GLX version 1.3 is required");
return GLFW_FALSE;
return false;
}
if (extensionSupportedGLX("GLX_EXT_swap_control"))
@@ -360,7 +339,7 @@ GLFWbool _glfwInitGLX(void)
getProcAddressGLX("glXSwapIntervalEXT");
if (_glfw.glx.SwapIntervalEXT)
_glfw.glx.EXT_swap_control = GLFW_TRUE;
_glfw.glx.EXT_swap_control = true;
}
if (extensionSupportedGLX("GLX_SGI_swap_control"))
@@ -369,7 +348,7 @@ GLFWbool _glfwInitGLX(void)
getProcAddressGLX("glXSwapIntervalSGI");
if (_glfw.glx.SwapIntervalSGI)
_glfw.glx.SGI_swap_control = GLFW_TRUE;
_glfw.glx.SGI_swap_control = true;
}
if (extensionSupportedGLX("GLX_MESA_swap_control"))
@@ -378,17 +357,17 @@ GLFWbool _glfwInitGLX(void)
getProcAddressGLX("glXSwapIntervalMESA");
if (_glfw.glx.SwapIntervalMESA)
_glfw.glx.MESA_swap_control = GLFW_TRUE;
_glfw.glx.MESA_swap_control = true;
}
if (extensionSupportedGLX("GLX_ARB_multisample"))
_glfw.glx.ARB_multisample = GLFW_TRUE;
_glfw.glx.ARB_multisample = true;
if (extensionSupportedGLX("GLX_ARB_framebuffer_sRGB"))
_glfw.glx.ARB_framebuffer_sRGB = GLFW_TRUE;
_glfw.glx.ARB_framebuffer_sRGB = true;
if (extensionSupportedGLX("GLX_EXT_framebuffer_sRGB"))
_glfw.glx.EXT_framebuffer_sRGB = GLFW_TRUE;
_glfw.glx.EXT_framebuffer_sRGB = true;
if (extensionSupportedGLX("GLX_ARB_create_context"))
{
@@ -396,25 +375,25 @@ GLFWbool _glfwInitGLX(void)
getProcAddressGLX("glXCreateContextAttribsARB");
if (_glfw.glx.CreateContextAttribsARB)
_glfw.glx.ARB_create_context = GLFW_TRUE;
_glfw.glx.ARB_create_context = true;
}
if (extensionSupportedGLX("GLX_ARB_create_context_robustness"))
_glfw.glx.ARB_create_context_robustness = GLFW_TRUE;
_glfw.glx.ARB_create_context_robustness = true;
if (extensionSupportedGLX("GLX_ARB_create_context_profile"))
_glfw.glx.ARB_create_context_profile = GLFW_TRUE;
_glfw.glx.ARB_create_context_profile = true;
if (extensionSupportedGLX("GLX_EXT_create_context_es2_profile"))
_glfw.glx.EXT_create_context_es2_profile = GLFW_TRUE;
_glfw.glx.EXT_create_context_es2_profile = true;
if (extensionSupportedGLX("GLX_ARB_create_context_no_error"))
_glfw.glx.ARB_create_context_no_error = GLFW_TRUE;
_glfw.glx.ARB_create_context_no_error = true;
if (extensionSupportedGLX("GLX_ARB_context_flush_control"))
_glfw.glx.ARB_context_flush_control = GLFW_TRUE;
_glfw.glx.ARB_context_flush_control = true;
return GLFW_TRUE;
return true;
}
// Terminate GLX
@@ -433,14 +412,14 @@ void _glfwTerminateGLX(void)
#define setAttrib(a, v) \
{ \
assert((size_t) (index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
attribs[index++] = a; \
attribs[index++] = v; \
}
// Create the OpenGL or OpenGL ES context
//
GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
bool _glfwCreateContextGLX(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
@@ -455,7 +434,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"GLX: Failed to find a suitable GLXFBConfig");
return GLFW_FALSE;
return false;
}
if (ctxconfig->client == GLFW_OPENGL_ES_API)
@@ -466,7 +445,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"GLX: OpenGL ES requested but GLX_EXT_create_context_es2_profile is unavailable");
return GLFW_FALSE;
return false;
}
}
@@ -476,7 +455,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"GLX: Forward compatibility requested but GLX_ARB_create_context_profile is unavailable");
return GLFW_FALSE;
return false;
}
}
@@ -487,7 +466,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"GLX: An OpenGL profile requested but GLX_ARB_create_context_profile is unavailable");
return GLFW_FALSE;
return false;
}
}
@@ -552,7 +531,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
if (ctxconfig->noerror)
{
if (_glfw.glx.ARB_create_context_no_error)
setAttrib(GLX_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
setAttrib(GLX_CONTEXT_OPENGL_NO_ERROR_ARB, true);
}
// NOTE: Only request an explicitly versioned context when necessary, as
@@ -588,7 +567,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
if (_glfw.x11.errorCode == _glfw.glx.errorBase + GLXBadProfileARB &&
ctxconfig->client == GLFW_OPENGL_API &&
ctxconfig->profile == GLFW_OPENGL_ANY_PROFILE &&
ctxconfig->forward == GLFW_FALSE)
ctxconfig->forward == false)
{
window->context.glx.handle =
createLegacyContextGLX(window, native, share);
@@ -606,7 +585,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
if (!window->context.glx.handle)
{
_glfwInputErrorX11(GLFW_VERSION_UNAVAILABLE, "GLX: Failed to create context");
return GLFW_FALSE;
return false;
}
window->context.glx.window =
@@ -614,7 +593,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
if (!window->context.glx.window)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to create window");
return GLFW_FALSE;
return false;
}
window->context.makeCurrent = makeContextCurrentGLX;
@@ -624,15 +603,15 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
window->context.getProcAddress = getProcAddressGLX;
window->context.destroy = destroyContextGLX;
return GLFW_TRUE;
return true;
}
#undef setAttrib
// Returns the Visual and depth of the chosen GLXFBConfig
//
GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
bool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig UNUSED,
const _GLFWctxconfig* ctxconfig UNUSED,
const _GLFWfbconfig* fbconfig,
Visual** visual, int* depth)
{
@@ -643,7 +622,7 @@ GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"GLX: Failed to find a suitable GLXFBConfig");
return GLFW_FALSE;
return false;
}
result = glXGetVisualFromFBConfig(_glfw.x11.display, native);
@@ -651,14 +630,14 @@ GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"GLX: Failed to retrieve Visual for GLXFBConfig");
return GLFW_FALSE;
return false;
}
*visual = result->visual;
*depth = result->depth;
XFree(result);
return GLFW_TRUE;
return true;
}

42
glfw/glx_context.h vendored
View File

@@ -1,8 +1,8 @@
//========================================================================
// GLFW 3.3 GLX - www.glfw.org
// GLFW 3.4 GLX - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
@@ -73,6 +73,7 @@ typedef struct __GLXcontext* GLXContext;
typedef void (*__GLXextproc)(void);
typedef int (*PFNGLXGETFBCONFIGATTRIBPROC)(Display*,GLXFBConfig,int,int*);
typedef GLXFBConfig* (*PFNGLXCHOOSEFBCONFIGPROC)(Display*,int,const int*,int*);
typedef const char* (*PFNGLXGETCLIENTSTRINGPROC)(Display*,int);
typedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display*,int*,int*);
typedef Bool (*PFNGLXQUERYVERSIONPROC)(Display*,int*,int*);
@@ -95,6 +96,7 @@ typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLX
// libGL.so function pointer typedefs
#define glXGetFBConfigs _glfw.glx.GetFBConfigs
#define glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib
#define glXChooseFBConfig _glfw.glx.ChooseFBConfig
#define glXGetClientString _glfw.glx.GetClientString
#define glXQueryExtension _glfw.glx.QueryExtension
#define glXQueryVersion _glfw.glx.QueryVersion
@@ -107,8 +109,8 @@ typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLX
#define glXCreateWindow _glfw.glx.CreateWindow
#define glXDestroyWindow _glfw.glx.DestroyWindow
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx;
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx;
// GLX-specific per-context data
@@ -134,6 +136,7 @@ typedef struct _GLFWlibraryGLX
// GLX 1.3 functions
PFNGLXGETFBCONFIGSPROC GetFBConfigs;
PFNGLXGETFBCONFIGATTRIBPROC GetFBConfigAttrib;
PFNGLXCHOOSEFBCONFIGPROC ChooseFBConfig;
PFNGLXGETCLIENTSTRINGPROC GetClientString;
PFNGLXQUERYEXTENSIONPROC QueryExtension;
PFNGLXQUERYVERSIONPROC QueryVersion;
@@ -153,29 +156,28 @@ typedef struct _GLFWlibraryGLX
PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT;
PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA;
PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
GLFWbool SGI_swap_control;
GLFWbool EXT_swap_control;
GLFWbool MESA_swap_control;
GLFWbool ARB_multisample;
GLFWbool ARB_framebuffer_sRGB;
GLFWbool EXT_framebuffer_sRGB;
GLFWbool ARB_create_context;
GLFWbool ARB_create_context_profile;
GLFWbool ARB_create_context_robustness;
GLFWbool EXT_create_context_es2_profile;
GLFWbool ARB_create_context_no_error;
GLFWbool 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;
GLFWbool _glfwInitGLX(void);
bool _glfwInitGLX(void);
void _glfwTerminateGLX(void);
GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
bool _glfwCreateContextGLX(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig);
void _glfwDestroyContextGLX(_GLFWwindow* window);
GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
bool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig,
Visual** visual, int* depth);

109
glfw/ibus_glfw.c vendored
View File

@@ -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>
//
@@ -50,14 +50,14 @@ enum Capabilities {
};
static inline GLFWbool
static inline bool
test_env_var(const char *name, const char *val) {
const char *q = getenv(name);
return (q && strcmp(q, val) == 0) ? GLFW_TRUE : GLFW_FALSE;
return (q && strcmp(q, val) == 0) ? true : false;
}
static inline size_t
MIN(size_t a, size_t b) {
GLFW_MIN(size_t a, size_t b) {
return a < b ? a : b;
}
@@ -107,17 +107,20 @@ get_ibus_text_from_message(DBusMessage *msg) {
}
static inline void
send_text(const char *text, int state) {
send_text(const char *text, GLFWIMEState ime_state) {
_GLFWwindow *w = _glfwFocusedWindow();
if (w && w->callbacks.keyboard) {
w->callbacks.keyboard((GLFWwindow*) w, GLFW_KEY_UNKNOWN, 0, GLFW_PRESS, 0, text, state);
GLFWkeyevent fake_ev = {.action = GLFW_PRESS};
fake_ev.text = text;
fake_ev.ime_state = ime_state;
w->callbacks.keyboard((GLFWwindow*) w, &fake_ev);
}
}
// Connection handling {{{
static DBusHandlerResult
message_handler(DBusConnection *conn, DBusMessage *msg, void *user_data) {
message_handler(DBusConnection *conn UNUSED, DBusMessage *msg, void *user_data) {
// To monitor signals from IBUS, use
//  dbus-monitor --address `ibus address` "type='signal',interface='org.freedesktop.IBus.InputContext'"
_GLFWIBUSData *ibus = (_GLFWIBUSData*)user_data;
@@ -127,11 +130,11 @@ message_handler(DBusConnection *conn, DBusMessage *msg, void *user_data) {
case 0:
text = get_ibus_text_from_message(msg);
debug("IBUS: CommitText: '%s'\n", text ? text : "(nil)");
send_text(text, 2);
send_text(text, GLFW_IME_COMMIT_TEXT);
break;
case 1:
text = get_ibus_text_from_message(msg);
send_text(text, 1);
send_text(text, GLFW_IME_PREEDIT_CHANGED);
debug("IBUS: UpdatePreeditText: '%s'\n", text ? text : "(nil)");
break;
case 2:
@@ -151,7 +154,7 @@ get_ibus_address_file_name(void) {
addr = getenv("IBUS_ADDRESS");
int offset = 0;
if (addr && addr[0]) {
memcpy(ans, addr, MIN(strlen(addr), sizeof(ans)));
memcpy(ans, addr, GLFW_MIN(strlen(addr), sizeof(ans)));
return ans;
}
@@ -193,39 +196,39 @@ get_ibus_address_file_name(void) {
}
static inline GLFWbool
static inline bool
read_ibus_address(_GLFWIBUSData *ibus) {
static char buf[1024];
struct stat s;
FILE *addr_file = fopen(ibus->address_file_name, "r");
if (!addr_file) {
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to open IBUS address file: %s with error: %s", ibus->address_file_name, strerror(errno));
return GLFW_FALSE;
return false;
}
int stat_result = fstat(fileno(addr_file), &s);
GLFWbool found = GLFW_FALSE;
bool found = false;
while (fgets(buf, sizeof(buf), addr_file)) {
if (strncmp(buf, "IBUS_ADDRESS=", sizeof("IBUS_ADDRESS=")-1) == 0) {
size_t sz = strlen(buf);
if (buf[sz-1] == '\n') buf[sz-1] = 0;
if (buf[sz-2] == '\r') buf[sz-2] = 0;
found = GLFW_TRUE;
found = true;
break;
}
}
fclose(addr_file); addr_file = NULL;
if (stat_result != 0) {
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to stat IBUS address file: %s with error: %s", ibus->address_file_name, strerror(errno));
return GLFW_FALSE;
return false;
}
ibus->address_file_mtime = s.st_mtime;
if (found) {
free((void*)ibus->address);
ibus->address = _glfw_strdup(buf + sizeof("IBUS_ADDRESS=") - 1);
return GLFW_TRUE;
return true;
}
_glfwInputError(GLFW_PLATFORM_ERROR, "Could not find IBUS_ADDRESS in %s", ibus->address_file_name);
return GLFW_FALSE;
return false;
}
void
@@ -245,35 +248,35 @@ input_context_created(DBusMessage *msg, const char* errmsg, void *data) {
dbus_connection_try_register_object_path(ibus->conn, ibus->input_ctx_path, &ibus_vtable, ibus, NULL);
enum Capabilities caps = IBUS_CAP_FOCUS | IBUS_CAP_PREEDIT_TEXT;
if (!glfw_dbus_call_method_no_reply(ibus->conn, IBUS_SERVICE, ibus->input_ctx_path, IBUS_INPUT_INTERFACE, "SetCapabilities", DBUS_TYPE_UINT32, &caps, DBUS_TYPE_INVALID)) return;
ibus->ok = GLFW_TRUE;
glfw_ibus_set_focused(ibus, GLFW_FALSE);
ibus->ok = true;
glfw_ibus_set_focused(ibus, false);
glfw_ibus_set_cursor_geometry(ibus, 0, 0, 0, 0);
debug("Connected to IBUS daemon for IME input management\n");
}
GLFWbool
bool
setup_connection(_GLFWIBUSData *ibus) {
const char *client_name = "GLFW_Application";
const char *address_file_name = get_ibus_address_file_name();
ibus->ok = GLFW_FALSE;
if (!address_file_name) return GLFW_FALSE;
ibus->ok = false;
if (!address_file_name) return false;
free((void*)ibus->address_file_name);
ibus->address_file_name = _glfw_strdup(address_file_name);
if (!read_ibus_address(ibus)) return GLFW_FALSE;
if (!read_ibus_address(ibus)) return false;
if (ibus->conn) {
glfw_dbus_close_connection(ibus->conn);
ibus->conn = NULL;
}
debug("Connecting to IBUS daemon @ %s for IME input management\n", ibus->address);
ibus->conn = glfw_dbus_connect_to(ibus->address, "Failed to connect to the IBUS daemon, with error", "ibus", GLFW_FALSE);
if (!ibus->conn) return GLFW_FALSE;
ibus->conn = glfw_dbus_connect_to(ibus->address, "Failed to connect to the IBUS daemon, with error", "ibus", true);
if (!ibus->conn) return false;
free((void*)ibus->input_ctx_path); ibus->input_ctx_path = NULL;
if (!glfw_dbus_call_method_with_reply(
ibus->conn, IBUS_SERVICE, IBUS_PATH, IBUS_INTERFACE, "CreateInputContext", DBUS_TIMEOUT_USE_DEFAULT, input_context_created, ibus,
DBUS_TYPE_STRING, &client_name, DBUS_TYPE_INVALID)) {
return GLFW_FALSE;
return false;
}
return GLFW_TRUE;
return true;
}
@@ -281,7 +284,7 @@ void
glfw_connect_to_ibus(_GLFWIBUSData *ibus) {
if (ibus->inited) return;
if (!test_env_var("GLFW_IM_MODULE", "ibus")) return;
ibus->inited = GLFW_TRUE;
ibus->inited = true;
setup_connection(ibus);
}
@@ -297,21 +300,21 @@ glfw_ibus_terminate(_GLFWIBUSData *ibus) {
F(address_file_name);
#undef F
ibus->ok = GLFW_FALSE;
ibus->ok = false;
}
static GLFWbool
static bool
check_connection(_GLFWIBUSData *ibus) {
if (!ibus->inited) return GLFW_FALSE;
if (!ibus->inited) return false;
if (ibus->conn && dbus_connection_get_is_connected(ibus->conn)) {
return ibus->ok;
}
struct stat s;
if (stat(ibus->address_file_name, &s) != 0 || s.st_mtime != ibus->address_file_mtime) {
if (!read_ibus_address(ibus)) return GLFW_FALSE;
if (!read_ibus_address(ibus)) return false;
setup_connection(ibus);
}
return GLFW_FALSE;
return false;
}
@@ -329,7 +332,7 @@ simple_message(_GLFWIBUSData *ibus, const char *method) {
}
void
glfw_ibus_set_focused(_GLFWIBUSData *ibus, GLFWbool focused) {
glfw_ibus_set_focused(_GLFWIBUSData *ibus, bool focused) {
simple_message(ibus, focused ? "FocusIn" : "FocusOut");
}
@@ -386,6 +389,7 @@ ibus_key_state(unsigned int glfw_modifiers, int action) {
M(ALT, IBUS_MOD1_MASK);
M(NUM_LOCK, IBUS_MOD2_MASK);
M(SUPER, IBUS_MOD4_MASK);
/* To do: figure out how to get super/hyper/meta */
#undef M
return ans;
}
@@ -393,34 +397,39 @@ ibus_key_state(unsigned int glfw_modifiers, int action) {
void
key_event_processed(DBusMessage *msg, const char* errmsg, void *data) {
uint32_t handled = 0;
KeyEvent *ev = (KeyEvent*)data;
GLFWbool is_release = ev->action == GLFW_RELEASE;
GLFWbool failed = GLFW_FALSE;
_GLFWIBUSKeyEvent *ev = (_GLFWIBUSKeyEvent*)data;
// Restore key's text from the text embedded in the structure.
ev->glfw_ev.text = ev->__embedded_text;
bool is_release = ev->glfw_ev.action == GLFW_RELEASE;
bool failed = false;
if (errmsg) {
_glfwInputError(GLFW_PLATFORM_ERROR, "IBUS: Failed to process key with error: %s", errmsg);
failed = GLFW_TRUE;
failed = true;
} else {
glfw_dbus_get_args(msg, "Failed to get IBUS handled key from reply", DBUS_TYPE_BOOLEAN, &handled, DBUS_TYPE_INVALID);
debug("IBUS processed scancode: 0x%x release: %d handled: %u\n", ev->keycode, is_release, handled);
debug("IBUS processed native_key: 0x%x release: %d handled: %u\n", ev->glfw_ev.native_key, is_release, handled);
}
glfw_xkb_key_from_ime(ev, handled ? GLFW_TRUE : GLFW_FALSE, failed);
glfw_xkb_key_from_ime(ev, handled ? true : false, failed);
free(ev);
}
GLFWbool
ibus_process_key(const KeyEvent *ev_, _GLFWIBUSData *ibus) {
if (!check_connection(ibus)) return GLFW_FALSE;
KeyEvent *ev = malloc(sizeof(KeyEvent));
if (!ev) return GLFW_FALSE;
memcpy(ev, ev_, sizeof(KeyEvent));
uint32_t state = ibus_key_state(ev->glfw_modifiers, ev->action);
bool
ibus_process_key(const _GLFWIBUSKeyEvent *ev_, _GLFWIBUSData *ibus) {
if (!check_connection(ibus)) return false;
_GLFWIBUSKeyEvent *ev = calloc(1, sizeof(_GLFWIBUSKeyEvent));
if (!ev) return false;
memcpy(ev, ev_, sizeof(_GLFWIBUSKeyEvent));
// Put the key's text in a field IN the structure, for proper serialization.
if (ev->glfw_ev.text) strncpy(ev->__embedded_text, ev->glfw_ev.text, sizeof(ev->__embedded_text) - 1);
ev->glfw_ev.text = NULL;
uint32_t state = ibus_key_state(ev->glfw_ev.mods, ev->glfw_ev.action);
if (!glfw_dbus_call_method_with_reply(
ibus->conn, IBUS_SERVICE, ibus->input_ctx_path, IBUS_INPUT_INTERFACE, "ProcessKeyEvent",
3000, key_event_processed, ev,
DBUS_TYPE_UINT32, &ev->ibus_sym, DBUS_TYPE_UINT32, &ev->ibus_keycode, DBUS_TYPE_UINT32,
DBUS_TYPE_UINT32, &ev->ibus_keysym, DBUS_TYPE_UINT32, &ev->ibus_keycode, DBUS_TYPE_UINT32,
&state, DBUS_TYPE_INVALID)) {
free(ev);
return GLFW_FALSE;
return false;
}
return GLFW_TRUE;
return true;
}

21
glfw/ibus_glfw.h vendored
View File

@@ -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>
//
@@ -27,29 +27,28 @@
#pragma once
#include "internal.h"
#include "dbus_glfw.h"
#include <xkbcommon/xkbcommon.h>
typedef struct {
GLFWbool ok, inited;
bool ok, inited;
time_t address_file_mtime;
DBusConnection *conn;
const char *input_ctx_path, *address_file_name, *address;
} _GLFWIBUSData;
typedef struct {
xkb_keycode_t keycode, ibus_keycode;
xkb_keysym_t keysym, ibus_sym;
unsigned int glfw_modifiers;
int action;
xkb_keycode_t ibus_keycode;
xkb_keysym_t ibus_keysym;
GLFWid window_id;
int glfw_keycode;
char text[64];
} KeyEvent;
GLFWkeyevent glfw_ev;
char __embedded_text[64];
} _GLFWIBUSKeyEvent;
void glfw_connect_to_ibus(_GLFWIBUSData *ibus);
void glfw_ibus_terminate(_GLFWIBUSData *ibus);
void glfw_ibus_set_focused(_GLFWIBUSData *ibus, GLFWbool focused);
void glfw_ibus_set_focused(_GLFWIBUSData *ibus, bool focused);
void glfw_ibus_dispatch(_GLFWIBUSData *ibus);
GLFWbool ibus_process_key(const KeyEvent *ev_, _GLFWIBUSData *ibus);
bool ibus_process_key(const _GLFWIBUSKeyEvent *ev_, _GLFWIBUSData *ibus);
void glfw_ibus_set_cursor_geometry(_GLFWIBUSData *ibus, int x, int y, int w, int h);

80
glfw/init.c vendored
View File

@@ -1,8 +1,8 @@
//========================================================================
// 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>
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
@@ -24,6 +24,8 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#include "mappings.h"
@@ -41,21 +43,21 @@
// Global state shared between compilation units of GLFW
//
_GLFWlibrary _glfw = { GLFW_FALSE };
_GLFWlibrary _glfw = { false };
// These are outside of _glfw so they can be used before initialization and
// after termination
//
static _GLFWerror _glfwMainThreadError;
static GLFWerrorfun _glfwErrorCallback;
static _GLFWinitconfig _glfwInitHints =
{
GLFW_TRUE, // hat buttons
GLFW_FALSE, // debug keyboard
GLFW_TRUE, // enable joystick
{
GLFW_TRUE, // macOS menu bar
GLFW_TRUE // macOS bundle chdir
static _GLFWinitconfig _glfwInitHints = {
.hatButtons = true,
.angleType = GLFW_ANGLE_PLATFORM_TYPE_NONE,
.debugKeyboard = false,
.debugRendering = false,
.ns = {
.menubar = true, // macOS menu bar
.chdir = true // macOS bundle chdir
}
};
@@ -90,9 +92,10 @@ static void terminate(void)
_glfw.mappingCount = 0;
_glfwTerminateVulkan();
_glfwPlatformTerminateJoysticks();
_glfwPlatformTerminate();
_glfw.initialized = GLFW_FALSE;
_glfw.initialized = false;
while (_glfw.errorListHead)
{
@@ -166,6 +169,10 @@ void _glfwInputError(int code, const char* format, ...)
strcpy(description, "The requested format is unavailable");
else if (code == GLFW_NO_WINDOW_CONTEXT)
strcpy(description, "The specified window has no context");
else if (code == GLFW_FEATURE_UNAVAILABLE)
strcpy(description, "The requested feature cannot be implemented for this platform");
else if (code == GLFW_FEATURE_UNIMPLEMENTED)
strcpy(description, "The requested feature has not yet been implemented for this platform");
else
strcpy(description, "ERROR: UNKNOWN GLFW ERROR");
}
@@ -199,7 +206,7 @@ _glfwDebug(const char *format, ...) {
{
va_list vl;
fprintf(stderr, "[%.4f] ", glfwGetTime());
fprintf(stderr, "[%.4f] ", monotonic_t_to_s_double(glfwGetTime()));
va_start(vl, format);
vfprintf(stderr, format, vl);
va_end(vl);
@@ -212,10 +219,11 @@ _glfwDebug(const char *format, ...) {
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
GLFWAPI int glfwInit(void)
GLFWAPI int glfwInit(monotonic_t start_time)
{
if (_glfw.initialized)
return GLFW_TRUE;
return true;
monotonic_start_time = start_time;
memset(&_glfw, 0, sizeof(_glfw));
_glfw.hints.init = _glfwInitHints;
@@ -223,7 +231,7 @@ GLFWAPI int glfwInit(void)
if (!_glfwPlatformInit())
{
terminate();
return GLFW_FALSE;
return false;
}
if (!_glfwPlatformCreateMutex(&_glfw.errorLock) ||
@@ -231,13 +239,12 @@ GLFWAPI int glfwInit(void)
!_glfwPlatformCreateTls(&_glfw.contextSlot))
{
terminate();
return GLFW_FALSE;
return false;
}
_glfwPlatformSetTls(&_glfw.errorSlot, &_glfwMainThreadError);
_glfw.initialized = GLFW_TRUE;
_glfw.timer.offset = _glfwPlatformGetTimerValue();
_glfw.initialized = true;
glfwDefaultWindowHints();
@@ -249,12 +256,12 @@ GLFWAPI int glfwInit(void)
if (!glfwUpdateGamepadMappings(_glfwDefaultMappings[i]))
{
terminate();
return GLFW_FALSE;
return false;
}
}
}
return GLFW_TRUE;
return true;
}
GLFWAPI void glfwTerminate(void)
@@ -269,15 +276,18 @@ GLFWAPI void glfwInitHint(int hint, int value)
{
switch (hint)
{
case GLFW_ENABLE_JOYSTICKS:
_glfwInitHints.enableJoysticks = value;
return;
case GLFW_JOYSTICK_HAT_BUTTONS:
_glfwInitHints.hatButtons = value;
return;
case GLFW_ANGLE_PLATFORM_TYPE:
_glfwInitHints.angleType = value;
return;
case GLFW_DEBUG_KEYBOARD:
_glfwInitHints.debugKeyboard = value;
return;
case GLFW_DEBUG_RENDERING:
_glfwInitHints.debugRendering = value;
return;
case GLFW_COCOA_CHDIR_RESOURCES:
_glfwInitHints.ns.chdir = value;
return;
@@ -342,26 +352,36 @@ GLFWAPI void glfwRunMainLoop(GLFWtickcallback callback, void *data)
_glfwPlatformRunMainLoop(callback, data);
}
GLFWAPI void glfwRequestTickCallback(void) {
_glfwPlatformRequestTickCallback();
}
GLFWAPI void glfwStopMainLoop(void) {
_GLFW_REQUIRE_INIT();
_glfwPlatformStopMainLoop();
}
GLFWAPI unsigned long long glfwAddTimer(
double interval, bool repeats, GLFWuserdatafun callback,
monotonic_t interval, bool repeats, GLFWuserdatafun callback,
void *callback_data, GLFWuserdatafun free_callback)
{
return _glfwPlatformAddTimer(interval, repeats, callback, callback_data, free_callback);
}
GLFWAPI void glfwUpdateTimer(unsigned long long timer_id, double interval, bool enabled) {
GLFWAPI void glfwUpdateTimer(unsigned long long timer_id, monotonic_t interval, bool enabled) {
_glfwPlatformUpdateTimer(timer_id, interval, enabled);
}
GLFWAPI void glfwRemoveTimer(unsigned long long timer_id) {
_glfwPlatformRemoveTimer(timer_id);
}
GLFWAPI GLFWapplicationclosefun glfwSetApplicationCloseCallback(GLFWapplicationclosefun cbfun)
{
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP_POINTERS(_glfw.callbacks.application_close, cbfun);
return cbfun;
}
GLFWAPI GLFWdrawtextfun glfwSetDrawTextFunction(GLFWdrawtextfun cbfun)
{
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP_POINTERS(_glfw.callbacks.draw_text, cbfun);
return cbfun;
}

632
glfw/input.c vendored
View File

@@ -1,8 +1,8 @@
//========================================================================
// 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>
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
@@ -24,8 +24,11 @@
// distribution.
//
//========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#include "../kitty/monotonic.h"
#include <assert.h>
#include <float.h>
@@ -41,6 +44,22 @@
#define _GLFW_JOYSTICK_BUTTON 2
#define _GLFW_JOYSTICK_HATBIT 3
// Initializes the platform joystick API if it has not been already
//
static bool initJoysticks(void)
{
if (!_glfw.joysticksInitialized)
{
if (!_glfwPlatformInitJoysticks())
{
_glfwPlatformTerminateJoysticks();
return false;
}
}
return _glfw.joysticksInitialized = true;
}
// Finds a mapping based on joystick GUID
//
static _GLFWmapping* findMapping(const char* guid)
@@ -58,17 +77,17 @@ static _GLFWmapping* findMapping(const char* guid)
// Checks whether a gamepad mapping element is present in the hardware
//
static GLFWbool isValidElementForJoystick(const _GLFWmapelement* e,
static bool isValidElementForJoystick(const _GLFWmapelement* e,
const _GLFWjoystick* js)
{
if (e->type == _GLFW_JOYSTICK_HATBIT && (e->index >> 4) >= js->hatCount)
return GLFW_FALSE;
return false;
else if (e->type == _GLFW_JOYSTICK_BUTTON && e->index >= js->buttonCount)
return GLFW_FALSE;
return false;
else if (e->type == _GLFW_JOYSTICK_AXIS && e->index >= js->axisCount)
return GLFW_FALSE;
return false;
return GLFW_TRUE;
return true;
}
// Finds a mapping based on joystick GUID and verifies element indices
@@ -110,7 +129,7 @@ static _GLFWmapping* findValidMapping(const _GLFWjoystick* js)
// Parses an SDL_GameControllerDB line and adds it to the mapping list
//
static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
static bool parseMapping(_GLFWmapping* mapping, const char* string)
{
const char* c = string;
size_t i, length;
@@ -148,7 +167,7 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
if (length != 32 || c[length] != ',')
{
_glfwInputError(GLFW_INVALID_VALUE, NULL);
return GLFW_FALSE;
return false;
}
memcpy(mapping->guid, c, length);
@@ -158,7 +177,7 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
if (length >= sizeof(mapping->name) || c[length] != ',')
{
_glfwInputError(GLFW_INVALID_VALUE, NULL);
return GLFW_FALSE;
return false;
}
memcpy(mapping->name, c, length);
@@ -168,7 +187,7 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
{
// TODO: Implement output modifiers
if (*c == '+' || *c == '-')
return GLFW_FALSE;
return false;
for (i = 0; i < sizeof(fields) / sizeof(fields[0]); i++)
{
@@ -229,7 +248,7 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
{
length = strlen(_GLFW_PLATFORM_MAPPING_NAME);
if (strncmp(c, _GLFW_PLATFORM_MAPPING_NAME, length) != 0)
return GLFW_FALSE;
return false;
}
break;
@@ -246,7 +265,7 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
}
_glfwPlatformUpdateGamepadGUID(mapping->guid);
return GLFW_TRUE;
return true;
}
@@ -254,42 +273,81 @@ static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
////// GLFW event API //////
//////////////////////////////////////////////////////////////////////////
// Notifies shared code of a key event
//
void _glfwInputKeyboard(_GLFWwindow* window, int key, int scancode, int action, int mods, const char* text, int state)
{
if (key >= 0 && key <= GLFW_KEY_LAST)
{
GLFWbool repeated = GLFW_FALSE;
static void
set_key_action(_GLFWwindow *window, uint32_t key, int val, int idx) {
const unsigned sz = arraysz(window->activated_keys);
if (idx < 0) {
for (unsigned i = 0; i < sz; i++) {
if (window->activated_keys[i].key == 0) {
idx = i;
break;
}
}
if (idx < 0) {
idx = sz - 1;
memmove(window->activated_keys, window->activated_keys + 1, sizeof(window->activated_keys[0]) * (sz - 1));
window->activated_keys[sz - 1].key = key;
}
}
if (val == GLFW_RELEASE) {
memset(window->activated_keys + idx, 0, sizeof(window->activated_keys[0]));
if (idx < (int)sz - 1) {
memmove(window->activated_keys + idx, window->activated_keys + idx + 1, sizeof(window->activated_keys[0]) * (sz - 1 - idx));
memset(window->activated_keys + sz - 1, 0, sizeof(window->activated_keys[0]));
}
} else {
window->activated_keys[idx].key = key;
window->activated_keys[idx].action = val;
}
}
if (action == GLFW_RELEASE && window->keys[key] == GLFW_RELEASE)
// Notifies shared code of a physical key event
//
void _glfwInputKeyboard(_GLFWwindow* window, GLFWkeyevent* ev)
{
if (ev->key > 0)
{
bool repeated = false;
int idx = -1;
int current_action = GLFW_RELEASE;
const unsigned sz = arraysz(window->activated_keys);
for (unsigned i = 0; i < sz; i++) {
if (window->activated_keys[i].key == ev->key) {
idx = i;
current_action = window->activated_keys[i].action;
break;
}
}
if (ev->action == GLFW_RELEASE && current_action == GLFW_RELEASE)
return;
if (action == GLFW_PRESS && window->keys[key] == GLFW_PRESS)
repeated = GLFW_TRUE;
if (ev->action == GLFW_PRESS && current_action == GLFW_PRESS)
repeated = true;
if (action == GLFW_RELEASE && window->stickyKeys)
window->keys[key] = _GLFW_STICK;
if (ev->action == GLFW_RELEASE && window->stickyKeys)
set_key_action(window, ev->key, _GLFW_STICK, idx);
else
window->keys[key] = (char) action;
set_key_action(window, ev->key, ev->action, idx);
if (repeated)
action = GLFW_REPEAT;
ev->action = GLFW_REPEAT;
}
// FIXME: will need to update ev->virtual_mods here too?
if (window->callbacks.keyboard) {
if (!window->lockKeyMods) mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
window->callbacks.keyboard((GLFWwindow*) window, key, scancode, action, mods, text, state);
if (!window->lockKeyMods) ev->mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
window->callbacks.keyboard((GLFWwindow*) window, ev);
}
}
// Notifies shared code of a scroll event
//
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset, int flags)
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset, int flags, int mods)
{
if (window->callbacks.scroll)
window->callbacks.scroll((GLFWwindow*) window, xoffset, yoffset, flags);
window->callbacks.scroll((GLFWwindow*) window, xoffset, yoffset, flags, mods);
}
// Notifies shared code of a mouse button click event
@@ -328,7 +386,7 @@ void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos)
// Notifies shared code of a cursor enter/leave event
//
void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered)
void _glfwInputCursorEnter(_GLFWwindow* window, bool entered)
{
if (window->callbacks.cursorEnter)
window->callbacks.cursorEnter((GLFWwindow*) window, entered);
@@ -336,10 +394,11 @@ void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered)
// Notifies shared code of files or directories dropped on a window
//
void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths)
int _glfwInputDrop(_GLFWwindow* window, const char *mime, const char *text, size_t sz)
{
if (window->callbacks.drop)
window->callbacks.drop((GLFWwindow*) window, count, paths);
return window->callbacks.drop((GLFWwindow*) window, mime, text, sz);
return 0;
}
// Notifies shared code of a joystick connection or disconnection
@@ -406,10 +465,10 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
return NULL;
js = _glfw.joysticks + jid;
js->present = GLFW_TRUE;
js->present = true;
js->name = _glfw_strdup(name);
js->axes = calloc(axisCount, sizeof(float));
js->buttons = calloc(buttonCount + hatCount * 4, 1);
js->buttons = calloc(buttonCount + (size_t) hatCount * 4, 1);
js->hats = calloc(hatCount, 1);
js->axisCount = axisCount;
js->buttonCount = buttonCount;
@@ -432,149 +491,169 @@ void _glfwFreeJoystick(_GLFWjoystick* js)
memset(js, 0, sizeof(_GLFWjoystick));
}
const char* _glfwGetKeyName(int key)
unsigned int
encode_utf8(uint32_t ch, char* dest) {
if (ch < 0x80) {
dest[0] = (char)ch;
return 1;
}
if (ch < 0x800) {
dest[0] = (ch>>6) | 0xC0;
dest[1] = (ch & 0x3F) | 0x80;
return 2;
}
if (ch < 0x10000) {
dest[0] = (ch>>12) | 0xE0;
dest[1] = ((ch>>6) & 0x3F) | 0x80;
dest[2] = (ch & 0x3F) | 0x80;
return 3;
}
if (ch < 0x110000) {
dest[0] = (ch>>18) | 0xF0;
dest[1] = ((ch>>12) & 0x3F) | 0x80;
dest[2] = ((ch>>6) & 0x3F) | 0x80;
dest[3] = (ch & 0x3F) | 0x80;
return 4;
}
return 0;
}
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";
// 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";
default: return "UNKNOWN";
/* start functional key names (auto generated by gen-key-constants.py do not edit) */
case GLFW_FKEY_ESCAPE: return "ESCAPE";
case GLFW_FKEY_ENTER: return "ENTER";
case GLFW_FKEY_TAB: return "TAB";
case GLFW_FKEY_BACKSPACE: return "BACKSPACE";
case GLFW_FKEY_INSERT: return "INSERT";
case GLFW_FKEY_DELETE: return "DELETE";
case GLFW_FKEY_LEFT: return "LEFT";
case GLFW_FKEY_RIGHT: return "RIGHT";
case GLFW_FKEY_UP: return "UP";
case GLFW_FKEY_DOWN: return "DOWN";
case GLFW_FKEY_PAGE_UP: return "PAGE_UP";
case GLFW_FKEY_PAGE_DOWN: return "PAGE_DOWN";
case GLFW_FKEY_HOME: return "HOME";
case GLFW_FKEY_END: return "END";
case GLFW_FKEY_CAPS_LOCK: return "CAPS_LOCK";
case GLFW_FKEY_SCROLL_LOCK: return "SCROLL_LOCK";
case GLFW_FKEY_NUM_LOCK: return "NUM_LOCK";
case GLFW_FKEY_PRINT_SCREEN: return "PRINT_SCREEN";
case GLFW_FKEY_PAUSE: return "PAUSE";
case GLFW_FKEY_MENU: return "MENU";
case GLFW_FKEY_F1: return "F1";
case GLFW_FKEY_F2: return "F2";
case GLFW_FKEY_F3: return "F3";
case GLFW_FKEY_F4: return "F4";
case GLFW_FKEY_F5: return "F5";
case GLFW_FKEY_F6: return "F6";
case GLFW_FKEY_F7: return "F7";
case GLFW_FKEY_F8: return "F8";
case GLFW_FKEY_F9: return "F9";
case GLFW_FKEY_F10: return "F10";
case GLFW_FKEY_F11: return "F11";
case GLFW_FKEY_F12: return "F12";
case GLFW_FKEY_F13: return "F13";
case GLFW_FKEY_F14: return "F14";
case GLFW_FKEY_F15: return "F15";
case GLFW_FKEY_F16: return "F16";
case GLFW_FKEY_F17: return "F17";
case GLFW_FKEY_F18: return "F18";
case GLFW_FKEY_F19: return "F19";
case GLFW_FKEY_F20: return "F20";
case GLFW_FKEY_F21: return "F21";
case GLFW_FKEY_F22: return "F22";
case GLFW_FKEY_F23: return "F23";
case GLFW_FKEY_F24: return "F24";
case GLFW_FKEY_F25: return "F25";
case GLFW_FKEY_F26: return "F26";
case GLFW_FKEY_F27: return "F27";
case GLFW_FKEY_F28: return "F28";
case GLFW_FKEY_F29: return "F29";
case GLFW_FKEY_F30: return "F30";
case GLFW_FKEY_F31: return "F31";
case GLFW_FKEY_F32: return "F32";
case GLFW_FKEY_F33: return "F33";
case GLFW_FKEY_F34: return "F34";
case GLFW_FKEY_F35: return "F35";
case GLFW_FKEY_KP_0: return "KP_0";
case GLFW_FKEY_KP_1: return "KP_1";
case GLFW_FKEY_KP_2: return "KP_2";
case GLFW_FKEY_KP_3: return "KP_3";
case GLFW_FKEY_KP_4: return "KP_4";
case GLFW_FKEY_KP_5: return "KP_5";
case GLFW_FKEY_KP_6: return "KP_6";
case GLFW_FKEY_KP_7: return "KP_7";
case GLFW_FKEY_KP_8: return "KP_8";
case GLFW_FKEY_KP_9: return "KP_9";
case GLFW_FKEY_KP_DECIMAL: return "KP_DECIMAL";
case GLFW_FKEY_KP_DIVIDE: return "KP_DIVIDE";
case GLFW_FKEY_KP_MULTIPLY: return "KP_MULTIPLY";
case GLFW_FKEY_KP_SUBTRACT: return "KP_SUBTRACT";
case GLFW_FKEY_KP_ADD: return "KP_ADD";
case GLFW_FKEY_KP_ENTER: return "KP_ENTER";
case GLFW_FKEY_KP_EQUAL: return "KP_EQUAL";
case GLFW_FKEY_KP_SEPARATOR: return "KP_SEPARATOR";
case GLFW_FKEY_KP_LEFT: return "KP_LEFT";
case GLFW_FKEY_KP_RIGHT: return "KP_RIGHT";
case GLFW_FKEY_KP_UP: return "KP_UP";
case GLFW_FKEY_KP_DOWN: return "KP_DOWN";
case GLFW_FKEY_KP_PAGE_UP: return "KP_PAGE_UP";
case GLFW_FKEY_KP_PAGE_DOWN: return "KP_PAGE_DOWN";
case GLFW_FKEY_KP_HOME: return "KP_HOME";
case GLFW_FKEY_KP_END: return "KP_END";
case GLFW_FKEY_KP_INSERT: return "KP_INSERT";
case GLFW_FKEY_KP_DELETE: return "KP_DELETE";
case GLFW_FKEY_KP_BEGIN: return "KP_BEGIN";
case GLFW_FKEY_MEDIA_PLAY: return "MEDIA_PLAY";
case GLFW_FKEY_MEDIA_PAUSE: return "MEDIA_PAUSE";
case GLFW_FKEY_MEDIA_PLAY_PAUSE: return "MEDIA_PLAY_PAUSE";
case GLFW_FKEY_MEDIA_REVERSE: return "MEDIA_REVERSE";
case GLFW_FKEY_MEDIA_STOP: return "MEDIA_STOP";
case GLFW_FKEY_MEDIA_FAST_FORWARD: return "MEDIA_FAST_FORWARD";
case GLFW_FKEY_MEDIA_REWIND: return "MEDIA_REWIND";
case GLFW_FKEY_MEDIA_TRACK_NEXT: return "MEDIA_TRACK_NEXT";
case GLFW_FKEY_MEDIA_TRACK_PREVIOUS: return "MEDIA_TRACK_PREVIOUS";
case GLFW_FKEY_MEDIA_RECORD: return "MEDIA_RECORD";
case GLFW_FKEY_LOWER_VOLUME: return "LOWER_VOLUME";
case GLFW_FKEY_RAISE_VOLUME: return "RAISE_VOLUME";
case GLFW_FKEY_MUTE_VOLUME: return "MUTE_VOLUME";
case GLFW_FKEY_LEFT_SHIFT: return "LEFT_SHIFT";
case GLFW_FKEY_LEFT_CONTROL: return "LEFT_CONTROL";
case GLFW_FKEY_LEFT_ALT: return "LEFT_ALT";
case GLFW_FKEY_LEFT_SUPER: return "LEFT_SUPER";
case GLFW_FKEY_LEFT_HYPER: return "LEFT_HYPER";
case GLFW_FKEY_LEFT_META: return "LEFT_META";
case GLFW_FKEY_RIGHT_SHIFT: return "RIGHT_SHIFT";
case GLFW_FKEY_RIGHT_CONTROL: return "RIGHT_CONTROL";
case GLFW_FKEY_RIGHT_ALT: return "RIGHT_ALT";
case GLFW_FKEY_RIGHT_SUPER: return "RIGHT_SUPER";
case GLFW_FKEY_RIGHT_HYPER: return "RIGHT_HYPER";
case GLFW_FKEY_RIGHT_META: return "RIGHT_META";
case GLFW_FKEY_ISO_LEVEL3_SHIFT: return "ISO_LEVEL3_SHIFT";
case GLFW_FKEY_ISO_LEVEL5_SHIFT: return "ISO_LEVEL5_SHIFT";
/* end functional key names */
case 0: return "UNKNOWN";
}
static char buf[16];
encode_utf8(key, buf);
return buf;
}
// Center the cursor in the middle of the content area of the specified window
// Center the cursor in the content area of the specified window
//
void _glfwCenterCursorInContentArea(_GLFWwindow* window)
{
int width, height;
_glfwPlatformGetWindowSize(window, &width, &height);
_glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
}
//////////////////////////////////////////////////////////////////////////
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
@@ -596,6 +675,8 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)
return window->stickyMouseButtons;
case GLFW_LOCK_KEY_MODS:
return window->lockKeyMods;
case GLFW_RAW_MOUSE_MOTION:
return window->rawMouseMotion;
}
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
@@ -633,19 +714,21 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
}
else if (mode == GLFW_STICKY_KEYS)
{
value = value ? GLFW_TRUE : GLFW_FALSE;
value = value ? true : false;
if (window->stickyKeys == value)
return;
if (!value)
{
int i;
// Release all sticky keys
for (i = 0; i <= GLFW_KEY_LAST; i++)
for (unsigned i = arraysz(window->activated_keys) - 1; i-- > 0;)
{
if (window->keys[i] == _GLFW_STICK)
window->keys[i] = GLFW_RELEASE;
if (window->activated_keys[i].action == _GLFW_STICK) {
if (i < arraysz(window->activated_keys) - 1) {
memmove(window->activated_keys + i, window->activated_keys + i + 1, sizeof(window->activated_keys[0]) * (arraysz(window->activated_keys) - 1 - i));
}
memset(window->activated_keys + arraysz(window->activated_keys) - 1, 0, sizeof(window->activated_keys[0]));
}
}
}
@@ -653,7 +736,7 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
}
else if (mode == GLFW_STICKY_MOUSE_BUTTONS)
{
value = value ? GLFW_TRUE : GLFW_FALSE;
value = value ? true : false;
if (window->stickyMouseButtons == value)
return;
@@ -672,64 +755,79 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
window->stickyMouseButtons = value;
}
else if (mode == GLFW_LOCK_KEY_MODS)
window->lockKeyMods = value ? GLFW_TRUE : GLFW_FALSE;
{
window->lockKeyMods = value ? true : false;
}
else if (mode == GLFW_RAW_MOUSE_MOTION)
{
if (!_glfwPlatformRawMouseMotionSupported())
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Raw mouse motion is not supported on this system");
return;
}
value = value ? true : false;
if (window->rawMouseMotion == value)
return;
window->rawMouseMotion = value;
_glfwPlatformSetRawMouseMotion(window, value);
}
else
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
}
GLFWAPI const char* glfwGetKeyName(int key, int scancode)
GLFWAPI int glfwRawMouseMotionSupported(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (key != GLFW_KEY_UNKNOWN)
{
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))
{
return NULL;
}
scancode = _glfwPlatformGetKeyScancode(key);
}
return _glfwPlatformGetScancodeName(scancode);
_GLFW_REQUIRE_INIT_OR_RETURN(false);
return _glfwPlatformRawMouseMotionSupported();
}
GLFWAPI int glfwGetKeyScancode(int key)
GLFWAPI const char* glfwGetKeyName(uint32_t key, int native_key)
{
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (key) return _glfwGetKeyName(key);
native_key = _glfwPlatformGetNativeKeyForKey(key);
return _glfwPlatformGetNativeKeyName(native_key);
}
GLFWAPI int glfwGetNativeKeyForKey(uint32_t key)
{
_GLFW_REQUIRE_INIT_OR_RETURN(-1);
if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key);
return GLFW_RELEASE;
}
return _glfwPlatformGetKeyScancode(key);
return _glfwPlatformGetNativeKeyForKey(key);
}
GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
GLFWAPI GLFWKeyAction glfwGetKey(GLFWwindow* handle, uint32_t key)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
if (!key) return GLFW_RELEASE;
if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key);
return GLFW_RELEASE;
int current_action = GLFW_RELEASE;
const unsigned sz = arraysz(window->activated_keys);
int idx = -1;
for (unsigned i = 0; i < sz; i++) {
if (window->activated_keys[i].key == key) {
idx = i;
current_action = window->activated_keys[i].action;
break;
}
}
if (window->keys[key] == _GLFW_STICK)
if (current_action == _GLFW_STICK)
{
// Sticky mode: release key now
window->keys[key] = GLFW_RELEASE;
return GLFW_PRESS;
set_key_action(window, key, GLFW_RELEASE, idx);
current_action = GLFW_PRESS;
}
return (int) window->keys[key];
return current_action;
}
GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)
@@ -915,13 +1013,13 @@ GLFWAPI GLFWkeyboardfun glfwSetKeyboardCallback(GLFWwindow* handle, GLFWkeyboard
return cbfun;
}
GLFWAPI void glfwUpdateIMEState(GLFWwindow* handle, int which, int a, int b, int c, int d) {
GLFWAPI void glfwUpdateIMEState(GLFWwindow* handle, const GLFWIMEUpdateEvent *ev) {
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT();
#if defined(_GLFW_X11) || defined(_GLFW_WAYLAND) || defined(_GLFW_COCOA)
_glfwPlatformUpdateIMEState(window, which, a, b, c, d);
_glfwPlatformUpdateIMEState(window, ev);
#else
(void)window; (void)which; (void)a; (void)b; (void)c; (void)d;
#endif
@@ -988,17 +1086,20 @@ GLFWAPI int glfwJoystickPresent(int jid)
assert(jid >= GLFW_JOYSTICK_1);
assert(jid <= GLFW_JOYSTICK_LAST);
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
_GLFW_REQUIRE_INIT_OR_RETURN(false);
if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
return GLFW_FALSE;
return false;
}
if (!initJoysticks())
return false;
js = _glfw.joysticks + jid;
if (!js->present)
return GLFW_FALSE;
return false;
return _glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE);
}
@@ -1021,6 +1122,9 @@ GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count)
return NULL;
}
if (!initJoysticks())
return NULL;
js = _glfw.joysticks + jid;
if (!js->present)
return NULL;
@@ -1050,6 +1154,9 @@ GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count)
return NULL;
}
if (!initJoysticks())
return NULL;
js = _glfw.joysticks + jid;
if (!js->present)
return NULL;
@@ -1083,6 +1190,9 @@ GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count)
return NULL;
}
if (!initJoysticks())
return NULL;
js = _glfw.joysticks + jid;
if (!js->present)
return NULL;
@@ -1109,6 +1219,9 @@ GLFWAPI const char* glfwGetJoystickName(int jid)
return NULL;
}
if (!initJoysticks())
return NULL;
js = _glfw.joysticks + jid;
if (!js->present)
return NULL;
@@ -1134,6 +1247,9 @@ GLFWAPI const char* glfwGetJoystickGUID(int jid)
return NULL;
}
if (!initJoysticks())
return NULL;
js = _glfw.joysticks + jid;
if (!js->present)
return NULL;
@@ -1179,6 +1295,10 @@ GLFWAPI void* glfwGetJoystickUserPointer(int jid)
GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun)
{
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (!initJoysticks())
return NULL;
_GLFW_SWAP_POINTERS(_glfw.callbacks.joystick, cbfun);
return cbfun;
}
@@ -1190,7 +1310,7 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string)
assert(string != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
_GLFW_REQUIRE_INIT_OR_RETURN(false);
while (*c)
{
@@ -1240,7 +1360,7 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string)
js->mapping = findValidMapping(js);
}
return GLFW_TRUE;
return true;
}
GLFWAPI int glfwJoystickIsGamepad(int jid)
@@ -1250,20 +1370,23 @@ GLFWAPI int glfwJoystickIsGamepad(int jid)
assert(jid >= GLFW_JOYSTICK_1);
assert(jid <= GLFW_JOYSTICK_LAST);
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
_GLFW_REQUIRE_INIT_OR_RETURN(false);
if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
return GLFW_FALSE;
return false;
}
if (!initJoysticks())
return false;
js = _glfw.joysticks + jid;
if (!js->present)
return GLFW_FALSE;
return false;
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
return GLFW_FALSE;
return false;
return js->mapping != NULL;
}
@@ -1283,6 +1406,9 @@ GLFWAPI const char* glfwGetGamepadName(int jid)
return NULL;
}
if (!initJoysticks())
return NULL;
js = _glfw.joysticks + jid;
if (!js->present)
return NULL;
@@ -1307,23 +1433,26 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
memset(state, 0, sizeof(GLFWgamepadstate));
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
_GLFW_REQUIRE_INIT_OR_RETURN(false);
if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
return GLFW_FALSE;
return false;
}
if (!initJoysticks())
return false;
js = _glfw.joysticks + jid;
if (!js->present)
return GLFW_FALSE;
return false;
if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_ALL))
return GLFW_FALSE;
return false;
if (!js->mapping)
return GLFW_FALSE;
return false;
for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++)
{
@@ -1331,8 +1460,18 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
if (e->type == _GLFW_JOYSTICK_AXIS)
{
const float value = js->axes[e->index] * e->axisScale + e->axisOffset;
if (value > 0.f)
state->buttons[i] = GLFW_PRESS;
// HACK: This should be baked into the value transform
// TODO: Bake into transform when implementing output modifiers
if (e->axisOffset < 0 || (e->axisOffset == 0 && e->axisScale > 0))
{
if (value >= 0.f)
state->buttons[i] = GLFW_PRESS;
}
else
{
if (value <= 0.f)
state->buttons[i] = GLFW_PRESS;
}
}
else if (e->type == _GLFW_JOYSTICK_HATBIT)
{
@@ -1359,15 +1498,17 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
const unsigned int bit = e->index & 0xf;
if (js->hats[hat] & bit)
state->axes[i] = 1.f;
else
state->axes[i] = -1.f;
}
else if (e->type == _GLFW_JOYSTICK_BUTTON)
state->axes[i] = (float) js->buttons[e->index];
state->axes[i] = js->buttons[e->index] * 2.f - 1.f;
}
return GLFW_TRUE;
return true;
}
GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string)
GLFWAPI void glfwSetClipboardString(GLFWwindow* handle UNUSED, const char* string)
{
assert(string != NULL);
@@ -1375,14 +1516,14 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string)
_glfwPlatformSetClipboardString(string);
}
GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle)
GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle UNUSED)
{
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return _glfwPlatformGetClipboardString();
}
#if defined(_GLFW_X11) || defined(_GLFW_WAYLAND)
GLFWAPI void glfwSetPrimarySelectionString(GLFWwindow* handle, const char* string)
GLFWAPI void glfwSetPrimarySelectionString(GLFWwindow* handle UNUSED, const char* string)
{
assert(string != NULL);
@@ -1390,42 +1531,15 @@ GLFWAPI void glfwSetPrimarySelectionString(GLFWwindow* handle, const char* strin
_glfwPlatformSetPrimarySelectionString(string);
}
GLFWAPI const char* glfwGetPrimarySelectionString(GLFWwindow* handle)
GLFWAPI const char* glfwGetPrimarySelectionString(GLFWwindow* handle UNUSED)
{
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return _glfwPlatformGetPrimarySelectionString();
}
#endif
GLFWAPI double glfwGetTime(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(0.0);
return (double) (_glfwPlatformGetTimerValue() - _glfw.timer.offset) /
_glfwPlatformGetTimerFrequency();
}
GLFWAPI void glfwSetTime(double time)
{
_GLFW_REQUIRE_INIT();
if (time != time || time < 0.0 || time > 18446744073.0)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid time %f", time);
return;
}
_glfw.timer.offset = _glfwPlatformGetTimerValue() -
(uint64_t) (time * _glfwPlatformGetTimerFrequency());
}
GLFWAPI uint64_t glfwGetTimerValue(void)
GLFWAPI monotonic_t glfwGetTime(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(0);
return _glfwPlatformGetTimerValue();
}
GLFWAPI uint64_t glfwGetTimerFrequency(void)
{
_GLFW_REQUIRE_INIT_OR_RETURN(0);
return _glfwPlatformGetTimerFrequency();
return monotonic();
}

235
glfw/internal.h vendored
View File

@@ -1,8 +1,8 @@
//========================================================================
// 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>
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
@@ -27,6 +27,8 @@
#pragma once
#include "../kitty/monotonic.h"
#if defined(_GLFW_USE_CONFIG_H)
#include "glfw_config.h"
#endif
@@ -60,7 +62,6 @@
#define _GLFW_MESSAGE_SIZE 1024
typedef bool GLFWbool;
typedef unsigned long long GLFWid;
typedef struct _GLFWerror _GLFWerror;
@@ -131,6 +132,7 @@ typedef enum VkStructureType
VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000,
VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000,
VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000,
VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000217000,
VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
} VkStructureType;
@@ -196,6 +198,16 @@ typedef void (APIENTRY * PFN_vkVoidFunction)(void);
#error "No supported window creation API selected"
#endif
#include "egl_context.h"
#include "osmesa_context.h"
#define remove_i_from_array(array, i, count) { \
(count)--; \
if ((i) < (count)) { \
memmove((array) + (i), (array) + (i) + 1, sizeof((array)[0]) * ((count) - (i))); \
}}
// Constructs a version number string from the public header macros
#define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r
#define _GLFW_MAKE_VERSION(m, n, r) _GLFW_CONCAT_VERSION(m, n, r)
@@ -219,12 +231,32 @@ typedef void (APIENTRY * PFN_vkVoidFunction)(void);
// Swaps the provided pointers
#define _GLFW_SWAP_POINTERS(x, y) \
{ \
void* t; \
do{ \
__typeof__(x) t; \
t = x; \
x = y; \
y = t; \
}
}while(0)
// Suppress some pedantic warnings
#ifdef __clang__
#define START_ALLOW_CASE_RANGE _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wpedantic\"")
#define END_ALLOW_CASE_RANGE _Pragma("clang diagnostic pop")
#define ALLOW_UNUSED_RESULT _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wunused-result\"")
#define END_ALLOW_UNUSED_RESULT _Pragma("clang diagnostic pop")
#else
#define START_ALLOW_CASE_RANGE _Pragma("GCC diagnostic ignored \"-Wpedantic\"")
#define END_ALLOW_CASE_RANGE _Pragma("GCC diagnostic pop")
#define ALLOW_UNUSED_RESULT _Pragma("GCC diagnostic ignored \"-Wunused-result\"")
#define END_ALLOW_UNUSED_RESULT _Pragma("GCC diagnostic pop")
#endif
// dlsym that works with -Wpedantic
#define glfw_dlsym(dest, handle, name) do {*(void **)&(dest) = _glfw_dlsym(handle, name);}while (0)
// Mark function arguments as unused
#define UNUSED __attribute__ ((unused))
// Per-thread error structure
//
@@ -241,12 +273,13 @@ struct _GLFWerror
//
struct _GLFWinitconfig
{
GLFWbool hatButtons;
GLFWbool debugKeyboard;
GLFWbool enableJoysticks;
bool hatButtons;
int angleType;
bool debugKeyboard;
bool debugRendering;
struct {
GLFWbool menubar;
GLFWbool chdir;
bool menubar;
bool chdir;
} ns;
};
@@ -261,18 +294,19 @@ struct _GLFWwndconfig
int width;
int height;
const char* title;
GLFWbool resizable;
GLFWbool visible;
GLFWbool decorated;
GLFWbool focused;
GLFWbool autoIconify;
GLFWbool floating;
GLFWbool maximized;
GLFWbool centerCursor;
GLFWbool focusOnShow;
GLFWbool scaleToMonitor;
bool resizable;
bool visible;
bool decorated;
bool focused;
bool autoIconify;
bool floating;
bool maximized;
bool centerCursor;
bool focusOnShow;
bool mousePassthrough;
bool scaleToMonitor;
struct {
GLFWbool retina;
bool retina;
char frameName[256];
} ns;
struct {
@@ -296,15 +330,15 @@ struct _GLFWctxconfig
int source;
int major;
int minor;
GLFWbool forward;
GLFWbool debug;
GLFWbool noerror;
bool forward;
bool debug;
bool noerror;
int profile;
int robustness;
int release;
_GLFWwindow* share;
struct {
GLFWbool offline;
bool offline;
} nsgl;
};
@@ -329,11 +363,11 @@ struct _GLFWfbconfig
int accumBlueBits;
int accumAlphaBits;
int auxBuffers;
GLFWbool stereo;
bool stereo;
int samples;
GLFWbool sRGB;
GLFWbool doublebuffer;
GLFWbool transparent;
bool sRGB;
bool doublebuffer;
bool transparent;
uintptr_t handle;
};
@@ -344,7 +378,7 @@ struct _GLFWcontext
int client;
int source;
int major, minor, revision;
GLFWbool forward, debug, noerror;
bool forward, debug, noerror;
int profile;
int robustness;
int release;
@@ -361,13 +395,18 @@ struct _GLFWcontext
_GLFWdestroycontextfun destroy;
// This is defined in the context API's context.h
_GLFW_PLATFORM_CONTEXT_STATE;
_GLFW_PLATFORM_CONTEXT_STATE
// This is defined in egl_context.h
_GLFW_EGL_CONTEXT_STATE;
_GLFWcontextEGL egl;
// This is defined in osmesa_context.h
_GLFW_OSMESA_CONTEXT_STATE;
_GLFWcontextOSMesa osmesa;
};
typedef struct GLFWKeyState {
uint32_t key;
char action;
} GLFWKeyState;
// Window and context structure
//
struct _GLFWwindow
@@ -375,12 +414,13 @@ struct _GLFWwindow
struct _GLFWwindow* next;
// Window settings and state
GLFWbool resizable;
GLFWbool decorated;
GLFWbool autoIconify;
GLFWbool floating;
GLFWbool focusOnShow;
GLFWbool shouldClose;
bool resizable;
bool decorated;
bool autoIconify;
bool floating;
bool focusOnShow;
bool mousePassthrough;
bool shouldClose;
void* userPointer;
GLFWid id;
GLFWvidmode videoMode;
@@ -390,15 +430,17 @@ struct _GLFWwindow
int minwidth, minheight;
int maxwidth, maxheight;
int numer, denom;
int widthincr, heightincr;
GLFWbool stickyKeys;
GLFWbool stickyMouseButtons;
GLFWbool lockKeyMods;
bool stickyKeys;
bool stickyMouseButtons;
bool lockKeyMods;
int cursorMode;
char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];
char keys[GLFW_KEY_LAST + 1];
GLFWKeyState activated_keys[16];
// Virtual cursor position when cursor is disabled
double virtualCursorPosX, virtualCursorPosY;
bool rawMouseMotion;
_GLFWcontext context;
@@ -484,7 +526,7 @@ struct _GLFWmapping
//
struct _GLFWjoystick
{
GLFWbool present;
bool present;
float* axes;
int axisCount;
unsigned char* buttons;
@@ -520,7 +562,7 @@ struct _GLFWmutex
//
struct _GLFWlibrary
{
GLFWbool initialized;
bool initialized;
struct {
_GLFWinitconfig init;
@@ -538,6 +580,7 @@ struct _GLFWlibrary
_GLFWmonitor** monitors;
int monitorCount;
bool joysticksInitialized;
_GLFWjoystick joysticks[GLFW_JOYSTICK_LAST + 1];
_GLFWmapping* mappings;
int mappingCount;
@@ -547,47 +590,45 @@ struct _GLFWlibrary
_GLFWmutex errorLock;
struct {
uint64_t offset;
// This is defined in the platform's time.h
_GLFW_PLATFORM_LIBRARY_TIMER_STATE;
} timer;
struct {
GLFWbool available;
bool available;
void* handle;
char* extensions[2];
#if !defined(_GLFW_VULKAN_STATIC)
PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
#endif
GLFWbool KHR_surface;
bool KHR_surface;
#if defined(_GLFW_WIN32)
GLFWbool KHR_win32_surface;
bool KHR_win32_surface;
#elif defined(_GLFW_COCOA)
GLFWbool MVK_macos_surface;
bool MVK_macos_surface;
bool EXT_metal_surface;
#elif defined(_GLFW_X11)
GLFWbool KHR_xlib_surface;
GLFWbool KHR_xcb_surface;
bool KHR_xlib_surface;
bool KHR_xcb_surface;
#elif defined(_GLFW_WAYLAND)
GLFWbool KHR_wayland_surface;
bool KHR_wayland_surface;
#endif
} vk;
struct {
GLFWmonitorfun monitor;
GLFWjoystickfun joystick;
GLFWapplicationclosefun application_close;
GLFWdrawtextfun draw_text;
} callbacks;
// This is defined in the window API's platform.h
_GLFW_PLATFORM_LIBRARY_WINDOW_STATE;
// This is defined in the context API's context.h
_GLFW_PLATFORM_LIBRARY_CONTEXT_STATE;
_GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
// This is defined in the platform's joystick.h
_GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE;
_GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE
// This is defined in egl_context.h
_GLFW_EGL_LIBRARY_CONTEXT_STATE;
_GLFWlibraryEGL egl;
// This is defined in osmesa_context.h
_GLFW_OSMESA_LIBRARY_CONTEXT_STATE;
_GLFWlibraryOSMesa osmesa;
};
// Global state shared between compilation units of GLFW
@@ -606,14 +647,16 @@ const char* _glfwPlatformGetVersionString(void);
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos);
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos);
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode);
void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, bool enabled);
bool _glfwPlatformRawMouseMotionSupported(void);
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
const GLFWimage* image, int xhot, int yhot, int count);
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, GLFWCursorShape shape);
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor);
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor);
const char* _glfwPlatformGetScancodeName(int scancode);
int _glfwPlatformGetKeyScancode(int key);
const char* _glfwPlatformGetNativeKeyName(int native_key);
int _glfwPlatformGetNativeKeyForKey(uint32_t key);
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor);
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos);
@@ -622,7 +665,7 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos, int *width, int *height);
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count);
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode);
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
bool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
void _glfwPlatformSetClipboardString(const char* string);
@@ -632,12 +675,11 @@ void _glfwPlatformSetPrimarySelectionString(const char* string);
const char* _glfwPlatformGetPrimarySelectionString(void);
#endif
bool _glfwPlatformInitJoysticks(void);
void _glfwPlatformTerminateJoysticks(void);
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode);
void _glfwPlatformUpdateGamepadGUID(char* guid);
uint64_t _glfwPlatformGetTimerValue(void);
uint64_t _glfwPlatformGetTimerFrequency(void);
int _glfwPlatformCreateWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
@@ -654,6 +696,7 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
int minwidth, int minheight,
int maxwidth, int maxheight);
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom);
void _glfwPlatformSetWindowSizeIncrements(_GLFWwindow* window, int widthincr, int heightincr);
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height);
void _glfwInputLiveResize(_GLFWwindow* window, bool started);
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
@@ -661,7 +704,7 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
int* right, int* bottom);
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
float* xscale, float* yscale);
double _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window);
monotonic_t _glfwPlatformGetDoubleClickInterval(_GLFWwindow* window);
void _glfwPlatformIconifyWindow(_GLFWwindow* window);
void _glfwPlatformRestoreWindow(_GLFWwindow* window);
void _glfwPlatformMaximizeWindow(_GLFWwindow* window);
@@ -682,17 +725,23 @@ int _glfwPlatformWindowMaximized(_GLFWwindow* window);
int _glfwPlatformWindowHovered(_GLFWwindow* window);
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window);
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window);
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled);
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled);
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled);
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, bool enabled);
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, bool enabled);
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, bool enabled);
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, bool enabled);
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity);
void _glfwPlatformUpdateIMEState(_GLFWwindow *w, int which, int a, int b, int c, int d);
void _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev);
void _glfwPlatformChangeCursorTheme(void);
void _glfwPlatformPollEvents(void);
void _glfwPlatformWaitEvents(void);
void _glfwPlatformWaitEventsTimeout(double timeout);
void _glfwPlatformWaitEventsTimeout(monotonic_t timeout);
void _glfwPlatformPostEmptyEvent(void);
EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs);
EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void);
EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window);
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions);
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
VkPhysicalDevice device,
@@ -702,12 +751,12 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
const VkAllocationCallbacks* allocator,
VkSurfaceKHR* surface);
GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls);
bool _glfwPlatformCreateTls(_GLFWtls* tls);
void _glfwPlatformDestroyTls(_GLFWtls* tls);
void* _glfwPlatformGetTls(_GLFWtls* tls);
void _glfwPlatformSetTls(_GLFWtls* tls, void* value);
GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex);
bool _glfwPlatformCreateMutex(_GLFWmutex* mutex);
void _glfwPlatformDestroyMutex(_GLFWmutex* mutex);
void _glfwPlatformLockMutex(_GLFWmutex* mutex);
void _glfwPlatformUnlockMutex(_GLFWmutex* mutex);
@@ -717,25 +766,25 @@ void _glfwPlatformUnlockMutex(_GLFWmutex* mutex);
////// GLFW event API //////
//////////////////////////////////////////////////////////////////////////
void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused);
void _glfwInputWindowOcclusion(_GLFWwindow* window, GLFWbool occluded);
void _glfwInputWindowFocus(_GLFWwindow* window, bool focused);
void _glfwInputWindowOcclusion(_GLFWwindow* window, bool occluded);
void _glfwInputWindowPos(_GLFWwindow* window, int xpos, int ypos);
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height);
void _glfwInputWindowContentScale(_GLFWwindow* window,
float xscale, float yscale);
void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified);
void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized);
void _glfwInputWindowIconify(_GLFWwindow* window, bool iconified);
void _glfwInputWindowMaximize(_GLFWwindow* window, bool maximized);
void _glfwInputWindowDamage(_GLFWwindow* window);
void _glfwInputWindowCloseRequest(_GLFWwindow* window);
void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor);
void _glfwInputKeyboard(_GLFWwindow* window, int key, int scancode, int action, int mods, const char* text, int state);
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset, int flags);
void _glfwInputKeyboard(_GLFWwindow *window, GLFWkeyevent *ev);
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset, int flags, int mods);
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered);
void _glfwInputDrop(_GLFWwindow* window, int count, const char** names);
void _glfwInputCursorEnter(_GLFWwindow* window, bool entered);
int _glfwInputDrop(_GLFWwindow* window, const char *mime, const char *text, size_t sz);
void _glfwInputJoystick(_GLFWjoystick* js, int event);
void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value);
void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value);
@@ -764,13 +813,10 @@ void _glfwDebug(const char* format, ...);
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions);
const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
const _GLFWfbconfig* alternatives,
unsigned int count);
GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
bool _glfwStringInExtensionString(const char* string, const char* extensions);
bool _glfwRefreshContextAttribs(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig);
GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig);
bool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig);
const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
const GLFWvidmode* desired);
@@ -790,16 +836,15 @@ void _glfwFreeJoystick(_GLFWjoystick* js);
const char* _glfwGetKeyName(int key);
void _glfwCenterCursorInContentArea(_GLFWwindow* window);
GLFWbool _glfwInitVulkan(int mode);
bool _glfwInitVulkan(int mode);
void _glfwTerminateVulkan(void);
const char* _glfwGetVulkanResultString(VkResult result);
_GLFWwindow* _glfwFocusedWindow(void);
_GLFWwindow* _glfwWindowForId(GLFWid id);
void _glfwPlatformRunMainLoop(GLFWtickcallback, void*);
void _glfwPlatformRequestTickCallback(void);
void _glfwPlatformStopMainLoop(void);
unsigned long long _glfwPlatformAddTimer(double interval, bool repeats, GLFWuserdatafun callback, void *callback_data, GLFWuserdatafun free_callback);
void _glfwPlatformUpdateTimer(unsigned long long timer_id, double interval, GLFWbool enabled);
unsigned long long _glfwPlatformAddTimer(monotonic_t interval, bool repeats, GLFWuserdatafun callback, void *callback_data, GLFWuserdatafun free_callback);
void _glfwPlatformUpdateTimer(unsigned long long timer_id, monotonic_t interval, bool enabled);
void _glfwPlatformRemoveTimer(unsigned long long timer_id);
char* _glfw_strdup(const char* source);

109
glfw/linux_desktop_settings.c vendored Normal file
View File

@@ -0,0 +1,109 @@
/*
* linux_cursor_settings.c
* Copyright (C) 2021 Kovid Goyal <kovid at kovidgoyal.net>
*
* Distributed under terms of the GPL3 license.
*/
#include "linux_desktop_settings.h"
#include <stdlib.h>
#include <strings.h>
#include <string.h>
static const char *DESKTOP_SERVICE = "org.freedesktop.portal.Desktop";
static const char *DESKTOP_PATH = "/org/freedesktop/portal/desktop";
static const char *DESKTOP_INTERFACE = "org.freedesktop.portal.Settings";
static const char *GNOME_DESKTOP_NAMESPACE = "org.gnome.desktop.interface";
static char theme_name[64] = {0};
static int theme_size = -1;
static bool gnome_cursor_theme_read = false, gnome_cursor_size_read = false;
static bool
parse_dbus_message_for_type(DBusMessage *const reply, const char *errmsg, const int type, void *value) {
DBusMessageIter iter[3];
dbus_message_iter_init(reply, &iter[0]);
#define FAIL { _glfwInputError(GLFW_PLATFORM_ERROR, "%s", errmsg); return false; }
if (dbus_message_iter_get_arg_type(&iter[0]) != DBUS_TYPE_VARIANT) FAIL;
dbus_message_iter_recurse(&iter[0], &iter[1]);
if (dbus_message_iter_get_arg_type(&iter[1]) != DBUS_TYPE_VARIANT) FAIL;
dbus_message_iter_recurse(&iter[1], &iter[2]);
if (dbus_message_iter_get_arg_type(&iter[2]) != type) FAIL;
dbus_message_iter_get_basic(&iter[2], value);
return true;
#undef FAIL
}
#define HANDLER(name) void name(DBusMessage *msg, const char* errmsg, void *data) { \
(void)data; \
if (errmsg) { \
_glfwInputError(GLFW_PLATFORM_ERROR, "%s: failed with error: %s", #name, errmsg); \
return; \
}
HANDLER(on_gnome_cursor_theme_read)
const char *name;
if (!parse_dbus_message_for_type(msg, "Failed to get cursor theme name from reply", DBUS_TYPE_STRING, &name)) return;
if (name && name[0]) {
gnome_cursor_theme_read = true;
strncpy(theme_name, name, sizeof(theme_name) - 1);
if (gnome_cursor_size_read) _glfwPlatformChangeCursorTheme();
}
}
HANDLER(on_gnome_cursor_size_read)
int32_t sz;
if (!parse_dbus_message_for_type(msg, "Failed to get cursor theme size from reply", DBUS_TYPE_INT32, &sz)) return;
gnome_cursor_size_read = true;
theme_size = sz;
if (gnome_cursor_theme_read) _glfwPlatformChangeCursorTheme();
}
#undef HANDLER
static bool
call_read(DBusConnection *session_bus, dbus_pending_callback callback, const char *namespace, const char *key) {
return glfw_dbus_call_method_with_reply(
session_bus, DESKTOP_SERVICE, DESKTOP_PATH, DESKTOP_INTERFACE, "Read", DBUS_TIMEOUT_USE_DEFAULT,
callback, NULL, DBUS_TYPE_STRING, &namespace, DBUS_TYPE_STRING, &key, DBUS_TYPE_INVALID);
}
static void
get_from_gnome(void) {
theme_size = 32;
DBusConnection *session_bus = glfw_dbus_session_bus();
if (session_bus) {
const char *theme_key = "cursor-theme";
call_read(session_bus, on_gnome_cursor_theme_read, GNOME_DESKTOP_NAMESPACE, theme_key);
const char *size_key = "cursor-size";
call_read(session_bus, on_gnome_cursor_size_read, GNOME_DESKTOP_NAMESPACE, size_key);
}
}
void
glfw_current_cursor_theme(const char **theme, int *size) {
*theme = theme_name[0] ? theme_name : NULL;
*size = (theme_size > 0 && theme_size < 2048) ? theme_size : 32;
}
static void
get_cursor_theme_from_env(void) {
const char *q = getenv("XCURSOR_THEME");
if (q) strncpy(theme_name, q, sizeof(theme_name)-1);
const char *env = getenv("XCURSOR_SIZE");
theme_size = 32;
if (env) {
const int retval = atoi(env);
if (retval > 0 && retval < 2048) theme_size = retval;
}
}
void
glfw_initialize_desktop_settings(void) {
get_cursor_theme_from_env();
const char *desktop = getenv("XDG_CURRENT_DESKTOP");
bool is_gnome = desktop && strncasecmp(desktop, "GNOME", sizeof("GNOME") - 1) == 0;
if (is_gnome) get_from_gnome();
}

14
glfw/linux_desktop_settings.h vendored Normal file
View File

@@ -0,0 +1,14 @@
/*
* Copyright (C) 2021 Kovid Goyal <kovid at kovidgoyal.net>
*
* Distributed under terms of the GPL3 license.
*/
#pragma once
#include "dbus_glfw.h"
#include "internal.h"
void glfw_initialize_desktop_settings(void);
void glfw_current_cursor_theme(const char **theme, int *size);

186
glfw/linux_joystick.c vendored
View File

@@ -1,8 +1,8 @@
//========================================================================
// GLFW 3.3 Linux - www.glfw.org
// GLFW 3.4 Linux - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
@@ -24,6 +24,8 @@
// distribution.
//
//========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h"
@@ -104,9 +106,7 @@ static void handleAbsEvent(_GLFWjoystick* js, int code, int value)
//
static void pollAbsState(_GLFWjoystick* js)
{
int code;
for (code = 0; code < ABS_CNT; code++)
for (int code = 0; code < ABS_CNT; code++)
{
if (js->linjs.absMap[code] < 0)
continue;
@@ -124,53 +124,52 @@ static void pollAbsState(_GLFWjoystick* js)
// Attempt to open the specified joystick device
//
static GLFWbool openJoystickDevice(const char* path)
static bool openJoystickDevice(const char* path)
{
int jid, code;
char name[256] = "";
char guid[33] = "";
char evBits[(EV_CNT + 7) / 8] = {0};
char keyBits[(KEY_CNT + 7) / 8] = {0};
char absBits[(ABS_CNT + 7) / 8] = {0};
int axisCount = 0, buttonCount = 0, hatCount = 0;
struct input_id id;
_GLFWjoystickLinux linjs = {0};
_GLFWjoystick* js = NULL;
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (!_glfw.joysticks[jid].present)
continue;
if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
return GLFW_FALSE;
return false;
}
_GLFWjoystickLinux linjs = {0};
linjs.fd = open(path, O_RDONLY | O_NONBLOCK);
if (linjs.fd == -1)
return GLFW_FALSE;
return false;
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)
char evBits[(EV_CNT + 7) / 8] = {0};
char keyBits[(KEY_CNT + 7) / 8] = {0};
char absBits[(ABS_CNT + 7) / 8] = {0};
struct input_id id;
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",
strerror(errno));
close(linjs.fd);
return GLFW_FALSE;
return false;
}
// Ensure this device supports the events expected of a joystick
if (!isBitSet(EV_KEY, evBits) || !isBitSet(EV_ABS, evBits))
{
close(linjs.fd);
return GLFW_FALSE;
return false;
}
if (ioctl(linjs.fd, EVIOCGNAME(sizeof(name)), name) < 0)
char name[256] = "";
if (ioctl(linjs.fd, (int32_t)EVIOCGNAME(sizeof(name)), name) < 0)
strncpy(name, "Unknown", sizeof(name));
char guid[33] = "";
// Generate a joystick GUID that matches the SDL 2.0.5+ one
if (id.vendor && id.product && id.version)
{
@@ -189,7 +188,9 @@ static GLFWbool openJoystickDevice(const char* path)
name[8], name[9], name[10]);
}
for (code = BTN_MISC; code < KEY_CNT; code++)
int axisCount = 0, buttonCount = 0, hatCount = 0;
for (int code = BTN_MISC; code < KEY_CNT; code++)
{
if (!isBitSet(code, keyBits))
continue;
@@ -198,7 +199,7 @@ static GLFWbool openJoystickDevice(const char* path)
buttonCount++;
}
for (code = 0; code < ABS_CNT; code++)
for (int code = 0; code < ABS_CNT; code++)
{
linjs.absMap[code] = -1;
if (!isBitSet(code, absBits))
@@ -221,11 +222,12 @@ static GLFWbool openJoystickDevice(const char* path)
}
}
js = _glfwAllocJoystick(name, guid, axisCount, buttonCount, hatCount);
_GLFWjoystick* js =
_glfwAllocJoystick(name, guid, axisCount, buttonCount, hatCount);
if (!js)
{
close(linjs.fd);
return GLFW_FALSE;
return false;
}
strncpy(linjs.path, path, sizeof(linjs.path) - 1);
@@ -234,7 +236,7 @@ static GLFWbool openJoystickDevice(const char* path)
pollAbsState(js);
_glfwInputJoystick(js, GLFW_CONNECTED);
return GLFW_TRUE;
return true;
}
#undef isBitSet
@@ -262,12 +264,51 @@ static int compareJoysticks(const void* fp, const void* sp)
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
// Initialize joystick interface
//
GLFWbool _glfwInitJoysticksLinux(void)
void _glfwDetectJoystickConnectionLinux(void)
{
if (_glfw.linjs.inotify <= 0)
return;
ssize_t offset = 0;
char buffer[16384];
const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer));
while (size > offset)
{
regmatch_t match;
const struct inotify_event* e = (struct inotify_event*) (buffer + offset);
offset += sizeof(struct inotify_event) + e->len;
if (regexec(&_glfw.linjs.regex, e->name, 1, &match, 0) != 0)
continue;
char path[PATH_MAX];
snprintf(path, sizeof(path), "/dev/input/%s", e->name);
if (e->mask & (IN_CREATE | IN_ATTRIB))
openJoystickDevice(path);
else if (e->mask & IN_DELETE)
{
for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
{
closeJoystick(_glfw.joysticks + jid);
break;
}
}
}
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
bool _glfwPlatformInitJoysticks(void)
{
DIR* dir;
int count = 0;
const char* dirname = "/dev/input";
_glfw.linjs.inotify = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
@@ -286,10 +327,12 @@ GLFWbool _glfwInitJoysticksLinux(void)
if (regcomp(&_glfw.linjs.regex, "^event[0-9]\\+$", 0) != 0)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Linux: Failed to compile regex");
return GLFW_FALSE;
return false;
}
dir = opendir(dirname);
int count = 0;
DIR* dir = opendir(dirname);
if (dir)
{
struct dirent* entry;
@@ -314,13 +357,11 @@ GLFWbool _glfwInitJoysticksLinux(void)
// Continue with no joysticks if enumeration fails
qsort(_glfw.joysticks, count, sizeof(_GLFWjoystick), compareJoysticks);
return GLFW_TRUE;
qsort(_glfw.joysticks, count, sizeof(_glfw.joysticks[0]), compareJoysticks);
return true;
}
// Close all opened joystick handles
//
void _glfwTerminateJoysticksLinux(void)
void _glfwPlatformTerminateJoysticks(void)
{
int jid;
@@ -331,64 +372,17 @@ void _glfwTerminateJoysticksLinux(void)
closeJoystick(js);
}
regfree(&_glfw.linjs.regex);
if (_glfw.linjs.inotify > 0)
{
if (_glfw.linjs.watch > 0)
inotify_rm_watch(_glfw.linjs.inotify, _glfw.linjs.watch);
close(_glfw.linjs.inotify);
regfree(&_glfw.linjs.regex);
}
}
void _glfwDetectJoystickConnectionLinux(void)
{
ssize_t offset = 0;
char buffer[16384];
if (_glfw.linjs.inotify <= 0)
return;
const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer));
while (size > offset)
{
regmatch_t match;
const struct inotify_event* e = (struct inotify_event*) (buffer + offset);
offset += sizeof(struct inotify_event) + e->len;
if (regexec(&_glfw.linjs.regex, e->name, 1, &match, 0) != 0)
continue;
char path[PATH_MAX];
snprintf(path, sizeof(path), "/dev/input/%s", e->name);
if (e->mask & (IN_CREATE | IN_ATTRIB))
openJoystickDevice(path);
else if (e->mask & IN_DELETE)
{
int jid;
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
{
if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
{
closeJoystick(_glfw.joysticks + jid);
break;
}
}
}
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode UNUSED)
{
// Read all queued events (non-blocking)
for (;;)
@@ -408,10 +402,10 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
if (e.type == EV_SYN)
{
if (e.code == SYN_DROPPED)
_glfw.linjs.dropped = GLFW_TRUE;
_glfw.linjs.dropped = true;
else if (e.code == SYN_REPORT)
{
_glfw.linjs.dropped = GLFW_FALSE;
_glfw.linjs.dropped = false;
pollAbsState(js);
}
}
@@ -428,6 +422,6 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
return js->present;
}
void _glfwPlatformUpdateGamepadGUID(char* guid)
void _glfwPlatformUpdateGamepadGUID(char* guid UNUSED)
{
}

10
glfw/linux_joystick.h vendored
View File

@@ -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>
//
@@ -29,7 +29,7 @@
#include <regex.h>
#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickLinux linjs
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux linjs;
#define _GLFW_PLATFORM_MAPPING_NAME "Linux"
@@ -52,11 +52,7 @@ typedef struct _GLFWlibraryLinux
int inotify;
int watch;
regex_t regex;
GLFWbool dropped;
bool dropped;
} _GLFWlibraryLinux;
GLFWbool _glfwInitJoysticksLinux(void);
void _glfwTerminateJoysticksLinux(void);
void _glfwDetectJoystickConnectionLinux(void);

3
glfw/linux_notify.c vendored
View File

@@ -43,8 +43,7 @@ notification_created(DBusMessage *msg, const char* errmsg, void *data) {
}
static DBusHandlerResult
message_handler(DBusConnection *conn, DBusMessage *msg, void *user_data) {
(void)(user_data);
message_handler(DBusConnection *conn UNUSED, DBusMessage *msg, void *user_data UNUSED) {
/* printf("session_bus message_handler invoked interface: %s member: %s\n", dbus_message_get_interface(msg), dbus_message_get_member(msg)); */
if (dbus_message_is_signal(msg, NOTIFICATIONS_IFACE, "ActionInvoked")) {
uint32_t notification_id;

22
glfw/main_loop.h vendored
View File

@@ -7,33 +7,37 @@
#pragma once
#include "internal.h"
#include "../kitty/monotonic.h"
#ifndef GLFW_LOOP_BACKEND
#define GLFW_LOOP_BACKEND x11
#endif
static GLFWbool keep_going = GLFW_FALSE;
static bool keep_going = false;
void _glfwPlatformRequestTickCallback() {
}
void _glfwPlatformStopMainLoop(void) {
if (keep_going) {
keep_going = GLFW_FALSE;
keep_going = false;
_glfwPlatformPostEmptyEvent();
}
}
void _glfwPlatformRunMainLoop(GLFWtickcallback tick_callback, void* data) {
keep_going = GLFW_TRUE;
keep_going = 1;
EventLoopData *eld = &_glfw.GLFW_LOOP_BACKEND.eventLoopData;
while(keep_going) {
_glfwPlatformWaitEvents();
EVDBG("loop tick");
tick_callback(data);
EVDBG("--------- loop tick, wakeups_happened: %d ----------", eld->wakeup_data_read);
if (eld->wakeup_data_read) {
eld->wakeup_data_read = false;
tick_callback(data);
}
}
EVDBG("main loop exiting");
}
unsigned long long _glfwPlatformAddTimer(double interval, bool repeats, GLFWuserdatafreefun callback, void *callback_data, GLFWuserdatafreefun free_callback) {
unsigned long long _glfwPlatformAddTimer(monotonic_t interval, bool repeats, GLFWuserdatafreefun callback, void *callback_data, GLFWuserdatafreefun free_callback) {
return addTimer(&_glfw.GLFW_LOOP_BACKEND.eventLoopData, "user timer", interval, 1, repeats, callback, callback_data, free_callback);
}
@@ -41,7 +45,7 @@ void _glfwPlatformRemoveTimer(unsigned long long timer_id) {
removeTimer(&_glfw.GLFW_LOOP_BACKEND.eventLoopData, timer_id);
}
void _glfwPlatformUpdateTimer(unsigned long long timer_id, double interval, GLFWbool enabled) {
void _glfwPlatformUpdateTimer(unsigned long long timer_id, monotonic_t interval, bool enabled) {
changeTimerInterval(&_glfw.GLFW_LOOP_BACKEND.eventLoopData, timer_id, interval);
toggleTimer(&_glfw.GLFW_LOOP_BACKEND.eventLoopData, timer_id, enabled);
}

4
glfw/mappings.h vendored
View File

@@ -1,7 +1,7 @@
//========================================================================
// GLFW 3.3 - www.glfw.org
// GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages

Some files were not shown because too many files have changed in this diff Show More