mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 13:51:40 +00:00
Script editor now keeps same line indentation as previous line when ENTER is pressed
This commit is contained in:
parent
66ef82efb9
commit
01ad6d9ec9
1 changed files with 18 additions and 1 deletions
|
@ -121,6 +121,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
scriptedit.IsViewEOL = false;
|
||||
scriptedit.IsVScrollBar = true;
|
||||
scriptedit.SetFoldFlags((int)ScriptFoldFlag.Box);
|
||||
scriptedit.TabWidth = 4;
|
||||
|
||||
// Symbol margin
|
||||
scriptedit.SetMarginTypeN(0, (int)ScriptMarginType.Symbol);
|
||||
|
@ -229,6 +230,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
scriptedit.CaretPeriod = SystemInformation.CaretBlinkTime;
|
||||
scriptedit.CaretFore = General.Colors.ScriptBackground.Inverse().ToColorRef();
|
||||
scriptedit.StyleBits = 7;
|
||||
scriptedit.TabWidth = 4;
|
||||
|
||||
// This applies the default style to all styles
|
||||
scriptedit.StyleClearAll();
|
||||
|
@ -615,6 +617,21 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
int highlightstart = 0;
|
||||
int highlightend = 0;
|
||||
|
||||
// Enter pressed?
|
||||
if((e.KeyCode == Keys.Enter) && (e.Modifiers == Keys.None))
|
||||
{
|
||||
// Get the current line index and heck if its not the first line
|
||||
int curline = scriptedit.LineFromPosition(scriptedit.CurrentPos);
|
||||
if(curline > 0)
|
||||
{
|
||||
// Apply identation of the previous line to this line
|
||||
int ident = scriptedit.GetLineIndentation(curline - 1);
|
||||
int tabs = ident / scriptedit.TabWidth;
|
||||
scriptedit.SetLineIndentation(curline, ident);
|
||||
scriptedit.SetSel(scriptedit.SelectionStart + tabs, scriptedit.SelectionStart + tabs);
|
||||
}
|
||||
}
|
||||
|
||||
UpdatePositionInfo();
|
||||
|
||||
// Call tip shown
|
||||
|
|
Loading…
Reference in a new issue