2024-05-04 18:55:52 +00:00
|
|
|
-- Copyright (C) 2024 - 2024:
|
|
|
|
-- The Trinitrix Project <bpeetz@b-peetz.de, antifallobst@systemausfall.org>
|
|
|
|
-- SPDX-License-Identifier: MIT
|
|
|
|
--
|
|
|
|
-- This file is part of Trinitrix.
|
|
|
|
--
|
|
|
|
-- Permission is hereby granted, free of charge, to any person
|
|
|
|
-- obtaining a copy of this software and associated documentation files
|
|
|
|
-- (the “Software”), to deal in the Software without restriction,
|
|
|
|
-- including without limitation the rights to use, copy, modify, merge,
|
|
|
|
-- publish, distribute, sublicense, and/or sell copies of the Software,
|
|
|
|
-- and to permit persons to whom the Software is furnished to do so,
|
|
|
|
-- subject to the following conditions:
|
|
|
|
--
|
|
|
|
-- The above copyright notice and this permission notice shall be
|
|
|
|
-- included in all copies or substantial portions of the Software.
|
|
|
|
--
|
|
|
|
-- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
|
|
-- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
-- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
|
|
-- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
-- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
-- OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2024-05-04 18:44:20 +00:00
|
|
|
-- FIXME(@soispha): The code here has been deprecated, update it when trixy supports lua <2024-05-03>
|
|
|
|
|
2023-10-18 21:03:16 +00:00
|
|
|
-- create the required tables under `std`
|
2023-12-16 10:46:10 +00:00
|
|
|
trinitrix.std = { keymaps = {} };
|
2023-10-18 21:03:16 +00:00
|
|
|
|
2023-10-16 12:04:03 +00:00
|
|
|
--- Add a new keymap. This is just a convenience function which registers the function
|
2023-10-18 21:03:16 +00:00
|
|
|
--- and at the same time deals with the fact that the whole trinitrix api is async.
|
2023-10-16 12:04:03 +00:00
|
|
|
---@param mode string
|
|
|
|
---@param key string
|
|
|
|
---@param callback function
|
|
|
|
trinitrix.std.keymaps.add = function(mode, key, callback)
|
|
|
|
local callback_key = trinitrix.api.register_function(function()
|
|
|
|
local co = coroutine.create(callback)
|
|
|
|
while coroutine.status(co) ~= "dead" do
|
|
|
|
coroutine.resume(co)
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
trinitrix.api.keymaps.add(mode, key, callback_key)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trinitrix.std.keymaps.add("ci", "<ESC>", trinitrix.api.ui.set_mode_normal)
|
|
|
|
|
|
|
|
trinitrix.std.keymaps.add("n", ":", trinitrix.api.ui.command_line_show)
|
|
|
|
trinitrix.std.keymaps.add("n", "i", trinitrix.api.ui.set_mode_insert)
|
2023-10-19 18:04:27 +00:00
|
|
|
trinitrix.std.keymaps.add("n", "<TAB>", trinitrix.api.ui.cycle_planes)
|
2023-10-16 12:04:03 +00:00
|
|
|
|
|
|
|
-- a simple test to prove that key chords work
|
2023-10-18 21:10:44 +00:00
|
|
|
trinitrix.std.keymaps.add("ni", "jj", function() print("hi") end)
|
2023-10-16 12:04:03 +00:00
|
|
|
|
|
|
|
trinitrix.std.keymaps.add("n", "q", trinitrix.api.exit)
|
2023-12-16 10:46:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- Help people
|
|
|
|
trinitrix.std.keymaps.add("n", "<C-c>", function() print("To exit trinitrix use 'trinitrix.api.exit()' instead!") end)
|