11-- Copyright 2014-2023 Mitchell. See LICENSE.
22
3- ---
4- -- A Textadept module for loading an interactive Lua REPL using the editor's Lua State, similar
3+ --- A Textadept module for loading an interactive Lua REPL using the editor's Lua State, similar
54-- to Lua's interactive REPL.
65--
76-- This is an alternative to the single-line Lua command entry.
@@ -22,10 +21,10 @@ local M = {}
2221-- Localizations.
2322if not rawget (_L , ' Lua REPL' ) then _L [' Lua REPL' ] = ' L_ua REPL' end
2423
25- -- A special environment for a Lua REPL.
24+ --- A special environment for a Lua REPL.
2625-- It has an `__index` metafield for accessing Textadept's global environment.
27- -- @class table
28- -- @name env
26+ -- @table env
27+ -- @local
2928local env = setmetatable ({
3029 print = function (...)
3130 buffer :add_text (' --> ' )
@@ -38,13 +37,11 @@ local env = setmetatable({
3837 end
3938}, {__index = _G })
4039
41- ---
42- -- Lua command history.
40+ --- Lua command history.
4341-- It has a numeric `pos` field that indicates where in the history the user currently is.
4442M .history = {pos = 0 }
4543
46- ---
47- -- Evaluates as Lua code the current line or the text on the currently selected lines.
44+ --- Evaluates as Lua code the current line or the text on the currently selected lines.
4845-- If the current line has a syntax error, it is ignored and treated as a line continuation.
4946function M .evaluate_repl ()
5047 local s , e = buffer .selection_start , buffer .selection_end
@@ -161,8 +158,7 @@ M.keys = {
161158 [' ctrl+n' ] = M .cycle_history_next
162159}
163160
164- -- Cannot initially define keys in `keys.lua` because that table does not exist yet and will
165- -- be overwritten by the Lua language module. Instead, define keys here.
161+ --- Register REPL keys.
166162local function register_keys ()
167163 if not keys .lua [next (M .keys )] then
168164 for key , f in pairs (M .keys ) do
@@ -175,8 +171,7 @@ local function register_keys()
175171end
176172events .connect (events .RESET_AFTER , register_keys )
177173
178- ---
179- -- Creates or switches to a Lua REPL.
174+ --- Creates or switches to a Lua REPL.
180175-- If *new* is `true`, creates a new REPL even if one already exists.
181176-- @param new Flag that indicates whether or not to create a new REPL even if one already exists.
182177function M .open (new )
0 commit comments