mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 14:31:50 +00:00
moo
This commit is contained in:
parent
fe2fa46d9c
commit
3206fbe0e0
4 changed files with 43 additions and 5 deletions
|
@ -5,6 +5,10 @@
|
|||
casesensitive = true;
|
||||
insertcase = 0; // 0=Normal, 1=Lowercase, 2=Uppercase
|
||||
lexer = 3; // CPP-style, case-sensitive
|
||||
functionopen = "(";
|
||||
functionclose = ")";
|
||||
argumentdelimiter = ",";
|
||||
terminator = ";";
|
||||
keywordhelp = "";
|
||||
|
||||
keywords
|
||||
|
|
|
@ -11,6 +11,10 @@ resultlump = "BEHAVIOR";
|
|||
casesensitive = false;
|
||||
insertcase = 0; // 0=Normal, 1=Lowercase, 2=Uppercase
|
||||
lexer = 35; // CPP-style, case-insensitive
|
||||
functionopen = "(";
|
||||
functionclose = ")";
|
||||
argumentdelimiter = ",";
|
||||
terminator = ";";
|
||||
keywordhelp = "http://www.zdoom.org/wiki/index.php?title=%K";
|
||||
|
||||
keywords
|
||||
|
|
|
@ -53,6 +53,10 @@ namespace CodeImp.DoomBuilder.Config
|
|||
private int insertcase;
|
||||
private int lexer;
|
||||
private string keywordhelp;
|
||||
private string functionopen;
|
||||
private string functionclose;
|
||||
private string argumentdelimiter;
|
||||
private string terminator;
|
||||
|
||||
// Collections
|
||||
private Dictionary<string, string> keywords;
|
||||
|
@ -74,6 +78,10 @@ namespace CodeImp.DoomBuilder.Config
|
|||
public int InsertCase { get { return insertcase; } }
|
||||
public int Lexer { get { return lexer; } }
|
||||
public string KeywordHelp { get { return keywordhelp; } }
|
||||
public string FunctionOpen { get { return functionopen; } }
|
||||
public string FunctionClose { get { return functionclose; } }
|
||||
public string ArgumentDelimiter { get { return argumentdelimiter; } }
|
||||
public string Terminator { get { return terminator; } }
|
||||
|
||||
// Collections
|
||||
public Dictionary<string, string>.KeyCollection Keywords { get { return keywords.Keys; } }
|
||||
|
@ -105,6 +113,10 @@ namespace CodeImp.DoomBuilder.Config
|
|||
insertcase = cfg.ReadSetting("insertcase", 0);
|
||||
lexer = cfg.ReadSetting("lexer", 0);
|
||||
keywordhelp = cfg.ReadSetting("keywordhelp", "");
|
||||
functionopen = cfg.ReadSetting("functionopen", "");
|
||||
functionclose = cfg.ReadSetting("functionclose", "");
|
||||
argumentdelimiter = cfg.ReadSetting("argumentdelimiter", "");
|
||||
terminator = cfg.ReadSetting("terminator", "");
|
||||
|
||||
// Load keywords
|
||||
dic = cfg.ReadSetting("keywords", new Hashtable());
|
||||
|
|
|
@ -55,6 +55,9 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
|
||||
#region ================== Variables
|
||||
|
||||
// Script configuration
|
||||
private ScriptConfiguration scriptconfig;
|
||||
|
||||
// List of keywords and constants, sorted as uppercase
|
||||
private string autocompletestring;
|
||||
|
||||
|
@ -115,6 +118,9 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
List<string> autocompletelist = new List<string>();
|
||||
string[] resnames;
|
||||
|
||||
// Keep script configuration
|
||||
scriptconfig = config;
|
||||
|
||||
// Find a resource named Actions.cfg
|
||||
resnames = General.ThisAssembly.GetManifestResourceNames();
|
||||
foreach(string rn in resnames)
|
||||
|
@ -136,9 +142,9 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
}
|
||||
|
||||
// Check if specified lexer exists and set the lexer to use
|
||||
string lexername = "lexer" + config.Lexer.ToString(CultureInfo.InvariantCulture);
|
||||
if(!lexercfg.SettingExists(lexername)) throw new InvalidOperationException("Unknown lexer " + config.Lexer + " specified in script configuration!");
|
||||
scriptedit.Lexer = config.Lexer;
|
||||
string lexername = "lexer" + scriptconfig.Lexer.ToString(CultureInfo.InvariantCulture);
|
||||
if(!lexercfg.SettingExists(lexername)) throw new InvalidOperationException("Unknown lexer " + scriptconfig.Lexer + " specified in script configuration!");
|
||||
scriptedit.Lexer = scriptconfig.Lexer;
|
||||
|
||||
// Set the default style and settings
|
||||
scriptedit.StyleSetFont(DEFAULT_STYLE, "Lucida Console");
|
||||
|
@ -189,7 +195,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
if(keywordsindex > -1)
|
||||
{
|
||||
StringBuilder keywordslist = new StringBuilder("");
|
||||
foreach(string k in config.Keywords)
|
||||
foreach(string k in scriptconfig.Keywords)
|
||||
{
|
||||
if(keywordslist.Length > 0) keywordslist.Append(" ");
|
||||
keywordslist.Append(k);
|
||||
|
@ -204,7 +210,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
if(constantsindex > -1)
|
||||
{
|
||||
StringBuilder constantslist = new StringBuilder("");
|
||||
foreach(string c in config.Constants)
|
||||
foreach(string c in scriptconfig.Constants)
|
||||
{
|
||||
if(constantslist.Length > 0) constantslist.Append(" ");
|
||||
constantslist.Append(c);
|
||||
|
@ -219,6 +225,18 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
autocompletestring = string.Join(" ", autocompletelist.ToArray());
|
||||
}
|
||||
|
||||
// This returns the current word (where the caret is at)
|
||||
public string GetCurrentWord()
|
||||
{
|
||||
int wordstart = scriptedit.WordStartPosition(scriptedit.CurrentPos, true);
|
||||
int wordend = scriptedit.WordEndPosition(scriptedit.CurrentPos, true);
|
||||
|
||||
if(wordstart > wordend)
|
||||
return scriptedit.Text.Substring(wordstart, wordend - wordstart);
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Events
|
||||
|
|
Loading…
Reference in a new issue