core.lua (c6879c6c14eedbd060ba588a3129a6c60ebbe783) | core.lua (5beb5507121c66e9af38523735b3a6d94310d8a8) |
---|---|
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 --- 52 unchanged lines hidden (view full) --- 61 core.setACPI(true) 62 end 63 core.setSingleUser(default_single_user) 64 core.setVerbose(default_verbose) 65end 66 67 68-- Globals | 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 --- 52 unchanged lines hidden (view full) --- 61 core.setACPI(true) 62 end 63 core.setSingleUser(default_single_user) 64 core.setVerbose(default_verbose) 65end 66 67 68-- Globals |
69-- try_include will return the loaded module on success, or nil on failure. 70-- A message will also be printed on failure, with one exception: non-verbose 71-- loading will suppress 'module not found' errors. | 69-- try_include will return the loaded module on success, or false and the error 70-- message on failure. |
72function try_include(module) 73 local status, ret = pcall(require, module) 74 -- ret is the module if we succeeded. 75 if status then 76 return ret 77 end | 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 76 end |
78 -- Otherwise, ret is just a message; filter out ENOENT unless we're 79 -- doing a verbose load. As a consequence, try_include prior to loading 80 -- configuration will not display 'module not found'. All other errors 81 -- in loading will be printed. 82 if config.verbose or ret:match("^module .+ not found") == nil then 83 error(ret, 2) 84 end 85 return nil | 77 return false, ret |
86end 87 88-- Module exports 89-- Commonly appearing constants 90core.KEY_BACKSPACE = 8 91core.KEY_ENTER = 13 92core.KEY_DELETE = 127 93 --- 303 unchanged lines hidden --- | 78end 79 80-- Module exports 81-- Commonly appearing constants 82core.KEY_BACKSPACE = 8 83core.KEY_ENTER = 13 84core.KEY_DELETE = 127 85 --- 303 unchanged lines hidden --- |