core.lua (61c1328eb016476ee7ff5ad65d8224bb43e572db) core.lua (bac5966e2d1b4cd7cb4d0cfab7a013d2af8054e5)
1--
2-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3--
4-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
5-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
6-- All rights reserved.
7--
8-- Redistribution and use in source and binary forms, with or without

--- 55 unchanged lines hidden (view full) ---

64 core.setVerbose(default_verbose)
65end
66
67
68-- Globals
69-- try_include will return the loaded module on success, or false and the error
70-- message on failure.
71function try_include(module)
1--
2-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3--
4-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
5-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
6-- All rights reserved.
7--
8-- Redistribution and use in source and binary forms, with or without

--- 55 unchanged lines hidden (view full) ---

64 core.setVerbose(default_verbose)
65end
66
67
68-- Globals
69-- try_include will return the loaded module on success, or false and the error
70-- message on failure.
71function try_include(module)
72 local status, ret = pcall(require, module)
73 -- ret is the module if we succeeded.
74 if status then
75 return ret
72 if module:sub(1, 1) ~= "/" then
73 local lua_path = loader.lua_paths
74 -- XXX Temporary compat shim; this should be removed once the
75 -- loader.lua_path export has sufficiently spread.
76 if lua_path == nil then
77 lua_path = "/boot/lua"
78 end
79 module = lua_path .. "/" .. module
80 -- We only attempt to append an extension if an absolute path
81 -- wasn't specified. This assumes that the caller either wants
82 -- to treat this like it would require() and specify just the
83 -- base filename, or they know what they're doing as they've
84 -- specified an absolute path and we shouldn't impede.
85 if module:match(".lua$") == nil then
86 module = module .. ".lua"
87 end
76 end
88 end
77 return false, ret
89 if lfs.attributes(module, "mode") ~= "file" then
90 return
91 end
92
93 return dofile(module)
78end
79
80-- Module exports
81-- Commonly appearing constants
82core.KEY_BACKSPACE = 8
83core.KEY_ENTER = 13
84core.KEY_DELETE = 127
85

--- 313 unchanged lines hidden ---
94end
95
96-- Module exports
97-- Commonly appearing constants
98core.KEY_BACKSPACE = 8
99core.KEY_ENTER = 13
100core.KEY_DELETE = 127
101

--- 313 unchanged lines hidden ---