It was developed as a focused exploration and is currently on hold. The code is functional in parts but incomplete and not intended for production use.
The repository remains public for learning, reference, and experimentation purposes.
A simple lightweight component to render and edit multi-line text in a flexible way.
The textBox automatically adjusts its height to the number of lines, mimicking a flexBox-style behavior.
Designed to be modular, easily extendable, and fully integrated with Löve2D and Lua.
Paused — last active development: December 2025.
Main unresolved topic:
- character deletion cascading across lines while respecting jump boundaries
- Multi-line editable text
- Automatic line wrapping on spaces (wrap-on-word)
- Dynamic height adjustment (like a FlexBox)
- Basic cursor movement and blinking
- Mouse-based positioning of the cursor
- Support for
backspace,deleteandenter - Placeholder text if input is empty
- Lightweight and dependency-free (apart from
classic.lua)
Coming soon:
- Hard-wrap on long words (with custom hyphenation logic)
- Word-aware cursor movement (e.g., ctrl+arrow)
- Selection / copy-paste support
textBox.lua: Main componentlineManager.lua: Line-level logic (insertion, deletion, wrapping)main.lua: Simple usage example withlove.load,love.draw,love.update, etc.
local TextBox = require("textBox")
local textBox = TextBox(50, 50, 300, 30) -- x, y, width, lineHeight
function love.load()
textBox.focused = true
end
function love.update(dt)
textBox:update(dt)
end
function love.draw()
textBox:draw()
end
function love.keypressed(key)
textBox:keypressed(key)
end
function love.textinput(t)
local LineManager = require("lineManager")
LineManager.addToLines(t, textBox)
textBox:setCanvas()
end
function love.mousepressed(mx, my, button)
textBox:mousepressed(mx, my, button)
end- The text is stored in a
linesarray. - Each insertion or deletion triggers a check for whether the line needs to wrap.
- Wrapping currently works only on spaces (not in the middle of a word).
- Cursor position is tracked with a
lineandcolindex. LineManageris responsible for splitting/merging lines and adjusting cursor.
Custom hard-wrap (cutting a word) is not yet implemented but will use a rule-based hyphenation system (e.g., only inserting a special character like —, to allow safe undo).
Copyleft © 2025 Franz Bonaparta (aka Jojopov) Released under the GNU GPLv3 or later. See https://www.gnu.org/licenses/ for full terms.
This project is part of the TurtleTech collection: A suite of small, Lua-based UI and game components built with a hacker/maker mindset.
Feel free to fork, contribute, or repurpose the component in your Löve2D projects.
“Write here… then write your own world.”
8
8 eeeee e eeeee eeeee eeeee ee e
8e 8 88 8 8 88 8 8 8 88 88 8
88 8 8 8e 8 8 8eee8 8 8 88 e8
e 88 8 8 e 88 8 8 88 8 8 8 8
8eee88 8eee8 8ee88 8eee8 88 8eee8 8ee8
🐢 TurtleTech · Crafted in Lua 🍕