- Offizieller Beitrag
Einige Editor-Funktionen basieren auf dem Wert der aktuellen Cursorposition. Man muss dann immer auf dieser Basis andere Funktionen aufrufen.
Ich habe das mal in eine Funktionsgruppe integriert um etwas übersichtlicher und direkter die gewünschten Parameter abzufragen. Evtl. ist das auch für euch interessant.
Python
EdPos = {
pos = function(self)
return editor.CurrentPos
end, -- current position
linenum = function(self, _pos)
return editor:LineFromPosition(_pos or self:pos())
end, -- linenum from current (default) or passed position
line = function(self, _linenum)
return editor:GetLine(_linenum or self:linenum())
end, -- contents of a line and the length of the line from current (default) or passed line
home = function(self, _linenum)
return editor:PositionFromLine(_linenum or self:linenum())
end, -- home position from current (default) or passed line
asc = function(self, _pos)
return editor.CharAt[_pos or self:pos()]
end, -- ascii value from character on current (default) or passed position
chr = function(self, _pos)
return string.char(self:asc(_pos))
end, -- character on current (default) or passed position
column = function(self, _pos)
return editor.Column[_pos or self:pos()]
end, -- column in line from current (default) or passed position
style = function(self, _pos)
return editor.StyleAt[_pos or self:pos()]
end -- style on current (default) or passed position
}
print('pos', EdPos:pos())
print('linenum',EdPos:linenum())
print('line', EdPos:line())
print('home', EdPos:home())
print('asc', EdPos:asc())
print('chr', EdPos:chr())
print('column', EdPos:column())
print('style', EdPos:style())
Alles anzeigen