mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Get rid of glfw_constants
This commit is contained in:
@@ -1,260 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
|
||||||
|
|
||||||
# --- Input handling definitions ----------------------------------------------
|
|
||||||
GLFW_RELEASE = 0
|
|
||||||
GLFW_PRESS = 1
|
|
||||||
GLFW_REPEAT = 2
|
|
||||||
|
|
||||||
# --- Keys --------------------------------------------------------------------
|
|
||||||
|
|
||||||
# --- The unknown key ---------------------------------------------------------
|
|
||||||
GLFW_KEY_UNKNOWN = -1
|
|
||||||
|
|
||||||
# --- Printable keys ----------------------------------------------------------
|
|
||||||
GLFW_KEY_SPACE = 32
|
|
||||||
GLFW_KEY_APOSTROPHE = 39 # ''
|
|
||||||
GLFW_KEY_COMMA = 44 # ,
|
|
||||||
GLFW_KEY_MINUS = 45 # -
|
|
||||||
GLFW_KEY_PERIOD = 46 # .
|
|
||||||
GLFW_KEY_SLASH = 47 # /
|
|
||||||
GLFW_KEY_0 = 48
|
|
||||||
GLFW_KEY_1 = 49
|
|
||||||
GLFW_KEY_2 = 50
|
|
||||||
GLFW_KEY_3 = 51
|
|
||||||
GLFW_KEY_4 = 52
|
|
||||||
GLFW_KEY_5 = 53
|
|
||||||
GLFW_KEY_6 = 54
|
|
||||||
GLFW_KEY_7 = 55
|
|
||||||
GLFW_KEY_8 = 56
|
|
||||||
GLFW_KEY_9 = 57
|
|
||||||
GLFW_KEY_SEMICOLON = 59 # ;
|
|
||||||
GLFW_KEY_EQUAL = 61 # =
|
|
||||||
GLFW_KEY_A = 65
|
|
||||||
GLFW_KEY_B = 66
|
|
||||||
GLFW_KEY_C = 67
|
|
||||||
GLFW_KEY_D = 68
|
|
||||||
GLFW_KEY_E = 69
|
|
||||||
GLFW_KEY_F = 70
|
|
||||||
GLFW_KEY_G = 71
|
|
||||||
GLFW_KEY_H = 72
|
|
||||||
GLFW_KEY_I = 73
|
|
||||||
GLFW_KEY_J = 74
|
|
||||||
GLFW_KEY_K = 75
|
|
||||||
GLFW_KEY_L = 76
|
|
||||||
GLFW_KEY_M = 77
|
|
||||||
GLFW_KEY_N = 78
|
|
||||||
GLFW_KEY_O = 79
|
|
||||||
GLFW_KEY_P = 80
|
|
||||||
GLFW_KEY_Q = 81
|
|
||||||
GLFW_KEY_R = 82
|
|
||||||
GLFW_KEY_S = 83
|
|
||||||
GLFW_KEY_T = 84
|
|
||||||
GLFW_KEY_U = 85
|
|
||||||
GLFW_KEY_V = 86
|
|
||||||
GLFW_KEY_W = 87
|
|
||||||
GLFW_KEY_X = 88
|
|
||||||
GLFW_KEY_Y = 89
|
|
||||||
GLFW_KEY_Z = 90
|
|
||||||
GLFW_KEY_LEFT_BRACKET = 91 # [
|
|
||||||
GLFW_KEY_BACKSLASH = 92 # \
|
|
||||||
GLFW_KEY_RIGHT_BRACKET = 93 # ]
|
|
||||||
GLFW_KEY_GRAVE_ACCENT = 96 # `
|
|
||||||
GLFW_KEY_WORLD_1 = 161 # non-US #1
|
|
||||||
GLFW_KEY_WORLD_2 = 162 # non-US #2
|
|
||||||
|
|
||||||
# --- Function keys -----------------------------------------------------------
|
|
||||||
GLFW_KEY_ESCAPE = 256
|
|
||||||
GLFW_KEY_ENTER = 257
|
|
||||||
GLFW_KEY_TAB = 258
|
|
||||||
GLFW_KEY_BACKSPACE = 259
|
|
||||||
GLFW_KEY_INSERT = 260
|
|
||||||
GLFW_KEY_DELETE = 261
|
|
||||||
GLFW_KEY_RIGHT = 262
|
|
||||||
GLFW_KEY_LEFT = 263
|
|
||||||
GLFW_KEY_DOWN = 264
|
|
||||||
GLFW_KEY_UP = 265
|
|
||||||
GLFW_KEY_PAGE_UP = 266
|
|
||||||
GLFW_KEY_PAGE_DOWN = 267
|
|
||||||
GLFW_KEY_HOME = 268
|
|
||||||
GLFW_KEY_END = 269
|
|
||||||
GLFW_KEY_CAPS_LOCK = 280
|
|
||||||
GLFW_KEY_SCROLL_LOCK = 281
|
|
||||||
GLFW_KEY_NUM_LOCK = 282
|
|
||||||
GLFW_KEY_PRINT_SCREEN = 283
|
|
||||||
GLFW_KEY_PAUSE = 284
|
|
||||||
GLFW_KEY_F1 = 290
|
|
||||||
GLFW_KEY_F2 = 291
|
|
||||||
GLFW_KEY_F3 = 292
|
|
||||||
GLFW_KEY_F4 = 293
|
|
||||||
GLFW_KEY_F5 = 294
|
|
||||||
GLFW_KEY_F6 = 295
|
|
||||||
GLFW_KEY_F7 = 296
|
|
||||||
GLFW_KEY_F8 = 297
|
|
||||||
GLFW_KEY_F9 = 298
|
|
||||||
GLFW_KEY_F10 = 299
|
|
||||||
GLFW_KEY_F11 = 300
|
|
||||||
GLFW_KEY_F12 = 301
|
|
||||||
GLFW_KEY_F13 = 302
|
|
||||||
GLFW_KEY_F14 = 303
|
|
||||||
GLFW_KEY_F15 = 304
|
|
||||||
GLFW_KEY_F16 = 305
|
|
||||||
GLFW_KEY_F17 = 306
|
|
||||||
GLFW_KEY_F18 = 307
|
|
||||||
GLFW_KEY_F19 = 308
|
|
||||||
GLFW_KEY_F20 = 309
|
|
||||||
GLFW_KEY_F21 = 310
|
|
||||||
GLFW_KEY_F22 = 311
|
|
||||||
GLFW_KEY_F23 = 312
|
|
||||||
GLFW_KEY_F24 = 313
|
|
||||||
GLFW_KEY_F25 = 314
|
|
||||||
GLFW_KEY_KP_0 = 320
|
|
||||||
GLFW_KEY_KP_1 = 321
|
|
||||||
GLFW_KEY_KP_2 = 322
|
|
||||||
GLFW_KEY_KP_3 = 323
|
|
||||||
GLFW_KEY_KP_4 = 324
|
|
||||||
GLFW_KEY_KP_5 = 325
|
|
||||||
GLFW_KEY_KP_6 = 326
|
|
||||||
GLFW_KEY_KP_7 = 327
|
|
||||||
GLFW_KEY_KP_8 = 328
|
|
||||||
GLFW_KEY_KP_9 = 329
|
|
||||||
GLFW_KEY_KP_DECIMAL = 330
|
|
||||||
GLFW_KEY_KP_DIVIDE = 331
|
|
||||||
GLFW_KEY_KP_MULTIPLY = 332
|
|
||||||
GLFW_KEY_KP_SUBTRACT = 333
|
|
||||||
GLFW_KEY_KP_ADD = 334
|
|
||||||
GLFW_KEY_KP_ENTER = 335
|
|
||||||
GLFW_KEY_KP_EQUAL = 336
|
|
||||||
GLFW_KEY_LEFT_SHIFT = 340
|
|
||||||
GLFW_KEY_LEFT_CONTROL = 341
|
|
||||||
GLFW_KEY_LEFT_ALT = 342
|
|
||||||
GLFW_KEY_LEFT_SUPER = 343
|
|
||||||
GLFW_KEY_RIGHT_SHIFT = 344
|
|
||||||
GLFW_KEY_RIGHT_CONTROL = 345
|
|
||||||
GLFW_KEY_RIGHT_ALT = 346
|
|
||||||
GLFW_KEY_RIGHT_SUPER = 347
|
|
||||||
GLFW_KEY_MENU = 348
|
|
||||||
GLFW_KEY_LAST = GLFW_KEY_MENU
|
|
||||||
MODIFIER_KEYS = (
|
|
||||||
GLFW_KEY_LEFT_SHIFT, GLFW_KEY_RIGHT_SHIFT, GLFW_KEY_LEFT_ALT,
|
|
||||||
GLFW_KEY_RIGHT_ALT, GLFW_KEY_LEFT_CONTROL, GLFW_KEY_RIGHT_CONTROL,
|
|
||||||
GLFW_KEY_LEFT_SUPER, GLFW_KEY_RIGHT_SUPER)
|
|
||||||
|
|
||||||
|
|
||||||
# --- Modifiers ---------------------------------------------------------------
|
|
||||||
GLFW_MOD_SHIFT = 0x0001
|
|
||||||
GLFW_MOD_CONTROL = 0x0002
|
|
||||||
GLFW_MOD_ALT = 0x0004
|
|
||||||
GLFW_MOD_SUPER = 0x0008
|
|
||||||
|
|
||||||
# --- Mouse -------------------------------------------------------------------
|
|
||||||
GLFW_MOUSE_BUTTON_1 = 0
|
|
||||||
GLFW_MOUSE_BUTTON_2 = 1
|
|
||||||
GLFW_MOUSE_BUTTON_3 = 2
|
|
||||||
GLFW_MOUSE_BUTTON_4 = 3
|
|
||||||
GLFW_MOUSE_BUTTON_5 = 4
|
|
||||||
GLFW_MOUSE_BUTTON_6 = 5
|
|
||||||
GLFW_MOUSE_BUTTON_7 = 6
|
|
||||||
GLFW_MOUSE_BUTTON_8 = 7
|
|
||||||
GLFW_MOUSE_BUTTON_LAST = GLFW_MOUSE_BUTTON_8
|
|
||||||
GLFW_MOUSE_BUTTON_LEFT = GLFW_MOUSE_BUTTON_1
|
|
||||||
GLFW_MOUSE_BUTTON_RIGHT = GLFW_MOUSE_BUTTON_2
|
|
||||||
GLFW_MOUSE_BUTTON_MIDDLE = GLFW_MOUSE_BUTTON_3
|
|
||||||
|
|
||||||
|
|
||||||
# --- Joystick ----------------------------------------------------------------
|
|
||||||
GLFW_JOYSTICK_1 = 0
|
|
||||||
GLFW_JOYSTICK_2 = 1
|
|
||||||
GLFW_JOYSTICK_3 = 2
|
|
||||||
GLFW_JOYSTICK_4 = 3
|
|
||||||
GLFW_JOYSTICK_5 = 4
|
|
||||||
GLFW_JOYSTICK_6 = 5
|
|
||||||
GLFW_JOYSTICK_7 = 6
|
|
||||||
GLFW_JOYSTICK_8 = 7
|
|
||||||
GLFW_JOYSTICK_9 = 8
|
|
||||||
GLFW_JOYSTICK_10 = 9
|
|
||||||
GLFW_JOYSTICK_11 = 10
|
|
||||||
GLFW_JOYSTICK_12 = 11
|
|
||||||
GLFW_JOYSTICK_13 = 12
|
|
||||||
GLFW_JOYSTICK_14 = 13
|
|
||||||
GLFW_JOYSTICK_15 = 14
|
|
||||||
GLFW_JOYSTICK_16 = 15
|
|
||||||
GLFW_JOYSTICK_LAST = GLFW_JOYSTICK_16
|
|
||||||
|
|
||||||
|
|
||||||
# --- Error codes -------------------------------------------------------------
|
|
||||||
GLFW_NOT_INITIALIZED = 0x00010001
|
|
||||||
GLFW_NO_CURRENT_CONTEXT = 0x00010002
|
|
||||||
GLFW_INVALID_ENUM = 0x00010003
|
|
||||||
GLFW_INVALID_VALUE = 0x00010004
|
|
||||||
GLFW_OUT_OF_MEMORY = 0x00010005
|
|
||||||
GLFW_API_UNAVAILABLE = 0x00010006
|
|
||||||
GLFW_VERSION_UNAVAILABLE = 0x00010007
|
|
||||||
GLFW_PLATFORM_ERROR = 0x00010008
|
|
||||||
GLFW_FORMAT_UNAVAILABLE = 0x00010009
|
|
||||||
|
|
||||||
# ---
|
|
||||||
GLFW_FOCUSED = 0x00020001
|
|
||||||
GLFW_ICONIFIED = 0x00020002
|
|
||||||
GLFW_RESIZABLE = 0x00020003
|
|
||||||
GLFW_VISIBLE = 0x00020004
|
|
||||||
GLFW_DECORATED = 0x00020005
|
|
||||||
GLFW_AUTO_ICONIFY = 0x00020006
|
|
||||||
GLFW_FLOATING = 0x00020007
|
|
||||||
|
|
||||||
# ---
|
|
||||||
GLFW_RED_BITS = 0x00021001
|
|
||||||
GLFW_GREEN_BITS = 0x00021002
|
|
||||||
GLFW_BLUE_BITS = 0x00021003
|
|
||||||
GLFW_ALPHA_BITS = 0x00021004
|
|
||||||
GLFW_DEPTH_BITS = 0x00021005
|
|
||||||
GLFW_STENCIL_BITS = 0x00021006
|
|
||||||
GLFW_ACCUM_RED_BITS = 0x00021007
|
|
||||||
GLFW_ACCUM_GREEN_BITS = 0x00021008
|
|
||||||
GLFW_ACCUM_BLUE_BITS = 0x00021009
|
|
||||||
GLFW_ACCUM_ALPHA_BITS = 0x0002100A
|
|
||||||
GLFW_AUX_BUFFERS = 0x0002100B
|
|
||||||
GLFW_STEREO = 0x0002100C
|
|
||||||
GLFW_SAMPLES = 0x0002100D
|
|
||||||
GLFW_SRGB_CAPABLE = 0x0002100E
|
|
||||||
GLFW_REFRESH_RATE = 0x0002100F
|
|
||||||
GLFW_DOUBLEBUFFER = 0x00021010
|
|
||||||
|
|
||||||
# ---
|
|
||||||
GLFW_CLIENT_API = 0x00022001
|
|
||||||
GLFW_CONTEXT_VERSION_MAJOR = 0x00022002
|
|
||||||
GLFW_CONTEXT_VERSION_MINOR = 0x00022003
|
|
||||||
GLFW_CONTEXT_REVISION = 0x00022004
|
|
||||||
GLFW_CONTEXT_ROBUSTNESS = 0x00022005
|
|
||||||
GLFW_OPENGL_FORWARD_COMPAT = 0x00022006
|
|
||||||
GLFW_OPENGL_DEBUG_CONTEXT = 0x00022007
|
|
||||||
GLFW_OPENGL_PROFILE = 0x00022008
|
|
||||||
|
|
||||||
# ---
|
|
||||||
GLFW_OPENGL_API = 0x00030001
|
|
||||||
GLFW_OPENGL_ES_API = 0x00030002
|
|
||||||
|
|
||||||
# ---
|
|
||||||
GLFW_NO_ROBUSTNESS = 0
|
|
||||||
GLFW_NO_RESET_NOTIFICATION = 0x00031001
|
|
||||||
GLFW_LOSE_CONTEXT_ON_RESET = 0x00031002
|
|
||||||
|
|
||||||
# ---
|
|
||||||
GLFW_OPENGL_ANY_PROFILE = 0
|
|
||||||
GLFW_OPENGL_CORE_PROFILE = 0x00032001
|
|
||||||
GLFW_OPENGL_COMPAT_PROFILE = 0x00032002
|
|
||||||
|
|
||||||
# ---
|
|
||||||
GLFW_CURSOR = 0x00033001
|
|
||||||
GLFW_STICKY_KEYS = 0x00033002
|
|
||||||
GLFW_STICKY_MOUSE_BUTTONS = 0x00033003
|
|
||||||
|
|
||||||
# ---
|
|
||||||
GLFW_CURSOR_NORMAL = 0x00034001
|
|
||||||
GLFW_CURSOR_HIDDEN = 0x00034002
|
|
||||||
GLFW_CURSOR_DISABLED = 0x00034003
|
|
||||||
|
|
||||||
# ---
|
|
||||||
GLFW_CONNECTED = 0x00040001
|
|
||||||
GLFW_DISCONNECTED = 0x00040002
|
|
||||||
@@ -7,9 +7,10 @@ import sys
|
|||||||
import os
|
import os
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
import glfw_constants as glfw
|
from .fast_data_types import (
|
||||||
|
CURSOR_BLOCK, CURSOR_BEAM, CURSOR_UNDERLINE
|
||||||
from .fast_data_types import CURSOR_BLOCK, CURSOR_BEAM, CURSOR_UNDERLINE
|
)
|
||||||
|
import kitty.fast_data_types as defines
|
||||||
from .utils import to_color
|
from .utils import to_color
|
||||||
|
|
||||||
key_pat = re.compile(r'([a-zA-Z][a-zA-Z0-9_-]*)\s+(.+)$')
|
key_pat = re.compile(r'([a-zA-Z][a-zA-Z0-9_-]*)\s+(.+)$')
|
||||||
@@ -67,12 +68,12 @@ def parse_key(val, keymap):
|
|||||||
mods = 0
|
mods = 0
|
||||||
for m in parts[:-1]:
|
for m in parts[:-1]:
|
||||||
try:
|
try:
|
||||||
mods |= getattr(glfw, 'GLFW_MOD_' + map_mod(m.upper()))
|
mods |= getattr(defines, 'GLFW_MOD_' + map_mod(m.upper()))
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
print('Shortcut: {} has an unknown modifier, ignoring'.format(val), file=sys.stderr)
|
print('Shortcut: {} has an unknown modifier, ignoring'.format(val), file=sys.stderr)
|
||||||
return
|
return
|
||||||
|
|
||||||
key = getattr(glfw, 'GLFW_KEY_' + parts[-1].upper(), None)
|
key = getattr(defines, 'GLFW_KEY_' + parts[-1].upper(), None)
|
||||||
if key is None:
|
if key is None:
|
||||||
print('Shortcut: {} has an unknown key, ignoring'.format(val), file=sys.stderr)
|
print('Shortcut: {} has an unknown key, ignoring'.format(val), file=sys.stderr)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ import pwd
|
|||||||
import ctypes
|
import ctypes
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
from .fast_data_types import (
|
||||||
|
GLFW_KEY_LEFT_SHIFT, GLFW_KEY_RIGHT_SHIFT, GLFW_KEY_LEFT_ALT,
|
||||||
|
GLFW_KEY_RIGHT_ALT, GLFW_KEY_LEFT_CONTROL, GLFW_KEY_RIGHT_CONTROL,
|
||||||
|
GLFW_KEY_LEFT_SUPER, GLFW_KEY_RIGHT_SUPER)
|
||||||
|
|
||||||
appname = 'kitty'
|
appname = 'kitty'
|
||||||
version = (0, 1, 0)
|
version = (0, 1, 0)
|
||||||
str_version = '.'.join(map(str, version))
|
str_version = '.'.join(map(str, version))
|
||||||
@@ -73,3 +78,8 @@ if ctypes.sizeof(GLfloat) != 4:
|
|||||||
raise RuntimeError('float size is not 4')
|
raise RuntimeError('float size is not 4')
|
||||||
if ctypes.sizeof(GLint) != 4:
|
if ctypes.sizeof(GLint) != 4:
|
||||||
raise RuntimeError('int size is not 4')
|
raise RuntimeError('int size is not 4')
|
||||||
|
|
||||||
|
MODIFIER_KEYS = (
|
||||||
|
GLFW_KEY_LEFT_SHIFT, GLFW_KEY_RIGHT_SHIFT, GLFW_KEY_LEFT_ALT,
|
||||||
|
GLFW_KEY_RIGHT_ALT, GLFW_KEY_LEFT_CONTROL, GLFW_KEY_RIGHT_CONTROL,
|
||||||
|
GLFW_KEY_LEFT_SUPER, GLFW_KEY_RIGHT_SUPER)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "data-types.h"
|
#include "data-types.h"
|
||||||
|
#include "glfw.h"
|
||||||
#include "gl.h"
|
#include "gl.h"
|
||||||
#include "modes.h"
|
#include "modes.h"
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ PyInit_fast_data_types(void) {
|
|||||||
if (!init_freetype_library(m)) return NULL;
|
if (!init_freetype_library(m)) return NULL;
|
||||||
if (!init_Face(m)) return NULL;
|
if (!init_Face(m)) return NULL;
|
||||||
if (!add_module_gl_constants(m)) return NULL;
|
if (!add_module_gl_constants(m)) return NULL;
|
||||||
|
if (!init_glfw(m)) return NULL;
|
||||||
PyModule_AddIntConstant(m, "BOLD", BOLD_SHIFT);
|
PyModule_AddIntConstant(m, "BOLD", BOLD_SHIFT);
|
||||||
PyModule_AddIntConstant(m, "ITALIC", ITALIC_SHIFT);
|
PyModule_AddIntConstant(m, "ITALIC", ITALIC_SHIFT);
|
||||||
PyModule_AddIntConstant(m, "REVERSE", REVERSE_SHIFT);
|
PyModule_AddIntConstant(m, "REVERSE", REVERSE_SHIFT);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
import glfw
|
import glfw
|
||||||
import glfw_constants
|
|
||||||
import sys
|
import sys
|
||||||
import ctypes
|
import ctypes
|
||||||
|
|
||||||
@@ -15,7 +14,9 @@ from kitty.fast_data_types import (
|
|||||||
glUniform2f, glUniform4f, glUniform2ui, glUniform1i, glewInit, glGetString,
|
glUniform2f, glUniform4f, glUniform2ui, glUniform1i, glewInit, glGetString,
|
||||||
GL_VERSION as GL_VERSION_C, GL_VENDOR, GL_SHADING_LANGUAGE_VERSION, GL_RENDERER,
|
GL_VERSION as GL_VERSION_C, GL_VENDOR, GL_SHADING_LANGUAGE_VERSION, GL_RENDERER,
|
||||||
glClear, GL_COLOR_BUFFER_BIT, GL_TRIANGLE_FAN, glDrawArraysInstanced,
|
glClear, GL_COLOR_BUFFER_BIT, GL_TRIANGLE_FAN, glDrawArraysInstanced,
|
||||||
Cursor, LineBuf, ColorProfile, DATA_CELL_SIZE
|
Cursor, LineBuf, ColorProfile, DATA_CELL_SIZE, GLFW_CONTEXT_VERSION_MAJOR,
|
||||||
|
GLFW_CONTEXT_VERSION_MINOR, GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE,
|
||||||
|
GLFW_OPENGL_FORWARD_COMPAT
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -109,11 +110,11 @@ def _main():
|
|||||||
# These Window hints are used to specify
|
# These Window hints are used to specify
|
||||||
# which opengl version to use and other details
|
# which opengl version to use and other details
|
||||||
# for the opengl context that will be created
|
# for the opengl context that will be created
|
||||||
glfw.glfwWindowHint(glfw_constants.GLFW_CONTEXT_VERSION_MAJOR, GL_VERSION[0])
|
glfw.glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, GL_VERSION[0])
|
||||||
glfw.glfwWindowHint(glfw_constants.GLFW_CONTEXT_VERSION_MINOR, GL_VERSION[1])
|
glfw.glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, GL_VERSION[1])
|
||||||
glfw.glfwWindowHint(glfw_constants.GLFW_OPENGL_PROFILE,
|
glfw.glfwWindowHint(GLFW_OPENGL_PROFILE,
|
||||||
glfw_constants.GLFW_OPENGL_CORE_PROFILE)
|
GLFW_OPENGL_CORE_PROFILE)
|
||||||
glfw.glfwWindowHint(glfw_constants.GLFW_OPENGL_FORWARD_COMPAT, True)
|
glfw.glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, True)
|
||||||
|
|
||||||
window = glfw.glfwCreateWindow(
|
window = glfw.glfwCreateWindow(
|
||||||
1024, 1024, "Trying this crap".encode('utf-8'), None, None)
|
1024, 1024, "Trying this crap".encode('utf-8'), None, None)
|
||||||
|
|||||||
268
kitty/glfw.c
Normal file
268
kitty/glfw.c
Normal file
@@ -0,0 +1,268 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
*
|
||||||
|
* Distributed under terms of the GPL3 license.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "data-types.h"
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
bool
|
||||||
|
init_glfw(PyObject *m) {
|
||||||
|
#define ADDC(n) if(PyModule_AddIntConstant(m, #n, n) != 0) return false;
|
||||||
|
ADDC(GLFW_RELEASE);
|
||||||
|
ADDC(GLFW_PRESS);
|
||||||
|
ADDC(GLFW_REPEAT);
|
||||||
|
|
||||||
|
// --- Keys --------------------------------------------------------------------
|
||||||
|
|
||||||
|
// --- The unknown key ---------------------------------------------------------
|
||||||
|
ADDC(GLFW_KEY_UNKNOWN);
|
||||||
|
|
||||||
|
// --- Printable keys ----------------------------------------------------------
|
||||||
|
ADDC(GLFW_KEY_SPACE);
|
||||||
|
ADDC(GLFW_KEY_APOSTROPHE);
|
||||||
|
ADDC(GLFW_KEY_COMMA);
|
||||||
|
ADDC(GLFW_KEY_MINUS);
|
||||||
|
ADDC(GLFW_KEY_PERIOD);
|
||||||
|
ADDC(GLFW_KEY_SLASH);
|
||||||
|
ADDC(GLFW_KEY_0);
|
||||||
|
ADDC(GLFW_KEY_1);
|
||||||
|
ADDC(GLFW_KEY_2);
|
||||||
|
ADDC(GLFW_KEY_3);
|
||||||
|
ADDC(GLFW_KEY_4);
|
||||||
|
ADDC(GLFW_KEY_5);
|
||||||
|
ADDC(GLFW_KEY_6);
|
||||||
|
ADDC(GLFW_KEY_7);
|
||||||
|
ADDC(GLFW_KEY_8);
|
||||||
|
ADDC(GLFW_KEY_9);
|
||||||
|
ADDC(GLFW_KEY_SEMICOLON);
|
||||||
|
ADDC(GLFW_KEY_EQUAL);
|
||||||
|
ADDC(GLFW_KEY_A);
|
||||||
|
ADDC(GLFW_KEY_B);
|
||||||
|
ADDC(GLFW_KEY_C);
|
||||||
|
ADDC(GLFW_KEY_D);
|
||||||
|
ADDC(GLFW_KEY_E);
|
||||||
|
ADDC(GLFW_KEY_F);
|
||||||
|
ADDC(GLFW_KEY_G);
|
||||||
|
ADDC(GLFW_KEY_H);
|
||||||
|
ADDC(GLFW_KEY_I);
|
||||||
|
ADDC(GLFW_KEY_J);
|
||||||
|
ADDC(GLFW_KEY_K);
|
||||||
|
ADDC(GLFW_KEY_L);
|
||||||
|
ADDC(GLFW_KEY_M);
|
||||||
|
ADDC(GLFW_KEY_N);
|
||||||
|
ADDC(GLFW_KEY_O);
|
||||||
|
ADDC(GLFW_KEY_P);
|
||||||
|
ADDC(GLFW_KEY_Q);
|
||||||
|
ADDC(GLFW_KEY_R);
|
||||||
|
ADDC(GLFW_KEY_S);
|
||||||
|
ADDC(GLFW_KEY_T);
|
||||||
|
ADDC(GLFW_KEY_U);
|
||||||
|
ADDC(GLFW_KEY_V);
|
||||||
|
ADDC(GLFW_KEY_W);
|
||||||
|
ADDC(GLFW_KEY_X);
|
||||||
|
ADDC(GLFW_KEY_Y);
|
||||||
|
ADDC(GLFW_KEY_Z);
|
||||||
|
ADDC(GLFW_KEY_LEFT_BRACKET);
|
||||||
|
ADDC(GLFW_KEY_BACKSLASH);
|
||||||
|
ADDC(GLFW_KEY_RIGHT_BRACKET);
|
||||||
|
ADDC(GLFW_KEY_GRAVE_ACCENT);
|
||||||
|
ADDC(GLFW_KEY_WORLD_1);
|
||||||
|
ADDC(GLFW_KEY_WORLD_2);
|
||||||
|
|
||||||
|
// --- Function keys -----------------------------------------------------------
|
||||||
|
ADDC(GLFW_KEY_ESCAPE);
|
||||||
|
ADDC(GLFW_KEY_ENTER);
|
||||||
|
ADDC(GLFW_KEY_TAB);
|
||||||
|
ADDC(GLFW_KEY_BACKSPACE);
|
||||||
|
ADDC(GLFW_KEY_INSERT);
|
||||||
|
ADDC(GLFW_KEY_DELETE);
|
||||||
|
ADDC(GLFW_KEY_RIGHT);
|
||||||
|
ADDC(GLFW_KEY_LEFT);
|
||||||
|
ADDC(GLFW_KEY_DOWN);
|
||||||
|
ADDC(GLFW_KEY_UP);
|
||||||
|
ADDC(GLFW_KEY_PAGE_UP);
|
||||||
|
ADDC(GLFW_KEY_PAGE_DOWN);
|
||||||
|
ADDC(GLFW_KEY_HOME);
|
||||||
|
ADDC(GLFW_KEY_END);
|
||||||
|
ADDC(GLFW_KEY_CAPS_LOCK);
|
||||||
|
ADDC(GLFW_KEY_SCROLL_LOCK);
|
||||||
|
ADDC(GLFW_KEY_NUM_LOCK);
|
||||||
|
ADDC(GLFW_KEY_PRINT_SCREEN);
|
||||||
|
ADDC(GLFW_KEY_PAUSE);
|
||||||
|
ADDC(GLFW_KEY_F1);
|
||||||
|
ADDC(GLFW_KEY_F2);
|
||||||
|
ADDC(GLFW_KEY_F3);
|
||||||
|
ADDC(GLFW_KEY_F4);
|
||||||
|
ADDC(GLFW_KEY_F5);
|
||||||
|
ADDC(GLFW_KEY_F6);
|
||||||
|
ADDC(GLFW_KEY_F7);
|
||||||
|
ADDC(GLFW_KEY_F8);
|
||||||
|
ADDC(GLFW_KEY_F9);
|
||||||
|
ADDC(GLFW_KEY_F10);
|
||||||
|
ADDC(GLFW_KEY_F11);
|
||||||
|
ADDC(GLFW_KEY_F12);
|
||||||
|
ADDC(GLFW_KEY_F13);
|
||||||
|
ADDC(GLFW_KEY_F14);
|
||||||
|
ADDC(GLFW_KEY_F15);
|
||||||
|
ADDC(GLFW_KEY_F16);
|
||||||
|
ADDC(GLFW_KEY_F17);
|
||||||
|
ADDC(GLFW_KEY_F18);
|
||||||
|
ADDC(GLFW_KEY_F19);
|
||||||
|
ADDC(GLFW_KEY_F20);
|
||||||
|
ADDC(GLFW_KEY_F21);
|
||||||
|
ADDC(GLFW_KEY_F22);
|
||||||
|
ADDC(GLFW_KEY_F23);
|
||||||
|
ADDC(GLFW_KEY_F24);
|
||||||
|
ADDC(GLFW_KEY_F25);
|
||||||
|
ADDC(GLFW_KEY_KP_0);
|
||||||
|
ADDC(GLFW_KEY_KP_1);
|
||||||
|
ADDC(GLFW_KEY_KP_2);
|
||||||
|
ADDC(GLFW_KEY_KP_3);
|
||||||
|
ADDC(GLFW_KEY_KP_4);
|
||||||
|
ADDC(GLFW_KEY_KP_5);
|
||||||
|
ADDC(GLFW_KEY_KP_6);
|
||||||
|
ADDC(GLFW_KEY_KP_7);
|
||||||
|
ADDC(GLFW_KEY_KP_8);
|
||||||
|
ADDC(GLFW_KEY_KP_9);
|
||||||
|
ADDC(GLFW_KEY_KP_DECIMAL);
|
||||||
|
ADDC(GLFW_KEY_KP_DIVIDE);
|
||||||
|
ADDC(GLFW_KEY_KP_MULTIPLY);
|
||||||
|
ADDC(GLFW_KEY_KP_SUBTRACT);
|
||||||
|
ADDC(GLFW_KEY_KP_ADD);
|
||||||
|
ADDC(GLFW_KEY_KP_ENTER);
|
||||||
|
ADDC(GLFW_KEY_KP_EQUAL);
|
||||||
|
ADDC(GLFW_KEY_LEFT_SHIFT);
|
||||||
|
ADDC(GLFW_KEY_LEFT_CONTROL);
|
||||||
|
ADDC(GLFW_KEY_LEFT_ALT);
|
||||||
|
ADDC(GLFW_KEY_LEFT_SUPER);
|
||||||
|
ADDC(GLFW_KEY_RIGHT_SHIFT);
|
||||||
|
ADDC(GLFW_KEY_RIGHT_CONTROL);
|
||||||
|
ADDC(GLFW_KEY_RIGHT_ALT);
|
||||||
|
ADDC(GLFW_KEY_RIGHT_SUPER);
|
||||||
|
ADDC(GLFW_KEY_MENU);
|
||||||
|
ADDC(GLFW_KEY_LAST);
|
||||||
|
|
||||||
|
// --- Modifiers ---------------------------------------------------------------
|
||||||
|
ADDC(GLFW_MOD_SHIFT);
|
||||||
|
ADDC(GLFW_MOD_CONTROL);
|
||||||
|
ADDC(GLFW_MOD_ALT);
|
||||||
|
ADDC(GLFW_MOD_SUPER);
|
||||||
|
|
||||||
|
// --- Mouse -------------------------------------------------------------------
|
||||||
|
ADDC(GLFW_MOUSE_BUTTON_1);
|
||||||
|
ADDC(GLFW_MOUSE_BUTTON_2);
|
||||||
|
ADDC(GLFW_MOUSE_BUTTON_3);
|
||||||
|
ADDC(GLFW_MOUSE_BUTTON_4);
|
||||||
|
ADDC(GLFW_MOUSE_BUTTON_5);
|
||||||
|
ADDC(GLFW_MOUSE_BUTTON_6);
|
||||||
|
ADDC(GLFW_MOUSE_BUTTON_7);
|
||||||
|
ADDC(GLFW_MOUSE_BUTTON_8);
|
||||||
|
ADDC(GLFW_MOUSE_BUTTON_LAST);
|
||||||
|
ADDC(GLFW_MOUSE_BUTTON_LEFT);
|
||||||
|
ADDC(GLFW_MOUSE_BUTTON_RIGHT);
|
||||||
|
ADDC(GLFW_MOUSE_BUTTON_MIDDLE);
|
||||||
|
|
||||||
|
|
||||||
|
// --- Joystick ----------------------------------------------------------------
|
||||||
|
ADDC(GLFW_JOYSTICK_1);
|
||||||
|
ADDC(GLFW_JOYSTICK_2);
|
||||||
|
ADDC(GLFW_JOYSTICK_3);
|
||||||
|
ADDC(GLFW_JOYSTICK_4);
|
||||||
|
ADDC(GLFW_JOYSTICK_5);
|
||||||
|
ADDC(GLFW_JOYSTICK_6);
|
||||||
|
ADDC(GLFW_JOYSTICK_7);
|
||||||
|
ADDC(GLFW_JOYSTICK_8);
|
||||||
|
ADDC(GLFW_JOYSTICK_9);
|
||||||
|
ADDC(GLFW_JOYSTICK_10);
|
||||||
|
ADDC(GLFW_JOYSTICK_11);
|
||||||
|
ADDC(GLFW_JOYSTICK_12);
|
||||||
|
ADDC(GLFW_JOYSTICK_13);
|
||||||
|
ADDC(GLFW_JOYSTICK_14);
|
||||||
|
ADDC(GLFW_JOYSTICK_15);
|
||||||
|
ADDC(GLFW_JOYSTICK_16);
|
||||||
|
ADDC(GLFW_JOYSTICK_LAST);
|
||||||
|
|
||||||
|
|
||||||
|
// --- Error codes -------------------------------------------------------------
|
||||||
|
ADDC(GLFW_NOT_INITIALIZED);
|
||||||
|
ADDC(GLFW_NO_CURRENT_CONTEXT);
|
||||||
|
ADDC(GLFW_INVALID_ENUM);
|
||||||
|
ADDC(GLFW_INVALID_VALUE);
|
||||||
|
ADDC(GLFW_OUT_OF_MEMORY);
|
||||||
|
ADDC(GLFW_API_UNAVAILABLE);
|
||||||
|
ADDC(GLFW_VERSION_UNAVAILABLE);
|
||||||
|
ADDC(GLFW_PLATFORM_ERROR);
|
||||||
|
ADDC(GLFW_FORMAT_UNAVAILABLE);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
ADDC(GLFW_FOCUSED);
|
||||||
|
ADDC(GLFW_ICONIFIED);
|
||||||
|
ADDC(GLFW_RESIZABLE);
|
||||||
|
ADDC(GLFW_VISIBLE);
|
||||||
|
ADDC(GLFW_DECORATED);
|
||||||
|
ADDC(GLFW_AUTO_ICONIFY);
|
||||||
|
ADDC(GLFW_FLOATING);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
ADDC(GLFW_RED_BITS);
|
||||||
|
ADDC(GLFW_GREEN_BITS);
|
||||||
|
ADDC(GLFW_BLUE_BITS);
|
||||||
|
ADDC(GLFW_ALPHA_BITS);
|
||||||
|
ADDC(GLFW_DEPTH_BITS);
|
||||||
|
ADDC(GLFW_STENCIL_BITS);
|
||||||
|
ADDC(GLFW_ACCUM_RED_BITS);
|
||||||
|
ADDC(GLFW_ACCUM_GREEN_BITS);
|
||||||
|
ADDC(GLFW_ACCUM_BLUE_BITS);
|
||||||
|
ADDC(GLFW_ACCUM_ALPHA_BITS);
|
||||||
|
ADDC(GLFW_AUX_BUFFERS);
|
||||||
|
ADDC(GLFW_STEREO);
|
||||||
|
ADDC(GLFW_SAMPLES);
|
||||||
|
ADDC(GLFW_SRGB_CAPABLE);
|
||||||
|
ADDC(GLFW_REFRESH_RATE);
|
||||||
|
ADDC(GLFW_DOUBLEBUFFER);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
ADDC(GLFW_CLIENT_API);
|
||||||
|
ADDC(GLFW_CONTEXT_VERSION_MAJOR);
|
||||||
|
ADDC(GLFW_CONTEXT_VERSION_MINOR);
|
||||||
|
ADDC(GLFW_CONTEXT_REVISION);
|
||||||
|
ADDC(GLFW_CONTEXT_ROBUSTNESS);
|
||||||
|
ADDC(GLFW_OPENGL_FORWARD_COMPAT);
|
||||||
|
ADDC(GLFW_OPENGL_DEBUG_CONTEXT);
|
||||||
|
ADDC(GLFW_OPENGL_PROFILE);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
ADDC(GLFW_OPENGL_API);
|
||||||
|
ADDC(GLFW_OPENGL_ES_API);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
ADDC(GLFW_NO_ROBUSTNESS);
|
||||||
|
ADDC(GLFW_NO_RESET_NOTIFICATION);
|
||||||
|
ADDC(GLFW_LOSE_CONTEXT_ON_RESET);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
ADDC(GLFW_OPENGL_ANY_PROFILE);
|
||||||
|
ADDC(GLFW_OPENGL_CORE_PROFILE);
|
||||||
|
ADDC(GLFW_OPENGL_COMPAT_PROFILE);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
ADDC(GLFW_CURSOR);
|
||||||
|
ADDC(GLFW_STICKY_KEYS);
|
||||||
|
ADDC(GLFW_STICKY_MOUSE_BUTTONS);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
ADDC(GLFW_CURSOR_NORMAL);
|
||||||
|
ADDC(GLFW_CURSOR_HIDDEN);
|
||||||
|
ADDC(GLFW_CURSOR_DISABLED);
|
||||||
|
|
||||||
|
// ---
|
||||||
|
ADDC(GLFW_CONNECTED);
|
||||||
|
ADDC(GLFW_DISCONNECTED);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
#undef ADDC
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
11
kitty/glfw.h
Normal file
11
kitty/glfw.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
*
|
||||||
|
* Distributed under terms of the GPL3 license.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
bool init_glfw(PyObject *m);
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
# vim:fileencoding=utf-8
|
# vim:fileencoding=utf-8
|
||||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
import glfw_constants as defines
|
import kitty.fast_data_types as defines
|
||||||
from .terminfo import key_as_bytes
|
from .terminfo import key_as_bytes
|
||||||
|
|
||||||
key_map = {
|
key_map = {
|
||||||
|
|||||||
@@ -13,9 +13,13 @@ from .config import load_config
|
|||||||
from .constants import appname, str_version, config_dir, viewport_size
|
from .constants import appname, str_version, config_dir, viewport_size
|
||||||
from .tabs import TabManager
|
from .tabs import TabManager
|
||||||
from .shaders import GL_VERSION
|
from .shaders import GL_VERSION
|
||||||
from .fast_data_types import glewInit, enable_automatic_opengl_error_checking, glClear, glClearColor, GL_COLOR_BUFFER_BIT
|
from .fast_data_types import (
|
||||||
|
glewInit, enable_automatic_opengl_error_checking, glClear, glClearColor,
|
||||||
|
GL_COLOR_BUFFER_BIT, GLFW_CONTEXT_VERSION_MAJOR,
|
||||||
|
GLFW_CONTEXT_VERSION_MINOR, GLFW_OPENGL_PROFILE,
|
||||||
|
GLFW_OPENGL_FORWARD_COMPAT, GLFW_OPENGL_CORE_PROFILE, GLFW_SAMPLES
|
||||||
|
)
|
||||||
import glfw
|
import glfw
|
||||||
import glfw_constants
|
|
||||||
|
|
||||||
|
|
||||||
def option_parser():
|
def option_parser():
|
||||||
@@ -36,11 +40,11 @@ def option_parser():
|
|||||||
|
|
||||||
|
|
||||||
def setup_opengl():
|
def setup_opengl():
|
||||||
glfw.glfwWindowHint(glfw_constants.GLFW_CONTEXT_VERSION_MAJOR, GL_VERSION[0])
|
glfw.glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, GL_VERSION[0])
|
||||||
glfw.glfwWindowHint(glfw_constants.GLFW_CONTEXT_VERSION_MINOR, GL_VERSION[1])
|
glfw.glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, GL_VERSION[1])
|
||||||
glfw.glfwWindowHint(glfw_constants.GLFW_OPENGL_PROFILE, glfw_constants.GLFW_OPENGL_CORE_PROFILE)
|
glfw.glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE)
|
||||||
glfw.glfwWindowHint(glfw_constants.GLFW_OPENGL_FORWARD_COMPAT, True)
|
glfw.glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, True)
|
||||||
glfw.glfwWindowHint(glfw_constants.GLFW_SAMPLES, 0)
|
glfw.glfwWindowHint(GLFW_SAMPLES, 0)
|
||||||
|
|
||||||
|
|
||||||
def clear_buffers(window, opts):
|
def clear_buffers(window, opts):
|
||||||
|
|||||||
@@ -15,10 +15,12 @@ from time import monotonic
|
|||||||
from queue import Queue, Empty
|
from queue import Queue, Empty
|
||||||
|
|
||||||
import glfw
|
import glfw
|
||||||
import glfw_constants
|
|
||||||
from .child import Child
|
from .child import Child
|
||||||
from .constants import viewport_size, shell_path, appname, set_tab_manager, tab_manager, wakeup, cell_size
|
from .constants import viewport_size, shell_path, appname, set_tab_manager, tab_manager, wakeup, cell_size, MODIFIER_KEYS
|
||||||
from .fast_data_types import glViewport, glBlendFunc, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
|
from .fast_data_types import (
|
||||||
|
glViewport, glBlendFunc, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GLFW_PRESS,
|
||||||
|
GLFW_REPEAT, GLFW_MOUSE_BUTTON_1
|
||||||
|
)
|
||||||
from .fonts import set_font_family
|
from .fonts import set_font_family
|
||||||
from .borders import Borders, BordersProgram
|
from .borders import Borders, BordersProgram
|
||||||
from .char_grid import cursor_shader, cell_shader
|
from .char_grid import cursor_shader, cell_shader
|
||||||
@@ -137,6 +139,9 @@ class TabManager(Thread):
|
|||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
||||||
self.sprites.do_layout(cell_size.width, cell_size.height)
|
self.sprites.do_layout(cell_size.width, cell_size.height)
|
||||||
self.queue_action(self.active_tab.new_window, False)
|
self.queue_action(self.active_tab.new_window, False)
|
||||||
|
# self.standard_cursor = glfw.glfwCreateStandardCursor(GLFW_IBEAM_CURSOR)
|
||||||
|
# self.click_cursor = glfw.glfwCreateStandardCursor(GLFW_HAND_CURSOR)
|
||||||
|
# glfw.glfwSetCursor(self.glfw_window, self.standard_cursor)
|
||||||
|
|
||||||
def signal_received(self):
|
def signal_received(self):
|
||||||
try:
|
try:
|
||||||
@@ -295,7 +300,7 @@ class TabManager(Thread):
|
|||||||
w.write_to_child(data)
|
w.write_to_child(data)
|
||||||
|
|
||||||
def on_key(self, window, key, scancode, action, mods):
|
def on_key(self, window, key, scancode, action, mods):
|
||||||
if action == glfw_constants.GLFW_PRESS or action == glfw_constants.GLFW_REPEAT:
|
if action == GLFW_PRESS or action == GLFW_REPEAT:
|
||||||
func = get_shortcut(self.opts.keymap, mods, key)
|
func = get_shortcut(self.opts.keymap, mods, key)
|
||||||
tab = self.active_tab
|
tab = self.active_tab
|
||||||
window = self.active_window
|
window = self.active_window
|
||||||
@@ -306,7 +311,7 @@ class TabManager(Thread):
|
|||||||
if not passthrough:
|
if not passthrough:
|
||||||
return
|
return
|
||||||
if window:
|
if window:
|
||||||
if window.char_grid.scrolled_by and key not in glfw_constants.MODIFIER_KEYS:
|
if window.char_grid.scrolled_by and key not in MODIFIER_KEYS:
|
||||||
window.scroll_end()
|
window.scroll_end()
|
||||||
data = interpret_key_event(key, scancode, mods)
|
data = interpret_key_event(key, scancode, mods)
|
||||||
if data:
|
if data:
|
||||||
@@ -325,7 +330,7 @@ class TabManager(Thread):
|
|||||||
def on_mouse_button(self, window, button, action, mods):
|
def on_mouse_button(self, window, button, action, mods):
|
||||||
w = self.window_for_pos(*glfw.glfwGetCursorPos(window))
|
w = self.window_for_pos(*glfw.glfwGetCursorPos(window))
|
||||||
if w is not None:
|
if w is not None:
|
||||||
if button == glfw_constants.GLFW_MOUSE_BUTTON_1 and w is not self.active_window:
|
if button == GLFW_MOUSE_BUTTON_1 and w is not self.active_window:
|
||||||
pass # TODO: Switch focus to this window
|
pass # TODO: Switch focus to this window
|
||||||
w.on_mouse_button(window, button, action, mods)
|
w.on_mouse_button(window, button, action, mods)
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,13 @@ from functools import partial
|
|||||||
from time import monotonic
|
from time import monotonic
|
||||||
|
|
||||||
import glfw
|
import glfw
|
||||||
import glfw_constants
|
|
||||||
from .char_grid import CharGrid
|
from .char_grid import CharGrid
|
||||||
from .constants import wakeup, tab_manager, appname, WindowGeometry
|
from .constants import wakeup, tab_manager, appname, WindowGeometry
|
||||||
from .fast_data_types import (
|
from .fast_data_types import (
|
||||||
BRACKETED_PASTE_START, BRACKETED_PASTE_END, Screen, read_bytes_dump, read_bytes
|
BRACKETED_PASTE_START, BRACKETED_PASTE_END, Screen, read_bytes_dump,
|
||||||
|
read_bytes, GLFW_MOD_SHIFT, GLFW_MOUSE_BUTTON_1, GLFW_PRESS,
|
||||||
|
GLFW_MOUSE_BUTTON_MIDDLE, GLFW_RELEASE, GLFW_KEY_LEFT_SHIFT,
|
||||||
|
GLFW_KEY_RIGHT_SHIFT
|
||||||
)
|
)
|
||||||
from .terminfo import get_capabilities
|
from .terminfo import get_capabilities
|
||||||
from .utils import sanitize_title, get_primary_selection
|
from .utils import sanitize_title, get_primary_selection
|
||||||
@@ -125,18 +127,22 @@ class Window:
|
|||||||
glfw.glfwPostEmptyEvent()
|
glfw.glfwPostEmptyEvent()
|
||||||
|
|
||||||
def on_mouse_button(self, window, button, action, mods):
|
def on_mouse_button(self, window, button, action, mods):
|
||||||
handle_event = mods == glfw_constants.GLFW_MOD_SHIFT or not self.screen.mouse_button_tracking_enabled()
|
handle_event = mods == GLFW_MOD_SHIFT or not self.screen.mouse_button_tracking_enabled()
|
||||||
if handle_event:
|
if handle_event:
|
||||||
if button == glfw_constants.GLFW_MOUSE_BUTTON_1:
|
if button == GLFW_MOUSE_BUTTON_1:
|
||||||
x, y = glfw.glfwGetCursorPos(window)
|
x, y = glfw.glfwGetCursorPos(window)
|
||||||
x, y = max(0, x - self.geometry.left), max(0, y - self.geometry.top)
|
x, y = max(0, x - self.geometry.left), max(0, y - self.geometry.top)
|
||||||
self.char_grid.update_drag(action == glfw_constants.GLFW_PRESS, x, y)
|
self.char_grid.update_drag(action == GLFW_PRESS, x, y)
|
||||||
if action == glfw_constants.GLFW_RELEASE:
|
if action == GLFW_RELEASE:
|
||||||
self.click_queue.append(monotonic())
|
self.click_queue.append(monotonic())
|
||||||
self.dispatch_multi_click(x, y)
|
self.dispatch_multi_click(x, y)
|
||||||
elif button == glfw_constants.GLFW_MOUSE_BUTTON_MIDDLE:
|
elif button == GLFW_MOUSE_BUTTON_MIDDLE:
|
||||||
if action == glfw_constants.GLFW_RELEASE:
|
if action == GLFW_RELEASE:
|
||||||
self.paste_from_selection()
|
self.paste_from_selection()
|
||||||
|
else:
|
||||||
|
x, y = glfw.glfwGetCursorPos(window)
|
||||||
|
x, y = max(0, x - self.geometry.left), max(0, y - self.geometry.top)
|
||||||
|
x, y = self.char_grid.cell_for_pos(x, y)
|
||||||
|
|
||||||
def on_mouse_move(self, window, x, y):
|
def on_mouse_move(self, window, x, y):
|
||||||
if self.char_grid.current_selection.in_progress:
|
if self.char_grid.current_selection.in_progress:
|
||||||
@@ -144,8 +150,8 @@ class Window:
|
|||||||
|
|
||||||
def on_mouse_scroll(self, window, x, y):
|
def on_mouse_scroll(self, window, x, y):
|
||||||
handle_event = (
|
handle_event = (
|
||||||
glfw.glfwGetKey(window, glfw_constants.GLFW_KEY_LEFT_SHIFT) == glfw_constants.GLFW_PRESS or
|
glfw.glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS or
|
||||||
glfw.glfwGetKey(window, glfw_constants.GLFW_KEY_RIGHT_SHIFT) == glfw_constants.GLFW_PRESS or
|
glfw.glfwGetKey(window, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS or
|
||||||
not self.screen.mouse_button_tracking_enabled())
|
not self.screen.mouse_button_tracking_enabled())
|
||||||
if handle_event:
|
if handle_event:
|
||||||
s = int(round(y * self.opts.wheel_scroll_multiplier))
|
s = int(round(y * self.opts.wheel_scroll_multiplier))
|
||||||
|
|||||||
6
setup.py
6
setup.py
@@ -24,7 +24,7 @@ cflags = ldflags = cc = ldpaths = None
|
|||||||
|
|
||||||
|
|
||||||
def pkg_config(pkg, *args):
|
def pkg_config(pkg, *args):
|
||||||
return shlex.split(subprocess.check_output(['pkg-config', pkg] + list(args)).decode('utf-8'))
|
return list(filter(None, shlex.split(subprocess.check_output(['pkg-config', pkg] + list(args)).decode('utf-8'))))
|
||||||
|
|
||||||
|
|
||||||
def cc_version():
|
def cc_version():
|
||||||
@@ -60,11 +60,13 @@ def init_env(debug=False):
|
|||||||
cflags.append('-pthread')
|
cflags.append('-pthread')
|
||||||
cflags.extend(pkg_config('glew', '--cflags-only-I'))
|
cflags.extend(pkg_config('glew', '--cflags-only-I'))
|
||||||
cflags.extend(pkg_config('freetype2', '--cflags-only-I'))
|
cflags.extend(pkg_config('freetype2', '--cflags-only-I'))
|
||||||
|
cflags.extend(pkg_config('glfw3', '--cflags-only-I'))
|
||||||
ldflags.append('-pthread')
|
ldflags.append('-pthread')
|
||||||
ldflags.append('-shared')
|
ldflags.append('-shared')
|
||||||
cflags.append('-I' + sysconfig.get_config_var('CONFINCLUDEPY'))
|
cflags.append('-I' + sysconfig.get_config_var('CONFINCLUDEPY'))
|
||||||
lib = sysconfig.get_config_var('LDLIBRARY')[3:-3]
|
lib = sysconfig.get_config_var('LDLIBRARY')[3:-3]
|
||||||
ldpaths = ['-L' + sysconfig.get_config_var('LIBDIR'), '-l' + lib] + pkg_config('glew', '--libs') + pkg_config('freetype2', '--libs')
|
ldpaths = ['-L' + sysconfig.get_config_var('LIBDIR'), '-l' + lib] + \
|
||||||
|
pkg_config('glew', '--libs') + pkg_config('freetype2', '--libs') + pkg_config('glfw3', '--libs')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.mkdir(build_dir)
|
os.mkdir(build_dir)
|
||||||
|
|||||||
Reference in New Issue
Block a user