Merge text0

[?]
Apr 10, 2023, 4:03 AM
THJX6RCJEMADQ3O6UOXA5DMGVGHMVKZHG4U7IUEV5E75FC3XRHXQC

Dependencies

  • [2] JNJ4R56X support running tests multiple times
  • [3] N2NUGNN4 include a brief reference enabling many useful apps
  • [4] HLIF3YQE Merge text0
  • [*] 3QNOKBFM beginnings of a test harness

Change contents

  • replacement in reference.md at line 1
    [3.17][3.18:48]()
    # Some useful building blocks
    [3.17]
    [3.48]
    # Building blocks for your Freewheeling Apps
    Freewheeling apps consist of 4 kinds of things:
    - a small number of functions you can define that get automatically called
    for you as appropriate,
    - a wide variety of primitives that you can call but not modify,
    - tests that start with `test_` and run on startup or after any change you
    make to the app's code, and
    - any other function you can define and call at will.
  • replacement in reference.md at line 11
    [3.49][3.49:235]()
    Apps can be composed of a wide variety of building blocks that you
    can use in your functions, including a small number of functions that get
    automatically called for you as appropriate.
    [3.49]
    [3.235]
    The rest of this document will summarize what is available to you in the first
    two categories.
  • replacement in reference.md at line 21
    [3.509][3.509:948]()
    ## Functions that get automatically called
    * `App.initialize_globals()` -- called before running each test and also
    before the app starts up. As the name suggests, use this to initialize all
    your global variables to something consistent. I also find it useful to be
    able to see all my global variables in one place, and avoid defining
    top-level variables anywhere else (unless they're constants and never going
    to be modified).
    [3.509]
    [3.948]
    ## Functions you can implement that will get automatically called
  • replacement in reference.md at line 23
    [3.949][3.949:1121]()
    * `App.initialize(arg)` -- called when app starts up after
    `App.initialize_globals`. Provides in `arg` an array of words typed in if
    you ran it from a terminal window.
    [3.949]
    [3.1121]
    * `on.initialize(arg)` -- called when app starts up. Provides in `arg` an
    array of words typed in if you ran it from a terminal window.
  • replacement in reference.md at line 27
    [3.1179][3.1179:1231]()
    * `App.quit()` -- called before the app shuts down.
    [3.1179]
    [3.1231]
    * `on.quit()` -- called before the app shuts down.
  • replacement in reference.md at line 30
    [3.1289][3.1289:1360]()
    * `App.focus(start?)` -- called when the app starts or stops receiving
    [3.1289]
    [3.1360]
    * `on.save_settings()` -- called after on.quit and should return a table which
    will be saved to disk.
    * `on.load_settings(settings)` -- called when app starts up, before
    `on.initialize`. Provides in `settings` the table that was saved to disk the
    last time the app shut down.
    * `on.focus(start?)` -- called when the app starts or stops receiving
  • replacement in reference.md at line 42
    [3.1548][3.1548:1623]()
    * `App.resize(w,h)` -- called when you resize the app window. Provides new
    [3.1548]
    [3.1623]
    * `on.resize(w,h)` -- called when you resize the app window. Provides new
  • replacement in reference.md at line 48
    [3.1847][3.1847:1926]()
    * `App.filedropped(file)` -- called when a file icon is dragged and dropped on
    [3.1847]
    [3.1926]
    * `on.file_drop(file)` -- called when a file icon is dragged and dropped on
  • replacement in reference.md at line 57
    [3.2252][3.2252:2326]()
    * `App.draw()` -- called to draw on the window, around 30 times a second.
    [3.2252]
    [3.2326]
    * `on.code_change()` -- called when you make changes to the app using
    [driver.love](https://git.sr.ht/~akkartik/driver.love), any time you hit
    `f4` inside driver.love, after a definition is created or modified.
    * `on.draw()` -- called to draw on the window, around 30 times a second.
  • replacement in reference.md at line 64
    [3.2384][3.2384:2460]()
    * `App.update(dt)` -- called after every call to `on.draw`. Make changes to
    [3.2384]
    [3.2460]
    * `on.update(dt)` -- called after every call to `on.draw`. Make changes to
  • replacement in reference.md at line 70
    [3.2699][3.2699:2936]()
    * `App.mousepressed(x,y, mouse_button)` -- called when you press down on a
    mouse button. Provides in `x` and `y` the point on the screen at which the
    click occurred, and in `mouse_button` an integer id of the mouse button
    pressed.
    [3.2699]
    [3.2936]
    * `on.mouse_press(x,y, mouse_button)` -- called when you press down on a mouse
    button. Provides in `x` and `y` the point on the screen at which the click
    occurred, and in `mouse_button` an integer id of the mouse button pressed.
  • replacement in reference.md at line 78
    [3.3222][3.3222:3298]()
    * `App.mousereleased(x,y, mouse_button)` -- called when you release a mouse
    [3.3222]
    [3.3298]
    * `on.mouse_release(x,y, mouse_button)` -- called when you release a mouse
  • replacement in reference.md at line 82
    [3.3432][3.3432:3717]()
    * `App.wheelmoved(dx,dy)` -- called when you use the scroll wheel on a mouse
    that has it. Provides in `dx` and `dy` an indication of how fast the wheel
    is being scrolled. Positive values for `dx` indicate movement to the right.
    Positive values for `dy` indicate upward movement.
    [3.3432]
    [3.3717]
    * `on.mouse_wheel_move(dx,dy)` -- called when you use the scroll wheel on a
    mouse that has it. Provides in `dx` and `dy` an indication of how fast the
    wheel is being scrolled. Positive values for `dx` indicate movement to the
    right. Positive values for `dy` indicate upward movement.
  • replacement in reference.md at line 88
    [3.3781][3.3781:3860]()
    * `App.keychord_press(chord, key)` -- called when you press a key-combination.
    [3.3781]
    [3.3860]
    * `on.keychord_press(chord, key)` -- called when you press a key-combination.
  • replacement in reference.md at line 98
    [3.4326][3.4326:4402]()
    * `App.textinput(t)` -- called when you press a key combination that yields
    [3.4326]
    [3.4402]
    * `on.text_input(t)` -- called when you press a key combination that yields
  • replacement in reference.md at line 103
    [3.4583][3.4583:4655]()
    * `App.keyrelease(key)` -- called when you press a key on the keyboard.
    [3.4583]
    [3.4655]
    * `on.key_release(key)` -- called when you press a key on the keyboard.
  • edit in app.lua at line 56
    [2.1247][2.1247:1286]()
    App.screen.draw = love.graphics.draw