Hallo BugFix,
da habe ich wohl etwas gepennt :D.
Aber es funktioniert noch nicht ganz.
In meiner "SciTEUser.properties"-Datei steht nun das hier:
Spoiler anzeigen
ContinuousComment.LFpos.*.au3=170
ContinuousComment.Chars.*.au3=;
ContinuousComment.BreakCharsLast.*.au3=˜ ˜ ›
ContinuousComment.BreakCharsNext.*.au3=›
ContinuousComment.NewLine.WithEnter.Enable.*.au3=1
# 36 Comment Continuous
command.name.36.*=Activate Comment Mode
command.36.*=CommentModeActivate
command.mode.36.*=subsystem:lua,savebefore:no
command.shortcut.36.*=Ctrl+Shift+K
Alles anzeigen
Und in der Script-Datei steht nun das:
Spoiler anzeigen
CommentHitKey = EventClass:new(Common)
local ext = props['FileExt']
local lfPos = tonumber(props['ContinuousComment.LFpos.*.' .. ext])
local charComm = props['ContinuousComment.Chars.*.' .. ext]..' '
local charBreak1 = props['ContinuousComment.BreakCharsLast.*.' .. ext]
local charBreak2 = props['ContinuousComment.BreakCharsNext.*.' .. ext]
local fNewLine = false
if tonumber(props['ContinuousComment.NewLine.WithEnter.Enable.*.' .. ext]) == 1 then fNewLine = true end
local fCommentModeOn, fNext, fIsNewLine, fIsEnter = false, false, false, false
local lastLine, column, col
local getSpaces = function()
col = editor.Column[editor.CurrentPos]
local s = ''
if col < column then
s = string.rep(' ', column - col)
end
return s
end
local isLFpos = function()
local pos = editor.Column[editor.CurrentPos]
if pos >= lfPos then
return true
else
return false
end
end
local ContinuousComment = function()
local autoBreak, w = '', ''
if not fIsNewLine then
local pos = editor.Column[editor.CurrentPos]
if pos > lfPos then
editor:WordLeftExtend()
w = editor:GetSelText()
editor:ReplaceSel('')
end
editor:GotoLine(editor:LineFromPosition(editor.CurrentPos) +1)
if charBreak2:len() > 0 then autoBreak = charBreak2..' ' end
else
fIsNewLine = false
end
local strAdd = ' '
editor:LineEnd()
strAdd = getSpaces() or strAdd
editor:InsertText(editor.CurrentPos, strAdd..charComm..autoBreak..w)
editor:LineEnd()
end
function CommentHitKey:OnKey(_keycode, _shift)
local Keycode = _keycode or nil -- Sinnfrei, nur zum Abbremsen <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
if fCommentModeOn then -- fortsetzender Kommentarmodus ist aktiv
local fBreak = isLFpos()
if fIsEnter then
fIsEnter = false
local s, e = getSpaces(), ''
if charBreak2:len() > 0 then e = charBreak2..' ' end
editor:InsertText(editor.CurrentPos, s..charComm..e)
editor:LineEnd()
end
if _keycode == 13 then
fIsEnter = true
editor:InsertText(editor.CurrentPos, ' '..charBreak1)
editor:LineEnd()
elseif _keycode == 32 and fBreak then -- Leerzeichen u. Position für Zeilenwechsel erreicht (automatischer Zeilenwechsel)
fNext = true -- Marker neue Zeile
elseif _keycode == 40 then -- Pfeil_ab (manueller Zeilenwechsel)
fNext = true fIsNewLine = true -- Marker neue Zeile und Marker in-neuer-Zeile
elseif fNext then -- in neuer Zeile ==> Kommentarzeichen einfügen
fNext = false
if not fIsNewLine then -- bei automatischem Wechsel (wenn in den properties ein Umbruchsymbol definiert):
editor:InsertText(editor.CurrentPos, charBreak1) -- am Ende Umbruchsymbol aus den properties anhängen
end
ContinuousComment()
end
end
return nil
end
function CommentModeActivate()
if not fCommentModeOn then
editor:LineEnd()
column = editor.Column[editor.CurrentPos]
editor.Cursor = 8 -- Cursor wechseln (Hand)
editor:InsertText(editor.CurrentPos, charComm)
editor:LineEnd()
else
editor.Cursor = -1 -- Cursor zurück auf Standard
end
fCommentModeOn = not fCommentModeOn
end
Alles anzeigen
Nun habe ich folgendes Verhalten:
Der Kommentarmodus lässt sich nun mit dem Hotkey ein- und ausschalten.
(nach dem ausschalten sollte der Cursor aber in der folgenden Zeile stehen, jetzt muss man immer zuerst ausschalten und dann erst Enter betätigen).
Ein automatischer Zeilenwechsel findet jedoch nicht statt.
Mit der Enter-Taste kann ich eine neue Kommentarzeile, mit den vorgegebenen Zeichen, beginnen.
Aber wenn ich einen Manuellen Zeilenwechsel mit der Pfeilab-Taste erzeugen will, geschieht entweder das hier:
; gggggggggggggggggggg
ggggggggggggggg
oder es geschieht das:
; gggggggggggggggggggg; gggggggggggggggggggg; gggggggggggggggggggg
Das macht die Funktion wie sie will.
Dabei ist es egal ob man dies hier:
local Keycode = _keycode or nil -- Sinnfrei, nur zum Abbremsen <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
ins Script einfügt oder nicht.
Da ist wohl noch etwas anderes falsch.
MfG:
BigRox
Edit BugFix: Leerzeilen gekillt und Tags gesetzt.