Edit.lines read/write property iterable


Returns a proxy table to get/set the lines of text in the Edit.
You can use this proxy table this way :

  • Edit.lines[line_number] : gets or sets the line at index line_number. The line index start from 1 and grows until the last line of text.
  • #Edit.lines : gets the line count of the Edit.
  • You can use each(Edit.lines) or ipairs(Edit.lines) to iterate through each line of the Edit text.
Edit.lines is a proxy table and should not be used for anything other than setting/getting lines.

Example

local ui = require "ui" -- create a simple window local win = ui.Window("Edit.lines sample", "fixed", 520, 206) local edit = ui.Edit(win, "", 10, 10, 500, 150) ui.Button(win, "Fade text !", 230, 170).onClick = function (self) local color = 0x505050 for i, line in ipairs(edit.lines) do edit.line = i edit.selection.to = edit.selection.from + #line edit.selection.fgcolor = color color = color + 0x303030 end edit.caret = 1 end -- set edit.properties edit.font = "Times New Roman" edit.fontsize = 12 edit.text = [[Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.]] edit.caret = 1 win:show() -- update user interface repeat ui.update() until not win.visible