120120-- ------------------------------------------------
121121
122122---
123- -- If there was a change of screen, change it immediatly
123+ -- This function is used internally by the ScreenManager library.
124+ -- It performs all changes that have been added to the changes queue (FIFO) and
125+ -- resets the queue afterwards.
126+ -- @see push, pop, switch
124127--
125128function ScreenManager .performChanges ()
126129 if # changes == 0 then
@@ -142,15 +145,19 @@ function ScreenManager.performChanges()
142145end
143146
144147---
145- -- Initialise the ScreenManager.
146- -- Sets up the ScreenManager and pushes the first screen.
147- -- @param nscreens (table) A table containing pointers to the different screen
148- -- classes. The keys will are used to call a specific
149- -- screen.
150- -- @param screen (string) The key of the first screen to push to the stack.
151- -- Use the key under which the screen in question is
152- -- stored in the nscreens table.
153- -- @param ... (vararg) One or multiple arguments passed to the new screen.
148+ -- Initialises the ScreenManager library.
149+ -- It sets up the stack table, the list of screens to use and then proceeds with
150+ -- validating and switching to the initial screen.
151+ -- @tparam table nscreens
152+ -- A table containing pointers to the different screen classes.
153+ -- The keys will are used to call a specific screen.
154+ -- @tparam string screen
155+ -- The key of the first screen to push to the stack. Use the
156+ -- key under which the screen in question is stored in the
157+ -- nscreens table.
158+ -- @tparam [opt] vararg ...
159+ -- Aditional arguments which will be passed to the new
160+ -- screen's init function.
154161--
155162function ScreenManager .init ( nscreens , screen , ... )
156163 stack = {}
166173-- Switches to a screen.
167174-- Removes all screens from the stack, creates a new screen and switches to it.
168175-- Use this if you don't want to stack onto other screens.
169- -- @param screen (string) The key of the screen to switch to.
170- -- @param ... (vararg) One or multiple arguments passed to the new screen.
176+ -- @tparam string screen
177+ -- The key of the screen to switch to.
178+ -- @tparam [opt] vararg ...
179+ -- One or multiple arguments passed to the new screen's init
180+ -- function.
171181--
172182function ScreenManager .switch ( screen , ... )
173183 validateScreen ( screen )
@@ -177,11 +187,13 @@ end
177187
178188---
179189-- Pushes a new screen to the stack.
180- -- Creates a new screen and pushes it on the screen stack, where it will overlay
181- -- the other screens below it. Screens below the this new screen will be set
182- -- inactive.
183- -- @param screen (string) The key of the screen to push to the stack.
184- -- @param ... (vararg) One or multiple arguments passed to the new screen.
190+ -- Creates a new screen and pushes it onto the stack, where it will overlay the
191+ -- other screens below it. Screens below this new screen will be set inactive.
192+ -- @tparam string screen
193+ -- The key of the screen to push to the stack.
194+ -- @tparam [opt] vararg ...
195+ -- One or multiple arguments passed to the new screen's init
196+ -- function.
185197--
186198function ScreenManager .push ( screen , ... )
187199 validateScreen ( screen )
@@ -191,14 +203,16 @@ end
191203
192204---
193205-- Returns the screen on top of the screen stack without removing it.
194- -- @return (table) The screen on top of the stack.
206+ -- @treturn table
207+ -- The screen on top of the stack.
195208--
196209function ScreenManager .peek ()
197210 return stack [# stack ]
198211end
199212
200213---
201214-- Removes the topmost screen of the stack.
215+ -- @raise Throws an error if the screen to pop is the last one on the stack.
202216--
203217function ScreenManager .pop ()
204218 if height > 1 then
0 commit comments