isosx -> is_macos

This commit is contained in:
Kovid Goyal
2017-12-01 12:16:13 +05:30
parent 85fcd51ea3
commit eb8f4e0b3c
9 changed files with 37 additions and 37 deletions
+2 -2
View File
@@ -6,7 +6,7 @@ import argparse
from gettext import gettext as _
from .config import load_config
from .constants import appname, str_version, isosx, defconf
from .constants import appname, str_version, is_macos, defconf
from .layout import all_layouts
@@ -70,7 +70,7 @@ def option_parser():
default=False,
help=_('Output commands received from child process to stdout')
)
if not isosx:
if not is_macos:
a(
'--detach',
action='store_true',
+2 -2
View File
@@ -13,7 +13,7 @@ appname = 'kitty'
version = (0, 5, 1)
str_version = '.'.join(map(str, version))
_plat = sys.platform.lower()
isosx = 'darwin' in _plat
is_macos = 'darwin' in _plat
ScreenGeometry = namedtuple('ScreenGeometry', 'xstart ystart xnum ynum dx dy')
@@ -25,7 +25,7 @@ def _get_config_dir():
if 'KITTY_CONFIG_DIRECTORY' in os.environ:
return os.path.abspath(os.path.expanduser(os.environ['VISE_CONFIG_DIRECTORY']))
candidate = os.path.abspath(os.path.expanduser(os.environ.get('XDG_CONFIG_HOME') or ('~/Library/Preferences' if isosx else '~/.config')))
candidate = os.path.abspath(os.path.expanduser(os.environ.get('XDG_CONFIG_HOME') or ('~/Library/Preferences' if is_macos else '~/.config')))
ans = os.path.join(candidate, appname)
os.makedirs(ans, exist_ok=True)
return ans
+2 -2
View File
@@ -3,9 +3,9 @@
# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
import sys
from kitty.constants import isosx
from kitty.constants import is_macos
if isosx:
if is_macos:
from .core_text import list_fonts
else:
from .fontconfig import list_fonts
+3 -3
View File
@@ -8,7 +8,7 @@ from collections import namedtuple
from math import ceil, floor, pi, sin, sqrt
from kitty.config import defaults
from kitty.constants import isosx
from kitty.constants import is_macos
from kitty.fast_data_types import (
Screen, change_wcwidth, get_fallback_font, send_prerendered_sprites,
set_font, set_font_size, set_logical_dpi, set_send_sprite_to_gpu,
@@ -16,7 +16,7 @@ from kitty.fast_data_types import (
)
from kitty.fonts.box_drawing import render_box_char, render_missing_glyph
if isosx:
if is_macos:
from .core_text import get_font_files, font_for_family
else:
from .fontconfig import get_font_files, font_for_family
@@ -243,7 +243,7 @@ def test_fallback_font(qtext=None, bold=False, italic=False):
def showcase():
change_wcwidth(True)
f = 'monospace' if isosx else 'Liberation Mono'
f = 'monospace' if is_macos else 'Liberation Mono'
test_render_string('He\u0347\u0305llo\u0337, w\u0302or\u0306l\u0354d!', family=f)
test_render_string('你好,世界', family=f)
test_render_string('|\U0001F601|\U0001F64f|\U0001F63a|', family=f)
+5 -5
View File
@@ -12,7 +12,7 @@ from .borders import load_borders_program
from .boss import Boss
from .cli import create_opts, option_parser
from .config import initial_window_size, load_cached_values, save_cached_values
from .constants import isosx, iswayland, logo_data_file
from .constants import is_macos, iswayland, logo_data_file
from .fast_data_types import (
change_wcwidth, create_os_window, glfw_init, glfw_terminate,
install_sigchld_handler, set_default_window_icon, set_logical_dpi,
@@ -34,7 +34,7 @@ def load_all_shaders():
def init_graphics():
glfw_module = 'cocoa' if isosx else 'x11'
glfw_module = 'cocoa' if is_macos else 'x11'
if not glfw_init(os.path.join(base, 'glfw-{}.so'.format(glfw_module))):
raise SystemExit('GLFW initialization failed')
return glfw_module
@@ -47,7 +47,7 @@ def run_app(opts, args):
w, h = initial_window_size(opts)
window_id = create_os_window(w, h, encode_wm_class(args.name, args.cls), True, load_all_shaders)
startup_ctx = init_startup_notification(window_id)
if not iswayland and not isosx: # no window icons on wayland
if not iswayland and not is_macos: # no window icons on wayland
with open(logo_data_file, 'rb') as f:
set_default_window_icon(f.read(), 256, 256)
set_logical_dpi(*get_logical_dpi())
@@ -99,12 +99,12 @@ def main():
sys.setswitchinterval(1000.0) # we have only a single python thread
except AttributeError:
pass # python compiled without threading
if isosx:
if is_macos:
ensure_osx_locale()
try:
locale.setlocale(locale.LC_ALL, '')
except Exception:
if not isosx:
if not is_macos:
raise
print('Failed to set locale with LANG:', os.environ.get('LANG'), file=sys.stderr)
os.environ.pop('LANG')
+9 -9
View File
@@ -17,7 +17,7 @@ from contextlib import contextmanager
from functools import lru_cache
from time import monotonic
from .constants import appname, isosx, iswayland
from .constants import appname, is_macos, iswayland
from .fast_data_types import (
GLSL_VERSION, glfw_get_physical_dpi, glfw_primary_monitor_content_scale,
redirect_std_streams, wcwidth as wcwidth_impl, x11_display, x11_window_id
@@ -78,7 +78,7 @@ def get_logical_dpi(override_dpi=None):
if override_dpi is not None:
get_logical_dpi.ans = override_dpi
if not hasattr(get_logical_dpi, 'ans'):
if isosx:
if is_macos:
# TODO: Investigate if this needs a different implementation on OS X
get_logical_dpi.ans = glfw_get_physical_dpi()
else:
@@ -117,7 +117,7 @@ def parse_color_set(raw):
def set_primary_selection(text):
if isosx or iswayland:
if is_macos or iswayland:
return # There is no primary selection
if isinstance(text, bytes):
text = text.decode('utf-8')
@@ -126,7 +126,7 @@ def set_primary_selection(text):
def get_primary_selection():
if isosx or iswayland:
if is_macos or iswayland:
return '' # There is no primary selection
from kitty.fast_data_types import get_primary_selection
return (get_primary_selection() or b'').decode('utf-8', 'replace')
@@ -155,7 +155,7 @@ def open_cmd(cmd, arg=None):
def open_url(url, program='default'):
if program == 'default':
cmd = ['open'] if isosx else ['xdg-open']
cmd = ['open'] if is_macos else ['xdg-open']
else:
cmd = shlex.split(program)
return open_cmd(cmd, url)
@@ -197,7 +197,7 @@ def end_startup_notification_x11(ctx):
def init_startup_notification(window, startup_id=None):
if isosx or iswayland:
if is_macos or iswayland:
return
try:
return init_startup_notification_x11(window, startup_id)
@@ -209,7 +209,7 @@ def init_startup_notification(window, startup_id=None):
def end_startup_notification(ctx):
if not ctx:
return
if isosx or iswayland:
if is_macos or iswayland:
return
try:
end_startup_notification_x11(ctx)
@@ -233,7 +233,7 @@ def remove_socket_file(s, path=None):
def single_instance_unix(name):
home = os.path.expanduser('~')
candidates = [tempfile.gettempdir(), home]
if isosx:
if is_macos:
from .fast_data_types import user_cache_dir
candidates = [user_cache_dir(), '/Library/Caches']
for loc in candidates:
@@ -294,6 +294,6 @@ def single_instance(group_id=None):
def encode_wm_class(name, cls, title=appname):
if isosx:
if is_macos:
return title
return '\x01' + (name or cls) + '\x1e' + cls + '\x1e' + title