Merge template-live-editor
This commit is contained in:
commit
c626f30585
3
edit.lua
3
edit.lua
|
@ -24,8 +24,7 @@ function edit.initialize_state(top, left, right, font, font_height, line_height)
|
|||
|
||||
-- rendering wrapped text lines needs some additional short-lived data per line:
|
||||
-- startpos, the index of data the line starts rendering from, can only be >1 for topmost line on screen
|
||||
-- fragments: snippets of the line guaranteed to not straddle screen lines
|
||||
-- screen_line_starting_pos: optional array of grapheme indices if it wraps over more than one screen line
|
||||
-- screen_line_starting_pos: optional array of codepoint indices if it wraps over more than one screen line
|
||||
line_cache = {},
|
||||
|
||||
-- Given wrapping, any potential location for the text cursor can be described in two ways:
|
||||
|
|
14
reference.md
14
reference.md
|
@ -48,7 +48,7 @@ two categories.
|
|||
* `on.resize(w,h)` -- called when you resize the app window. Provides new
|
||||
window dimensions in `w` and `h`. Don't bother updating `App.screen.width`
|
||||
and `App.screen.height`, that will happen automatically before calling
|
||||
`App.resize`.
|
||||
`on.resize`.
|
||||
(Based on [LÖVE](https://love2d.org/wiki/love.resize))
|
||||
|
||||
* `on.file_drop(file)` -- called when a file icon is dragged and dropped on
|
||||
|
@ -114,7 +114,7 @@ two categories.
|
|||
|
||||
* `on.text_input(t)` -- called when you press a key combination that yields
|
||||
(roughly) a printable character. For example, `shift` and `a` pressed
|
||||
together will call `App.textinput` with `A`.
|
||||
together will call `on.textinput` with `A`.
|
||||
(Based on [LÖVE](https://love2d.org/wiki/love.textinput).)
|
||||
|
||||
* `on.key_release(key)` -- called when you press a key on the keyboard.
|
||||
|
@ -286,9 +286,9 @@ clicked. It requires setting up 3 things:
|
|||
- a `state` table housing all buttons. Can be the same `state` variable the
|
||||
text-editor widget uses, but doesn't have to be.
|
||||
- specifying buttons to create in `state`. This must happen either directly
|
||||
or indirectly within `App.draw`.
|
||||
or indirectly within `on.draw`.
|
||||
- responding to clicks on buttons in `state`. This must happen either
|
||||
directly or indirectly within `App.mousepressed`.
|
||||
directly or indirectly within `on.mouse_press`.
|
||||
|
||||
The following facilities help set these things up:
|
||||
|
||||
|
@ -309,7 +309,7 @@ The following facilities help set these things up:
|
|||
})
|
||||
```
|
||||
|
||||
Call this either directly or indirectly from `App.draw`. It will assign a
|
||||
Call this either directly or indirectly from `on.draw`. It will assign a
|
||||
rectangle with the given dimensions and trigger the provided (zero-arg)
|
||||
`onpress1` callback when the primary mouse button is clicked within.
|
||||
It will also optionally paint the rectangle with the specified background
|
||||
|
@ -321,7 +321,7 @@ The following facilities help set these things up:
|
|||
|
||||
* `mouse_press_consumed_by_any_button(state, x,y, mouse_button)`
|
||||
|
||||
Call this either directly or indirectly from `App.mousepressed`. It will
|
||||
Call this either directly or indirectly from `on.mouse_press`. It will
|
||||
pass on a click to any button registered in `state`. It's also helpful to
|
||||
ensure clicks on a button don't have other effects, so I prefer the
|
||||
following boilerplate early in `mousepressed`:
|
||||
|
@ -339,7 +339,7 @@ The following facilities help set these things up:
|
|||
(Based on [LÖVE](https://love2d.org/wiki/love.mouse.setPosition).)
|
||||
|
||||
* `App.mouse_down(mouse_button)` -- returns `true` if the button
|
||||
`mouse_button` is pressed. See `App.mousepressed` for `mouse_button` codes.
|
||||
`mouse_button` is pressed. See `on.mouse_press` for `mouse_button` codes.
|
||||
(Based on [LÖVE](https://love2d.org/wiki/love.mouse.isDown).)
|
||||
|
||||
* `App.mouse_x()` -- returns the x coordinate of the current position of the
|
||||
|
|
Loading…
Reference in New Issue