Merge template-live-editor
This commit is contained in:
commit
164c6c4472
2
app.lua
2
app.lua
|
@ -202,7 +202,7 @@ function App.undo_initialize()
|
|||
end
|
||||
|
||||
function App.initialize_for_test()
|
||||
App.screen.init({width=100, height=50})
|
||||
App.screen.init{width=100, height=50}
|
||||
App.screen.contents = {} -- clear screen
|
||||
App.filesystem = {}
|
||||
App.fake_keys_pressed = {}
|
||||
|
|
35
reference.md
35
reference.md
|
@ -197,7 +197,7 @@ The text-editor widget includes extremely thorough automated tests to give you
|
|||
early warning if you break something.
|
||||
|
||||
* `state = edit.initialize_state(top, left, right, font_height, line_height)` --
|
||||
returns an object that can be used to render an interactive editor widgets
|
||||
returns an object that can be used to render an interactive editor widget
|
||||
for text starting at `y=top` on the app window, between `x=left` and
|
||||
`x=right`. Wraps long lines at word boundaries where possible, or in the
|
||||
middle of words (no hyphenation yet) when it must.
|
||||
|
@ -205,12 +205,12 @@ early warning if you break something.
|
|||
* `edit.quit()` -- calling this ensures any final edits are flushed to disk
|
||||
before the app exits.
|
||||
|
||||
* `edit.draw(state)` -- Call this from `on.draw` to display the current editor
|
||||
* `edit.draw(state)` -- call this from `on.draw` to display the current editor
|
||||
state on the app window as requested in the call to `edit.initialize_state`
|
||||
that created `state`.
|
||||
|
||||
* `edit.update(state, dt)` -- call this from `on.update` to periodically auto
|
||||
saves editor contents to disk.
|
||||
* `edit.update(state, dt)` -- call this from `on.update` to periodically
|
||||
auto-save editor contents to disk.
|
||||
|
||||
* `edit.mouse_press(state, x,y, mouse_button)` and `edit.mouse_release(x,y,
|
||||
mouse_button)` -- call these to position the cursor or select some text.
|
||||
|
@ -320,3 +320,30 @@ and [the Lua manual](https://www.lua.org/manual/5.1/manual.html#5.7).
|
|||
|
||||
There's much more I could include here; check out [the LÖVE manual](https://love2d.org/wiki)
|
||||
and [the Lua manual](https://www.lua.org/manual/5.1/manual.html).
|
||||
|
||||
### writing tests
|
||||
|
||||
* `App.screen.init{width=.., height=..}` -- creates a fake screen for a test
|
||||
|
||||
* `App.screen.check(y, expected_contents, msg)` -- verifies text written to
|
||||
the fake screen at `y`. This isn't very realistic; `y` must exactly match
|
||||
what was displayed, and the expected contents show everything printed to
|
||||
that `y` in chronological order, regardless of `x` coordinate. In spite of
|
||||
these limitations, you can write lots of useful tests with this.
|
||||
|
||||
* `App.run_after_textinput(t)` -- mimics keystrokes resulting in `t` and then
|
||||
draws one frame.
|
||||
|
||||
* `App.run_after_keychord(chord)` -- mimics keystrokes resulting in `chord`
|
||||
and then draws one frame.
|
||||
|
||||
* `App.run_after_mouse_press(x,y, mouse_button)` -- mimics a mouse press down
|
||||
followed by drawing a frame.
|
||||
|
||||
* `App.run_after_mouse_release(x,y, mouse_button)` -- mimics a mouse release
|
||||
up followed by drawing a frame.
|
||||
|
||||
* `App.run_after_mouse_click(x,y, mouse_button)` -- mimics a mouse press down
|
||||
and mouse release up followed by drawing a frame.
|
||||
|
||||
* `App.wait_fake_time(t)` -- simulates the passage of time for `App.getTime()`.
|
||||
|
|
Loading…
Reference in New Issue