Update docs

pull/3/head release/0.5.0-rc1
Iron-E 4 years ago
parent 596b7e8859
commit ab45ca248b
No known key found for this signature in database
GPG Key ID: 19B71B7B7B021D22

File diff suppressed because it is too large Load Diff

@ -6,6 +6,21 @@
local libmodal = require('libmodal/src')
--[[
/*
* MIRRORS
*/
--]]
libmodal.mode = {['enter'] = function(name, instruction, ...)
libmodal.Mode.new(name, instruction, ...):enter()
end}
libmodal.prompt = {['enter'] = function(name, instruction, ...)
libmodal.Prompt.new(name, instruction, ...):enter()
end}
--[[
/*
* PUBLICIZE MODULE

@ -36,22 +36,18 @@ local _winOpenOpts = {
local _metaPopup = classes.new({})
_metaPopup._buffer = nil
_metaPopup._inputChars = nil
_metaPopup.window = nil
---------------------------
--[[ SUMMARY:
* Close `self.window`
* Close `self._window`
* The `self` is inert after calling this.
]]
---------------------------
function _metaPopup:close()
api.nvim_win_close(self.window, false)
api.nvim_win_close(self._window, false)
self._buffer = nil
self._inputChars = nil
self.window = nil
self._window = nil
end
---------------------------------

@ -51,7 +51,7 @@ local _metaInputBytes = classes.new({
-----------------------------------------------
--[[ SUMMARY:
* Parse `self._mappings` and see if there is any command to execute.
* Parse `self.mappings` and see if there is any command to execute.
]]
-----------------------------------------------
function _metaMode:_checkInputForMapping()
@ -59,12 +59,12 @@ function _metaMode:_checkInputForMapping()
self._flushInputTimer:stop()
-- Append the latest input to the locally stored input history.
local inputBytes = self._inputBytes
local inputBytes = self.inputBytes
inputBytes[#inputBytes + 1] = self._input:nvimGet()
inputBytes[#inputBytes + 1] = self.input:nvimGet()
-- Get the command based on the users input.
local cmd = self._mappings:parseGet(inputBytes)
local cmd = self.mappings:parseGet(inputBytes)
-- Get the type of the command.
local commandType = type(cmd)
@ -127,7 +127,7 @@ function _metaMode:enter()
-- If there were errors, handle them.
if not noErrors then
utils.showError(modeResult)
utils.show_error(modeResult)
continueMode = false
else
continueMode = modeResult
@ -151,10 +151,10 @@ function _metaMode:_initMappings()
self._help = utils.Help.new(self._instruction, 'KEY MAP')
end
self._inputBytes = setmetatable({}, _metaInputBytes)
self.inputBytes = setmetatable({}, _metaInputBytes)
-- Build the parse tree.
self._mappings = collections.ParseTable.new(self._instruction)
self.mappings = collections.ParseTable.new(self._instruction)
-- Create a table for mode-specific data.
self._popups = collections.Stack.new()
@ -188,7 +188,7 @@ function _metaMode:_inputLoop()
end
-- Echo the indicator.
api.nvim_lecho(self._indicator)
api.nvim_lecho(self.indicator)
-- Capture input.
local userInput = api.nvim_input()
@ -199,7 +199,7 @@ function _metaMode:_inputLoop()
end
-- Set the global input variable to the new input.
self._input:nvimSet(userInput)
self.input:nvimSet(userInput)
-- Make sure that the user doesn't want to exit.
if not self._exit.supress
@ -222,7 +222,7 @@ end
function _metaMode:_tearDown()
if type(self._instruction) == globals.TYPE_TBL then
self._flushInputTimer:stop()
self._inputBytes = nil
self.inputBytes = nil
self._popups:pop():close()
end
@ -252,7 +252,7 @@ function Mode.new(name, instruction, ...)
local self = setmetatable(
{
['_exit'] = Vars.new('exit', name),
['_indicator'] = Indicator.mode(name),
['indicator'] = Indicator.mode(name),
['_input'] = Vars.new('input', name),
['_instruction'] = instruction,
['_name'] = name,

@ -51,16 +51,16 @@ function _metaPrompt:_inputLoop()
local userInput = ''
-- echo the highlighting
api.nvim_command('echohl ' .. self._indicator.hl)
api.nvim_command('echohl ' .. self.indicator.hl)
-- set the user input variable
if self._completions
then userInput =
api.nvim_call_function('libmodal#_inputWith', {
self._indicator.str, self._completions
self.indicator.str, self._completions
})
else userInput =
api.nvim_call_function('input', {self._indicator})
api.nvim_call_function('input', {self.indicator})
end
-- get the instruction for the mode.
@ -68,7 +68,7 @@ function _metaPrompt:_inputLoop()
-- determine what to do with the input
if string.len(userInput) > 0 then -- the user actually entered something
self._input:nvimSet(userInput)
self.input:nvimSet(userInput)
if type(instruction) == globals.TYPE_TBL then -- the instruction is a command table.
if instruction[userInput] then -- there is a defined command for the input.
api.nvim_command(instruction[userInput])
@ -100,7 +100,7 @@ function _metaPrompt:enter()
-- if there were errors.
if not noErrors then
utils.showError(promptResult)
utils.show_error(promptResult)
continueMode = false
else
continueMode = promptResult

@ -6,27 +6,13 @@
local libmodal = {}
libmodal.classes = require('libmodal/src/classes')
libmodal.collection = require('libmodal/src/collections')
libmodal.globals = require('libmodal/src/globals')
libmodal.Indicator = require('libmodal/src/Indicator')
libmodal.Mode = require('libmodal/src/Mode')
libmodal.Prompt = require('libmodal/src/Prompt')
libmodal.utils = require('libmodal/src/utils')
--[[
/*
* MIRRORS
*/
--]]
libmodal.mode = {['enter'] = function(name, instruction, ...)
libmodal.Mode.new(name, instruction, ...):enter()
end}
libmodal.prompt = {['enter'] = function(name, instruction, ...)
libmodal.Prompt.new(name, instruction, ...):enter()
end}
libmodal.classes = require('libmodal/src/classes')
libmodal.collections = require('libmodal/src/collections')
libmodal.globals = require('libmodal/src/globals')
libmodal.Indicator = require('libmodal/src/Indicator')
libmodal.Mode = require('libmodal/src/Mode')
libmodal.Prompt = require('libmodal/src/Prompt')
libmodal.utils = require('libmodal/src/utils')
--[[
/*

@ -29,10 +29,10 @@ utils.WindowState = require('libmodal/src/utils/WindowState')
* Show an error from `pcall()`.
]]
--[[ PARAMS:
`pcallErr` => the error generated by `pcall()`.
`pcall_err` => the error generated by `pcall()`.
]]
----------------------------------
function utils.showError(pcallErr)
function utils.show_error(pcall_err)
utils.api.nvim_bell()
utils.api.nvim_show_err(
globals.DEFAULT_ERROR_TITLE,
@ -40,7 +40,7 @@ function utils.showError(pcallErr)
.. '\n' ..
api.nvim_get_vvar('exception')
.. '\n' ..
tostring(pcallErr)
tostring(pcall_err)
)
end

Loading…
Cancel
Save