-- TIME_STAMP 2012-02-18 00:14:04 v 0.2 --[[ FUNCTION: Continuous Comment Mode ---------------------------------------------------------------------------------------------------------------------------------- DESCRIPTION The function is activated using a hotkey. If the mode is active, the cursor appears as a hand. At the current cursor position will inserted chars from properties ('ContinuousComment.Chars.*.au3') e.g. "; ==". AUTO BRAKE: In properties 'ContinuousComment.LFpos.*.au3' is determinate at which position should skip to next line. It's triggered by press key and position is greater than or equal to position from properties. So you can continuous write comments and if the breakpoint is reached - automatically jumps the cursor to next line and inserts command-char at the same position like in line before. If length of code in next line greather than the comment start position before, the comment in this line starts behind the code. Optional, contiguous comment with automatic line breaks are marked by additional break character. If the last word in line overrides the breakposition, this word will moved to next line. MANUALLY BRAKE: You can manually skip to next line by press key . To appear in the next line no comment can turn "down arrow" to the next line to be changed (in the current row will be no comment character set). In addition, a manual break can generated with simultaneous insertion of a blank line by hit the key. Markers are set, as with a manual break. The comment is continued at the same position like before. Stops the continuous-comment mode again with the hotkey, which is also used for launch. The cursor is reset. ---------------------------------------------------------------------------------------------------------------------------------- INSTALLATION Rename the attached file to "ContinuousCommentsRu.lua". Save the script "ContinuousCommentsRu.lua" to folder "..\SciTE-RU\tools\". entries in "SciTEUser.properties": ContinuousComment.LFpos.*.au3=170 <== line position for automatically line break ContinuousComment.Chars.*.au3=; <== Character(s) that begins each comment line ContinuousComment.BreakCharsLast.*.au3=˜ ˜ › <== [optional] Character(s) at line end on rows with automatically line break ContinuousComment.BreakCharsNext.*.au3=› <== [optional] Character(s) at next line on rows with automatically line break (in front of your text) ContinuousComment.NewLine.WithEnter.Enable.*.au3' <== insert new line (with comment at same position) by hit ENTER in comment mode (=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 <== desired hotkey entrie in "..\SciTE-RU\tools\SciTEStartup.lua" dofile (props["SciteDefaultHome"].."\\tools\\ContinuousCommentsRu.lua") <== at the end of the file !! ---------------------------------------------------------------------------------------------------------------------------------- ]] --[[ FUNKTION: Kontinuierlicher Kommentar Modus ---------------------------------------------------------------------------------------------------------------------------------- BESCHREIBUNG Per Hotkey wird die Funktion aktiviert. Dabei wird an der aktuellen Cursorposition die in den properties ('ContinuousComment.Chars.*.au3') festgelegte Zeichenfolge gesetzt (z.B. "; =="). AUTO UMBRUCH: In den properties 'ContinuousComment.LFpos.*.au3' wird festgelegt an welcher Spaltenposition ein automatischer Wechsel auf die nächste Zeile erfolgen soll (Trigger: Leerzeichen an Position gleich od. größer Spaltenangabe aus den properties). Man kann also einfach fortlaufend seinen Kommentar schreiben und er wird automatisch in der Folgezeile hinter dem Code, an derselben Spaltenposition wie in der vorigen Zeile, fortgesetzt. Ist der Code in der Folgezeile länger, beginnt der Kommentar erst dahinter. Überschreitet der Code die Umbruchposition, so wird das letzte Wort mit in die neue Zeile übernommen MANUELLER UMBRUCH: Manuell kann jeder Zeit mit "Pfeil ab" auf die Folgezeile gewechselt werden. Soll in der Folgezeile kein Kommentar erscheinen, kann wiederum mit "Pfeil ab" zur nächsten Zeile gewechselt werden (in der momentanen Zeile wird dann kein Kommentarzeichen gesetzt). Ausserdem kann mit ein manueller Umbruch erzeugt werden mit gleichzeitigem Einfügen einer Leerzeile. Dabei wird die Umbruchmarkierung (sofern in den properties festgelegt) genau wie beim manuellen Umbruch erzeugt. Der Kommentar wird wiederum spaltengenau fortgesetzt. Beendet wird der Kontinuierliche-Kommentar-Modus wiederum mit dem Hotkey, das auch zum Start verwendet wird. ---------------------------------------------------------------------------------------------------------------------------------- INSTALLATION Das Skript "ContinuousCommentsRu.lua" im Ordner "..\SciTE-RU\tools\" speichern. Einträge in "SciTEUser.properties": ContinuousComment.LFpos.*.au3=150 <== gewünschte Position für automatischen Zeilenwechsel beim Kommentar schreiben ContinuousComment.Chars.*.au3=; <== Zeichenfolge mit der jede Kommentarzeile beginnt (Leerzeichen wird automatisch angefügt) ContinuousComment.BreakCharsLast.*.au3=˜ ˜ › <== [optional] Zeichen am Zeilenende bei automatischem Umbruch ContinuousComment.BreakCharsNext.*.au3=› <== [optional] Zeichen am Anfang der Folgezeile bei automatischem Umbruch ContinuousComment.NewLine.WithEnter.Enable.*.au3' <== neue Zeile (mit Kommentar an derselben Position) einfügen mit Enter im Kommentar-Modus (=1) # 36 Comment Continuous command.name.36.*=Kommentarmodus aktivieren command.36.*=CommentModeActivate command.mode.36.*=subsystem:lua,savebefore:no command.shortcut.36.*=Ctrl+Shift+K <== gewünschter Hotkey Eintrag in "..\SciTE-RU\tools\SciTEStartup.lua" dofile (props["SciteDefaultHome"].."\\tools\\ContinuousCommentsRu.lua") <== Am Dateiende anfügen! ---------------------------------------------------------------------------------------------------------------------------------- ]] local lfPos = tonumber(props['ContinuousComment.LFpos.*.au3']) local charComm = props['ContinuousComment.Chars.*.au3']..' ' local charBreak1 = props['ContinuousComment.BreakCharsLast.*.au3'] local charBreak2 = props['ContinuousComment.BreakCharsNext.*.au3'] local fNewLine = false if tonumber(props['ContinuousComment.NewLine.WithEnter.Enable.*.au3']) == 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 AddEventHandler("OnKey", function(_keycode) 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ð² šeilenwechsel 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𧥮 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寧en 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