new fork: carousel shell
Dependencies
- [2]
QW7YRY25Merge text0 - [3]
RKRBRQ4Ybugfix: render text in given fg color - [4]
JOPVPUSAediting source code from within the app - [5]
5DOC2CBMextract a function - [6]
XVR2O5PIchange text cursor shape - [7]
HALS7E5Umore clearly skip prints before screen top - [8]
I64IPGJXavoid saving fragments in lines - [9]
ULKLJBN6couple of renames - [10]
EQSFHYF3slightly standardize on app-specific stuff - [11]
Z4XRNDTRfind text - [12]
YJ6ASFBGyet another fork trying to integrate my live framework with everything else - [13]
RTDYYP4Hbugfix: text past cursor was rendered red on wrapped lines - [14]
AJB4LFRBtry to maintain a reasonable line width - [15]
2RXZ3PGObeginning of a new approach to scroll+wrap - [16]
5OVKHVY6nice way to make on.* handlers more discoverable - [17]
H2DPLWMVsnapshot: wrapping long lines at word boundaries - [18]
M7UODV5HMerge text0 - [19]
UBA2ZUCPremove a duplicate print to screen - [20]
3TFEAQSWstart using some globals - [*]
BULPIBEGbeginnings of a module for the text editor - [*]
V5SYDHPQstart thinking of compute_fragments as a detail - [*]
OTIBCAUJlove2d scaffold - [*]
36Z442IVback to commit 8123959e52f without code editing - [*]
3PSFWAILMerge lines.love - [*]
2L5MEZV3experiment: new edit namespace - [*]
4KC7I3E2make colors easier to edit - [*]
R5QXEHUIsomebody stop me
Change contents
- edit in text.lua at line 19
App.color(Line_number_color)love.graphics.print(line_index, State.left-Line_number_width*App.width('m')+10,y)if fg == nil theninitialize_color()end - replacement in text.lua at line 70
-- render fragmentApp.color(fg)App.screen.print(screen_line, State.left,y)-- render colorized textlocal x = State.leftfor frag in screen_line:gmatch('%S*%s*') doif fg thenApp.color(fg)elseselect_color(frag)endApp.screen.print(frag, x,y)x = x+App.width(frag)end - edit in main.lua at line 36
Line_number_width = 3 -- in ems - replacement in main.lua at line 69
love.window.setTitle('TODO')love.window.setTitle('Carousel Shell') - edit in main.lua at line 146
App.screen.width = love.window.fromPixels(App.screen.width)App.screen.height = love.window.fromPixels(App.screen.height) - edit in edit.lua at line 5
Line_number_color = {r=0.4, g=0.4, b=0.4} - edit in edit.lua at line 15
require 'colorize' - file addition: colorize.lua[29.2]
-- State transitions while colorizing a single line.-- Just for comments and strings.-- Limitation: each fragment gets a uniform color so we can only change color-- at word boundaries.Next_state = {normal={{prefix='--[[', target='block_comment'}, -- only single-line for now{prefix='--', target='comment'},-- these don't mostly work well until we can change color within words-- {prefix='"', target='dstring'},-- {prefix="'", target='sstring'},{prefix='[[', target='block_string'}, -- only single line for now},dstring={{suffix='"', target='normal'},},sstring={{suffix="'", target='normal'},},block_string={{suffix=']]', target='normal'},},block_comment={{suffix=']]', target='normal'},},-- comments are a sink}Comment_color = {r=0, g=0, b=1}String_color = {r=0, g=0.5, b=0.5}Divider_color = {r=0.7, g=0.7, b=0.7}Colors = {normal=Text_color,comment=Comment_color,sstring=String_color,dstring=String_color,block_string=String_color,block_comment=Comment_color,}Current_state = 'normal'function initialize_color()--? print('new line')Current_state = 'normal'endfunction select_color(frag)--? print('before', '^'..frag..'$', Current_state)switch_color_based_on_prefix(frag)--? print('using color', Current_state, Colors[Current_state])App.color(Colors[Current_state])switch_color_based_on_suffix(frag)--? print('state after suffix', Current_state)endfunction switch_color_based_on_prefix(frag)if Next_state[Current_state] == nil thenreturnendfrag = rtrim(frag)for _,edge in pairs(Next_state[Current_state]) doif edge.prefix and starts_with(frag, edge.prefix) thenCurrent_state = edge.targetbreakendendendfunction switch_color_based_on_suffix(frag)if Next_state[Current_state] == nil thenreturnendfrag = rtrim(frag)for _,edge in pairs(Next_state[Current_state]) doif edge.suffix and ends_with(frag, edge.suffix) thenCurrent_state = edge.targetbreakendendend - file addition: 0019-Line_number_padding[29.2]
Line_number_padding = 0 - file addition: 0017-on.mouse_release[29.2]
on.mouse_release = function(x,y, mouse_button)edit.mouse_release(Editor_state, x,y, mouse_button)end - file addition: 0016-on.mouse_press[29.2]
on.mouse_press = function(x,y, mouse_button)edit.mouse_press(Editor_state, x,y, mouse_button)end - file addition: 0015-on.key_release[29.2]
on.key_release = function(key, scancode)edit.key_release(Editor_state, key, scancode)end - file addition: 0014-on.text_input[29.2]
on.text_input = function(t)edit.text_input(Editor_state, t)end - file addition: 0013-on.keychord_press[29.2]
on.keychord_press = function(chord, key)edit.keychord_press(Editor_state, chord, key)end - file addition: 0012-on.draw[29.2]
on.draw = function()love.graphics.rectangle('line', 100-5-Line_number_padding,100-5, 400+10, 200+10, 5,5)edit.draw(Editor_state)end - file addition: 0011-on.initialize[29.2]
on.initialize = function()love.graphics.setFont(love.graphics.newFont(20))Line_height = math.floor(love.graphics.getFont():getHeight()*1.3)Line_number_padding = Line_number_width*App.width('m')Editor_state = edit.initialize_state(100, 100, 400, love.graphics.getFont():getHeight(), Line_height)Text.redraw_all(Editor_state)end - file addition: 0010-Line_height[29.2]
Line_height = 0 - file addition: 0009-Editor_state[29.2]
Editor_state = nil