Fixed, Script Editor: in some cases "[EP]" (Entry Position) markers were processed incorrectly when inserting a snippet.

Updated SharpCompress library to 0.11.5.
Updated ScintillaNET library to 3.6.3.
This commit is contained in:
MaxED 2016-03-14 13:41:26 +00:00
parent 23d2a27dec
commit 8924f62d7d
5 changed files with 34 additions and 38 deletions

Binary file not shown.

Binary file not shown.

View file

@ -524,10 +524,10 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="JetBrains.Profiler.Core.Api, Version=1.3.1661.20096, Culture=neutral, PublicKeyToken=1010a0d8d6380325" Condition=" '$(Configuration)|$(Platform)' == 'Debug + Profiler|x86' Or '$(Configuration)|$(Platform)' == 'Release + Profiler|x86' " /> <Reference Include="JetBrains.Profiler.Core.Api, Version=1.3.1661.20096, Culture=neutral, PublicKeyToken=1010a0d8d6380325" Condition=" '$(Configuration)|$(Platform)' == 'Debug + Profiler|x86' Or '$(Configuration)|$(Platform)' == 'Release + Profiler|x86' " />
<Reference Include="ScintillaNET.3.5, Version=3.5.6.0, Culture=neutral, processorArchitecture=x86"> <Reference Include="ScintillaNET.3.5, Version=3.5.8.0, Culture=neutral, processorArchitecture=x86">
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="SharpCompress.3.5, Version=0.11.2.0, Culture=neutral, processorArchitecture=x86"> <Reference Include="SharpCompress.3.5, Version=0.11.5.0, Culture=neutral, processorArchitecture=x86">
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="SlimDX, Version=2.0.13.43, Culture=neutral, PublicKeyToken=b1b0c32fd1ffe4f9, processorArchitecture=x86" /> <Reference Include="SlimDX, Version=2.0.13.43, Culture=neutral, PublicKeyToken=b1b0c32fd1ffe4f9, processorArchitecture=x86" />

View file

@ -48,8 +48,6 @@ namespace CodeImp.DoomBuilder.Config
{ {
#region ================== Constants #region ================== Constants
private const string WORD_CHARS = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; //mxd
#endregion #endregion
#region ================== Variables #region ================== Variables
@ -62,7 +60,7 @@ namespace CodeImp.DoomBuilder.Config
// Editor settings // Editor settings
private readonly string description; private readonly string description;
private readonly int codepage; private readonly int codepage;
private readonly string wordchars; //mxd. Characters to be threated as part of a word by Scintilla private readonly string extrawordchars; //mxd. Extra characters to be threated as part of a word by Scintilla
private readonly string[] extensions; private readonly string[] extensions;
private readonly bool casesensitive; private readonly bool casesensitive;
private readonly int insertcase; private readonly int insertcase;
@ -115,7 +113,7 @@ namespace CodeImp.DoomBuilder.Config
public string ArrayClose { get { return arrayclose; } } //mxd public string ArrayClose { get { return arrayclose; } } //mxd
public string ArgumentDelimiter { get { return argumentdelimiter; } } public string ArgumentDelimiter { get { return argumentdelimiter; } }
public string Terminator { get { return terminator; } } public string Terminator { get { return terminator; } }
public string WordCharacters { get { return wordchars; } } //mxd public string ExtraWordCharacters { get { return extrawordchars; } } //mxd
public ScriptType ScriptType { get { return scripttype; } } //mxd public ScriptType ScriptType { get { return scripttype; } } //mxd
// Collections // Collections
@ -163,7 +161,7 @@ namespace CodeImp.DoomBuilder.Config
terminator = ""; terminator = "";
description = "Plain text"; description = "Plain text";
scripttype = ScriptType.UNKNOWN; //mxd scripttype = ScriptType.UNKNOWN; //mxd
wordchars = WORD_CHARS; //mxd extrawordchars = ""; //mxd
extensions = new[] { "txt" }; extensions = new[] { "txt" };
} }
@ -202,7 +200,7 @@ namespace CodeImp.DoomBuilder.Config
argumentdelimiter = cfg.ReadSetting("argumentdelimiter", ""); argumentdelimiter = cfg.ReadSetting("argumentdelimiter", "");
terminator = cfg.ReadSetting("terminator", ""); terminator = cfg.ReadSetting("terminator", "");
scripttype = (ScriptType)cfg.ReadSetting("scripttype", (int)ScriptType.UNKNOWN); //mxd scripttype = (ScriptType)cfg.ReadSetting("scripttype", (int)ScriptType.UNKNOWN); //mxd
wordchars = WORD_CHARS + cfg.ReadSetting("extrawordchars", ""); //mxd extrawordchars = cfg.ReadSetting("extrawordchars", ""); //mxd
//mxd. Make braces array //mxd. Make braces array
if(!string.IsNullOrEmpty(functionopen)) braces.Add(functionopen[0]); if(!string.IsNullOrEmpty(functionopen)) braces.Add(functionopen[0]);

View file

@ -70,6 +70,7 @@ namespace CodeImp.DoomBuilder.Controls
private const int MAX_BACKTRACK_LENGTH = 200; private const int MAX_BACKTRACK_LENGTH = 200;
private const int HIGHLIGHT_INDICATOR = 8; //mxd. Indicators 0-7 could be in use by a lexer so we'll use indicator 8 to highlight words. private const int HIGHLIGHT_INDICATOR = 8; //mxd. Indicators 0-7 could be in use by a lexer so we'll use indicator 8 to highlight words.
private const string ENTRY_POSITION_MARKER = "[EP]"; //mxd private const string ENTRY_POSITION_MARKER = "[EP]"; //mxd
private const string LINE_BREAK_MARKER = "[LB]"; //mxd
#endregion #endregion
@ -359,8 +360,9 @@ namespace CodeImp.DoomBuilder.Controls
if(!lexercfg.SettingExists(lexername)) throw new InvalidOperationException("Unknown lexer " + scriptconfig.Lexer + " specified in script configuration!"); if(!lexercfg.SettingExists(lexername)) throw new InvalidOperationException("Unknown lexer " + scriptconfig.Lexer + " specified in script configuration!");
scriptedit.Lexer = scriptconfig.Lexer; scriptedit.Lexer = scriptconfig.Lexer;
//mxd. Set word chars //mxd. Set extra word chars?
scriptedit.SetWordChars(scriptconfig.WordCharacters); if(!string.IsNullOrEmpty(scriptconfig.ExtraWordCharacters))
scriptedit.WordChars += scriptconfig.ExtraWordCharacters;
// Set the default style and settings // Set the default style and settings
scriptedit.Styles[Style.Default].Font = General.Settings.ScriptFontName; scriptedit.Styles[Style.Default].Font = General.Settings.ScriptFontName;
@ -691,16 +693,33 @@ namespace CodeImp.DoomBuilder.Controls
public void InsertSnippet(string[] lines) public void InsertSnippet(string[] lines)
{ {
// Insert the snippet // Insert the snippet
List<string> processedlines = new List<string>(lines.Length);
int curline = scriptedit.LineFromPosition(scriptedit.SelectionStart); int curline = scriptedit.LineFromPosition(scriptedit.SelectionStart);
int indent = scriptedit.Lines[scriptedit.CurrentLine].Indentation; int indent = scriptedit.Lines[scriptedit.CurrentLine].Indentation;
string tabs = Environment.NewLine + GetIndentationString(indent); string tabs = Environment.NewLine + GetIndentationString(indent);
string spaces = new String(' ', General.Settings.ScriptTabWidth); string spaces = new String(' ', General.Settings.ScriptTabWidth);
string[] linebreak = { LINE_BREAK_MARKER };
int entrypos = -1; int entrypos = -1;
int entryline = -1; int entryline = -1;
string[] processedlines = ProcessLineBreaks(lines);
// Process line breaks
foreach(string line in lines)
{
if(line.IndexOf(linebreak[0], StringComparison.Ordinal) != -1)
{
if(General.Settings.ScriptAllmanStyle)
processedlines.AddRange(line.Split(linebreak, StringSplitOptions.RemoveEmptyEntries));
else
processedlines.Add(line.Replace(linebreak[0], " "));
}
else
{
processedlines.Add(line);
}
}
// Process special chars, try to find entry position marker // Process special chars, try to find entry position marker
for(int i = 0; i < lines.Length; i++) for(int i = 0; i < processedlines.Count; i++)
{ {
if(!scriptedit.UseTabs) processedlines[i] = processedlines[i].Replace("\t", spaces); if(!scriptedit.UseTabs) processedlines[i] = processedlines[i].Replace("\t", spaces);
@ -718,7 +737,7 @@ namespace CodeImp.DoomBuilder.Controls
} }
// Replace the text // Replace the text
string text = string.Join(tabs, processedlines); string text = string.Join(tabs, processedlines.ToArray());
scriptedit.SelectionStart = scriptedit.WordStartPosition(scriptedit.CurrentPosition, true); scriptedit.SelectionStart = scriptedit.WordStartPosition(scriptedit.CurrentPosition, true);
scriptedit.SelectionEnd = scriptedit.WordEndPosition(scriptedit.CurrentPosition, true); scriptedit.SelectionEnd = scriptedit.WordEndPosition(scriptedit.CurrentPosition, true);
scriptedit.ReplaceSelection(text); scriptedit.ReplaceSelection(text);
@ -726,7 +745,10 @@ namespace CodeImp.DoomBuilder.Controls
// Move the cursor if we had the [EP] marker // Move the cursor if we had the [EP] marker
if(entrypos != -1) if(entrypos != -1)
{ {
scriptedit.SetEmptySelection(scriptedit.Lines[entryline].EndPosition - entrypos - 2); // Count from the end of the line, because I don't see a reliable way to count indentation chars...
int pos = scriptedit.Lines[entryline].EndPosition - entrypos;
if(scriptedit.Lines[entryline].Text.EndsWith(Environment.NewLine)) pos -= 2;
scriptedit.SetEmptySelection(pos);
} }
} }
@ -969,30 +991,6 @@ namespace CodeImp.DoomBuilder.Controls
scriptedit.Markers[(int)index].Symbol = MarkerSymbol.RgbaImage; scriptedit.Markers[(int)index].Symbol = MarkerSymbol.RgbaImage;
} }
//mxd. This converts [LB] markers to line breaks if necessary
private static string[] ProcessLineBreaks(string[] lines)
{
List<string> result = new List<string>(lines.Length);
string[] separator = new[] { "[LB]" };
foreach(string line in lines)
{
if(line.IndexOf(separator[0], StringComparison.Ordinal) != -1)
{
if(General.Settings.ScriptAllmanStyle)
result.AddRange(line.Split(separator, StringSplitOptions.RemoveEmptyEntries));
else
result.Add(line.Replace(separator[0], " "));
}
else
{
result.Add(line);
}
}
return result.ToArray();
}
//mxd. Autocompletion handling (https://github.com/jacobslusser/ScintillaNET/wiki/Basic-Autocompletion) //mxd. Autocompletion handling (https://github.com/jacobslusser/ScintillaNET/wiki/Basic-Autocompletion)
private bool ShowAutoCompletionList() private bool ShowAutoCompletionList()
{ {