Find the exact Scintilla.NET API used by UDB and create a stub implementation so that it builds without

This commit is contained in:
Magnus Norddahl 2020-09-30 03:34:11 +02:00
parent e79a15807b
commit e390bce8f6
8 changed files with 459 additions and 180 deletions

View file

@ -179,6 +179,7 @@
<DependentUpon>ArgumentBox.cs</DependentUpon>
</Compile>
<Compile Include="Controls\FolderSelectDialog.cs" />
<Compile Include="Controls\Scripting\TextEditorControl.cs" />
<Compile Include="Controls\TransparentTrackBar.cs">
<SubType>Component</SubType>
</Compile>

View file

@ -176,12 +176,19 @@
<DependentUpon>ArgumentBox.cs</DependentUpon>
</Compile>
<Compile Include="Controls\FolderSelectDialog.cs" />
<Compile Include="Controls\Scripting\TextEditorControl.cs" />
<Compile Include="Controls\TransparentTrackBar.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\Scripting\ScriptDocumentTab.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\Scripting\ScriptEditorPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\Scripting\ScriptEditorPanel.Designer.cs">
<DependentUpon>ScriptEditorPanel.cs</DependentUpon>
</Compile>
<Compile Include="Controls\Scripting\ScriptFileDocumentTab.cs">
<SubType>Component</SubType>
</Compile>
@ -870,6 +877,18 @@
<Compile Include="Controls\PasteOptionsControl.Designer.cs">
<DependentUpon>PasteOptionsControl.cs</DependentUpon>
</Compile>
<Compile Include="Controls\Scripting\ScriptEditorControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\Scripting\ScriptEditorControl.designer.cs">
<DependentUpon>ScriptEditorControl.cs</DependentUpon>
</Compile>
<Compile Include="Controls\Scripting\ScriptEditorPreviewControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\Scripting\ScriptEditorPreviewControl.Designer.cs">
<DependentUpon>ScriptEditorPreviewControl.cs</DependentUpon>
</Compile>
<Compile Include="Controls\SectorSlopeControl.cs">
<SubType>UserControl</SubType>
</Compile>

View file

@ -21,9 +21,7 @@ using System.Collections;
using System.Collections.Generic;
using System.IO;
using CodeImp.DoomBuilder.IO;
#if !NO_SCINTILLA
using ScintillaNET;
#endif
#endregion
@ -77,9 +75,7 @@ namespace CodeImp.DoomBuilder.Config
private readonly string[] extensions;
private readonly bool casesensitive;
private readonly int insertcase;
#if !NO_SCINTILLA
private readonly Lexer lexer;
#endif
private readonly string keywordhelp;
private readonly string functionopen;
private readonly string functionclose;
@ -118,9 +114,7 @@ namespace CodeImp.DoomBuilder.Config
public string[] Extensions { get { return extensions; } }
public bool CaseSensitive { get { return casesensitive; } }
public int InsertCase { get { return insertcase; } }
#if !NO_SCINTILLA
public Lexer Lexer { get { return lexer; } }
#endif
public string KeywordHelp { get { return keywordhelp; } }
public string FunctionOpen { get { return functionopen; } }
public string FunctionClose { get { return functionclose; } }
@ -161,9 +155,7 @@ namespace CodeImp.DoomBuilder.Config
this.braces = new HashSet<char>(); //mxd
// Settings
#if !NO_SCINTILLA
lexer = Lexer.Null;
#endif
casesensitive = false;
codepage = 65001;
parameters = "";
@ -208,9 +200,7 @@ namespace CodeImp.DoomBuilder.Config
resultlump = cfg.ReadSetting("resultlump", "");
casesensitive = cfg.ReadSetting("casesensitive", true);
insertcase = cfg.ReadSetting("insertcase", 0);
#if !NO_SCINTILLA
lexer = (Lexer)cfg.ReadSetting("lexer", (int)Lexer.Container);
#endif
keywordhelp = cfg.ReadSetting("keywordhelp", "");
functionopen = cfg.ReadSetting("functionopen", "");
functionclose = cfg.ReadSetting("functionclose", "");

View file

@ -28,87 +28,10 @@ using CodeImp.DoomBuilder.Config;
using CodeImp.DoomBuilder.Compilers;
using CodeImp.DoomBuilder.ZDoom.Scripting;
using System.Text;
using ScintillaNET;
#endregion
#if NO_SCINTILLA
namespace CodeImp.DoomBuilder.Controls
{
internal abstract class ScriptDocumentTab : TabPage
{
protected readonly ScriptEditorControl editor;
protected ScriptConfiguration config;
protected readonly ScriptEditorPanel panel;
protected ScriptDocumentTabType tabtype;
public virtual bool ExplicitSave { get { return true; } }
public virtual bool IsSaveAsRequired { get { return true; } }
public virtual bool IsClosable { get { return true; } }
public virtual bool IsReconfigurable { get { return true; } }
public virtual bool IsReadOnly { get { return false; } }
public virtual string Filename { get { return ""; } }
public ScriptEditorPanel Panel { get { return panel; } }
public ScriptEditorControl Editor { get; private set; }
public string Title { get; private set; }
public bool IsChanged { get { return false; } }
public int SelectionStart { get; set; }
public int SelectionEnd { get; set; }
public bool ShowWhitespace { get; set; }
public bool WrapLongLines { get; set; }
public string SelectedText { get { return ""; } }
public ScriptConfiguration Config { get { return config; } }
public new event EventHandler OnTextChanged;
protected ScriptDocumentTab(ScriptEditorPanel panel, ScriptConfiguration config)
{
this.panel = panel;
this.config = config;
editor = new ScriptEditorControl();
this.Controls.Add(editor);
}
public bool LaunchKeywordHelp() { return false; }
public virtual void RefreshSettings() { }
public virtual void MoveToLine(int linenumber) { }
public virtual void ClearMarks() { }
public virtual void MarkScriptErrors(IEnumerable<CompilerError> errors) { }
public virtual bool VerifyErrorForScript(CompilerError e) { return false; }
public virtual void Compile() { }
public virtual bool Save() { return false; }
public virtual bool SaveAs(string filename) { return false; }
public virtual void ChangeScriptConfig(ScriptConfiguration newconfig) { }
public void Undo() { }
public void Redo() { }
public void Cut() { }
public void Copy() { }
public void Paste() { }
public bool FindNext(FindReplaceOptions options) { return false; }
public bool FindNext(FindReplaceOptions options, bool useselectionstart) { return false; }
public bool FindPrevious(FindReplaceOptions options) { return false; }
public void ReplaceSelection(string replacement) { }
internal virtual ScriptDocumentSettings GetViewSettings() { return new ScriptDocumentSettings {}; }
internal virtual void SetViewSettings(ScriptDocumentSettings settings) { }
internal void SetDefaultViewSettings() { }
internal List<CompilerError> UpdateNavigator() { return new List<CompilerError>(); }
internal ScriptType VerifyScriptType() { return ScriptType.UNKNOWN; }
internal void InsertSnippet(string name) { }
internal void IndentSelection(bool indent) { }
protected void SetTitle(string title) { }
protected void UpdateTitle() { }
protected void RemoveTrailingWhitespace() { }
}
}
#else
using ScintillaNET;
namespace CodeImp.DoomBuilder.Controls
{
internal abstract class ScriptDocumentTab : TabPage
@ -607,5 +530,3 @@ namespace CodeImp.DoomBuilder.Controls
#endregion
}
}
#endif

View file

@ -68,9 +68,7 @@ namespace CodeImp.DoomBuilder.Controls
{
// Set text and view settings
tabtype = ScriptDocumentTabType.FILE;
#if !NO_SCINTILLA
editor.Scintilla.Text = sourcetab.Editor.Scintilla.Text;
#endif
SetViewSettings(sourcetab.GetViewSettings());
// Set title

View file

@ -10,68 +10,6 @@ using CodeImp.DoomBuilder.Data.Scripting;
#endregion
#if NO_SCINTILLA
namespace CodeImp.DoomBuilder.Controls
{
//mxd. Document tab bound to a resource entry. Script type can't be changed. Can be readonly.
//Must be replaced with ScriptFileDocumentTab when unable to locate target resource entry to save to.
internal sealed class ScriptResourceDocumentTab : ScriptDocumentTab
{
private ScriptResource source;
private string hash;
private string filepathname;
public override bool IsReconfigurable { get { return false; } }
public override bool IsSaveAsRequired { get { return false; } }
public override bool IsReadOnly { get { return source.IsReadOnly; } }
public override string Filename { get { return filepathname; } }
internal ScriptResource Resource { get { return source; } }
internal ScriptResourceDocumentTab(ScriptEditorPanel panel, ScriptResource resource, ScriptConfiguration config) : base(panel, config)
{
source = resource;
filepathname = source.FilePathName;
this.ToolTipText = filepathname;
}
public override void Compile()
{
}
// This checks if a script error applies to this script
public override bool VerifyErrorForScript(CompilerError e)
{
return (string.Compare(e.filename, source.Filename, true) == 0);
}
public override bool Save()
{
if(source.IsReadOnly) return false;
return false;
}
internal override ScriptDocumentSettings GetViewSettings()
{
// Store resource location
var settings = base.GetViewSettings();
DataReader reader = source.Resource;
if(reader != null)
{
settings.ResourceLocation = reader.Location.location;
settings.Filename = Path.Combine(reader.Location.location, filepathname); // Make unique location
}
return settings;
}
internal void OnReloadResources()
{
}
}
}
#else
namespace CodeImp.DoomBuilder.Controls
{
//mxd. Document tab bound to a resource entry. Script type can't be changed. Can be readonly.
@ -227,5 +165,3 @@ namespace CodeImp.DoomBuilder.Controls
#endregion
}
}
#endif

View file

@ -0,0 +1,438 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
#if NO_SCINTILLA
namespace ScintillaNET
{
public enum Lexer
{
Container = 0,
Null = 1,
Python = 2,
Cpp = 3,
Html = 4,
Xml = 5,
Perl = 6,
Sql = 7,
Vb = 8,
Properties = 9,
Batch = 12,
Lua = 15,
Pascal = 18,
Ada = 20,
Lisp = 21,
Ruby = 22,
VbScript = 28,
Asm = 34,
Fortran = 36,
Css = 38,
Verilog = 56,
BlitzBasic = 66,
PureBasic = 67,
PhpScript = 69,
Smalltalk = 72,
FreeBasic = 75,
R = 86,
PowerShell = 88,
Markdown = 98,
Json = 120
}
public enum WhitespaceMode
{
Invisible,
VisibleAlways,
VisibleAfterIndent,
VisibleOnlyIndent
}
public enum WrapMode
{
None,
Word,
Char,
Whitespace
}
public enum Command
{
Null
}
public enum FoldAction
{
Contract
}
[Flags]
public enum FoldFlags
{
LineAfterContracted
}
public class Line
{
public int Position { get; private set; }
public int EndPosition { get; private set; }
public string Text { get; private set; }
public int WrapCount { get; private set; }
public int Indentation { get; set; }
public int FoldLevel { get; set; }
public bool Expanded { get; set; }
public void FoldLine(FoldAction action) { }
public void Goto() { }
public void MarkerAdd(int marker) { }
}
public class LineCollection // : IEnumerable<Line>
{
public int Count { get { return 0; } }
public Line this[int index] { get { return null; } }
}
public enum StyleCase
{
Mixed
}
public class Style
{
public const int Default = 0;
public const int LineNumber = 1;
public const int CallTip = 2;
public const int IndentGuide = 3;
public const int BraceLight = 4;
public const int BraceBad = 5;
public const int FoldDisplayText = 6;
public Color BackColor { get; set; }
public Color ForeColor { get; set; }
public string Font { get; set; }
public int Size { get; set; }
public bool Bold { get; set; }
public bool Italic { get; set; }
public bool Underline { get; set; }
public StyleCase Case { get; set; }
}
public class StyleCollection // : IEnumerable<Style>
{
public Style this[int index] { get { return null; } }
}
public enum MarginType
{
Symbol,
Number
}
public enum MarginCursor
{
Arrow
}
public class Margin
{
public MarginType Type { get; set; }
public int Width { get; set; }
public uint Mask { get; set; }
public MarginCursor Cursor { get; set; }
public bool Sensitive { get; set; }
}
public class MarginCollection // : IEnumerable<Margin>
{
public int Count { get { return 0; } }
public Margin this[int index] { get { return null; } }
}
public enum MarkerSymbol
{
BoxPlus,
BoxMinus,
BoxPlusConnected,
BoxMinusConnected,
TCorner,
LCorner,
VLine,
RgbaImage
}
public class Marker
{
public const uint MaskFolders = 127;
public const int FolderEnd = 1;
public const int FolderOpenMid = 2;
public const int FolderMidTail = 4;
public const int FolderTail = 8;
public const int FolderSub = 16;
public const int Folder = 32;
public const int FolderOpen = 64;
public MarkerSymbol Symbol { get; set; }
public void SetBackColor(Color color) { }
public void SetForeColor(Color color) { }
public void DefineRgbaImage(Bitmap image) { }
}
public class MarkerCollection // : IEnumerable<Marker>
{
public int Count { get { return 32; } }
public Marker this[int index] { get { return null; } }
}
public enum IndicatorStyle
{
RoundBox
}
public class Indicator
{
public IndicatorStyle Style { get; set; }
public bool Under { get; set; }
public Color ForeColor { get; set; }
public int OutlineAlpha { get; set; }
public int Alpha { get; set; }
}
public class IndicatorCollection // : IEnumerable<Indicator>
{
public Indicator this[int index] { get { return null; } }
}
[Flags]
public enum AutomaticFold
{
None = 0,
Show = 1,
Click = 2,
Change = 4
}
[Flags]
public enum SearchFlags
{
None = 0,
MatchCase = 1,
WholeWord = 2
}
public enum FontQuality
{
Default,
LcdOptimized
}
public enum Order
{
Presorted,
PerformSort,
Custom
}
public class Scintilla : Control
{
public const int InvalidPosition = -1;
[DefaultValue(BorderStyle.Fixed3D)]
[Category("Appearance")]
[Description("Indicates whether the control should have a border.")]
public BorderStyle BorderStyle { get; set; }
[DefaultValue(1)]
[Category("Caret")]
[Description("The width of the caret line measured in pixels (between 0 and 3).")]
public int CaretWidth { get; set; }
[DefaultValue(0)]
[Category("Whitespace")]
[Description("Extra whitespace added to the ascent (top) of each line.")]
public int ExtraAscent { get; set; }
[DefaultValue(0)]
[Category("Whitespace")]
[Description("Extra whitespace added to the descent (bottom) of each line.")]
public int ExtraDescent { get; set; }
[DefaultValue(FontQuality.Default)]
[Category("Misc")]
[Description("Specifies the anti-aliasing method to use when rendering fonts.")]
public FontQuality FontQuality { get; set; }
[DefaultValue(2000)]
[Category("Scrolling")]
[Description("The range in pixels of the horizontal scroll bar.")]
public int ScrollWidth { get; set; }
[DefaultValue(1)]
[Category("Whitespace")]
[Description("The size of whitespace dots.")]
public int WhitespaceSize { get; set; }
[DefaultValue(false)]
[Category("Autocompletion")]
[Description("Whether autocompletion word matching can ignore case.")]
public bool AutoCIgnoreCase { get; set; }
[DefaultValue(5)]
[Category("Autocompletion")]
[Description("The maximum number of rows to display in an autocompletion list.")]
public int AutoCMaxHeight { get; set; }
[DefaultValue(Order.Presorted)]
[Category("Autocompletion")]
[Description("The order of words in an autocompletion list.")]
public Order AutoCOrder { get; set; }
public int TextLength { get; private set; }
public int GetCharAt(int position) { return 0; }
public int CurrentPosition { get; set; }
public int CurrentLine { get; private set; }
public int IndicatorCurrent { get; set; }
public int TargetStart { get; set; }
public int TargetEnd { get; set; }
public int FirstVisibleLine { get; set; }
public int LinesOnScreen { get; private set; }
public bool AutoCActive { get; private set; }
public bool CallTipActive { get; private set; }
public Lexer Lexer { get; set; }
public int SelectionStart { get; set; }
public int SelectionEnd { get; set; }
public string SelectedText { get { return ""; } }
public int TabWidth { get; set; }
public bool ReadOnly { get; set; }
public bool CanUndo { get; private set; }
public bool CanRedo { get; private set; }
public bool CanPaste { get; private set; }
public bool Modified { get; private set; }
public Color CaretForeColor { get; set; }
public int CaretPeriod { get; set; }
public bool UseTabs { get; set; }
public WhitespaceMode ViewWhitespace { get; set; }
public WrapMode WrapMode { get; set; }
public AutomaticFold AutomaticFold { get; set; }
public SearchFlags SearchFlags { get; set; }
public LineCollection Lines { get; private set; }
public StyleCollection Styles { get; private set; }
public MarginCollection Margins { get; private set; }
public MarkerCollection Markers { get; private set; }
public IndicatorCollection Indicators { get; private set; }
public Scintilla()
{
Lines = new LineCollection();
Styles = new StyleCollection();
Margins = new MarginCollection();
Markers = new MarkerCollection();
Indicators = new IndicatorCollection();
}
public int WordStartPosition(int position, bool onlyWordCharacters) { return 0; }
public int WordEndPosition(int position, bool onlyWordCharacters) { return 0; }
public int LineFromPosition(int position) { return 0; }
public string GetWordFromPosition(int position) { return ""; }
public string GetTextRange(int position, int length) { return ""; }
public void SetEmptySelection(int pos) { }
public void ReplaceSelection(string text) { }
public int PointXFromPosition(int pos) { return 0; }
public int PointYFromPosition(int pos) { return 0; }
public int CharPositionFromPointClose(int x, int y) { return 0; }
public void ShowLines(int lineStart, int lineEnd) { }
public void GotoPosition(int position) { }
public void MarkerDeleteAll(int marker) { }
public void IndicatorClearRange(int position, int length) { }
public void IndicatorFillRange(int position, int length) { }
public void EmptyUndoBuffer() { }
public void Undo() { }
public void Redo() { }
public void Cut() { }
public void Copy() { }
public void Paste() { }
public void SelectAll() { }
public void DeleteRange(int position, int length) { }
public int SearchInTarget(string text) { return 0; }
public void InsertText(int position, string text) { }
public void SetSavePoint() { }
public void RegisterRgbaImage(int type, Bitmap image) { }
public int TextWidth(int style, string text) { return 0; }
public void BraceHighlight(int position1, int position2) { }
public int BraceMatch(int position) { return 0; }
public void BraceBadLight(int position) { }
public string WordChars { get; set; }
public int GetStyleAt(int position) { return 0; }
public void StyleClearAll() { }
public void ClearDocumentStyle() { }
public void StyleResetDefault() { }
public void SetKeywords(int set, string keywords) { }
public void SetProperty(string name, string value) { }
public void SetWhitespaceBackColor(bool use, Color color) { }
public void SetWhitespaceForeColor(bool use, Color color) { }
public void SetSelectionBackColor(bool use, Color color) { }
public void SetSelectionForeColor(bool use, Color color) { }
public void SetFoldMarginColor(bool use, Color color) { }
public void SetFoldMarginHighlightColor(bool use, Color color) { }
public void SetFoldFlags(FoldFlags flags) { }
public void AutoCCancel() { }
public void AutoCShow(int lenEntered, string list) { }
public void CallTipShow(int posStart, string definition) { }
public void CallTipCancel() { }
public void CallTipSetHlt(int hlStart, int hlEnd) { }
public void DirectMessage(int message, IntPtr param1, IntPtr param2) { }
public void AssignCmdKey(Keys keyDefinition, Command sciCommand) { }
[Category("Notifications")]
[Description("Occurs when the user types a character.")]
public event EventHandler<CharAddedEventArgs> CharAdded;
[Category("Notifications")]
[Description("Occurs after autocompleted text has been inserted.")]
public event EventHandler<AutoCSelectionEventArgs> AutoCCompleted;
[Category("Notifications")]
[Description("Occurs before text is inserted. Permits changing the inserted text.")]
public event EventHandler<InsertCheckEventArgs> InsertCheck;
[Category("Notifications")]
[Description("Occurs when the control UI is updated.")]
public event EventHandler<UpdateUIEventArgs> UpdateUI;
}
public class UpdateUIEventArgs
{
}
public class CharAddedEventArgs
{
public char Char { get; set; }
}
public class InsertCheckEventArgs
{
public string Text { get; set; }
}
public class AutoCSelectionEventArgs
{
public string Text { get; set; }
}
}
#endif

View file

@ -13,28 +13,6 @@ using CodeImp.DoomBuilder.IO;
#endregion
#if NO_SCINTILLA
namespace CodeImp.DoomBuilder.Data.Scripting
{
[ScriptHandler(ScriptType.UNKNOWN)]
internal class ScriptHandler
{
public virtual void Initialize(ScriptEditorControl scriptcontrol, ScriptConfiguration scriptconfig)
{
}
public virtual List<CompilerError> UpdateFunctionBarItems(ScriptDocumentTab tab, MemoryStream stream, ComboBox target)
{
// Unsupported script type. Just clear the items
target.Items.Clear();
return new List<CompilerError>();
}
}
}
#else
using ScintillaNET;
namespace CodeImp.DoomBuilder.Data.Scripting
@ -475,5 +453,3 @@ namespace CodeImp.DoomBuilder.Data.Scripting
#endregion
}
}
#endif