This commit is contained in:
codeimp 2008-11-03 22:05:47 +00:00
parent fe2fa46d9c
commit 3206fbe0e0
4 changed files with 43 additions and 5 deletions

View file

@ -5,6 +5,10 @@
casesensitive = true; casesensitive = true;
insertcase = 0; // 0=Normal, 1=Lowercase, 2=Uppercase insertcase = 0; // 0=Normal, 1=Lowercase, 2=Uppercase
lexer = 3; // CPP-style, case-sensitive lexer = 3; // CPP-style, case-sensitive
functionopen = "(";
functionclose = ")";
argumentdelimiter = ",";
terminator = ";";
keywordhelp = ""; keywordhelp = "";
keywords keywords

View file

@ -11,6 +11,10 @@ resultlump = "BEHAVIOR";
casesensitive = false; casesensitive = false;
insertcase = 0; // 0=Normal, 1=Lowercase, 2=Uppercase insertcase = 0; // 0=Normal, 1=Lowercase, 2=Uppercase
lexer = 35; // CPP-style, case-insensitive lexer = 35; // CPP-style, case-insensitive
functionopen = "(";
functionclose = ")";
argumentdelimiter = ",";
terminator = ";";
keywordhelp = "http://www.zdoom.org/wiki/index.php?title=%K"; keywordhelp = "http://www.zdoom.org/wiki/index.php?title=%K";
keywords keywords

View file

@ -53,6 +53,10 @@ namespace CodeImp.DoomBuilder.Config
private int insertcase; private int insertcase;
private int lexer; private int lexer;
private string keywordhelp; private string keywordhelp;
private string functionopen;
private string functionclose;
private string argumentdelimiter;
private string terminator;
// Collections // Collections
private Dictionary<string, string> keywords; private Dictionary<string, string> keywords;
@ -74,6 +78,10 @@ namespace CodeImp.DoomBuilder.Config
public int InsertCase { get { return insertcase; } } public int InsertCase { get { return insertcase; } }
public int Lexer { get { return lexer; } } public int Lexer { get { return lexer; } }
public string KeywordHelp { get { return keywordhelp; } } 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 // Collections
public Dictionary<string, string>.KeyCollection Keywords { get { return keywords.Keys; } } public Dictionary<string, string>.KeyCollection Keywords { get { return keywords.Keys; } }
@ -105,6 +113,10 @@ namespace CodeImp.DoomBuilder.Config
insertcase = cfg.ReadSetting("insertcase", 0); insertcase = cfg.ReadSetting("insertcase", 0);
lexer = cfg.ReadSetting("lexer", 0); lexer = cfg.ReadSetting("lexer", 0);
keywordhelp = cfg.ReadSetting("keywordhelp", ""); keywordhelp = cfg.ReadSetting("keywordhelp", "");
functionopen = cfg.ReadSetting("functionopen", "");
functionclose = cfg.ReadSetting("functionclose", "");
argumentdelimiter = cfg.ReadSetting("argumentdelimiter", "");
terminator = cfg.ReadSetting("terminator", "");
// Load keywords // Load keywords
dic = cfg.ReadSetting("keywords", new Hashtable()); dic = cfg.ReadSetting("keywords", new Hashtable());

View file

@ -55,6 +55,9 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Variables #region ================== Variables
// Script configuration
private ScriptConfiguration scriptconfig;
// List of keywords and constants, sorted as uppercase // List of keywords and constants, sorted as uppercase
private string autocompletestring; private string autocompletestring;
@ -115,6 +118,9 @@ namespace CodeImp.DoomBuilder.Controls
List<string> autocompletelist = new List<string>(); List<string> autocompletelist = new List<string>();
string[] resnames; string[] resnames;
// Keep script configuration
scriptconfig = config;
// Find a resource named Actions.cfg // Find a resource named Actions.cfg
resnames = General.ThisAssembly.GetManifestResourceNames(); resnames = General.ThisAssembly.GetManifestResourceNames();
foreach(string rn in resnames) foreach(string rn in resnames)
@ -136,9 +142,9 @@ namespace CodeImp.DoomBuilder.Controls
} }
// Check if specified lexer exists and set the lexer to use // Check if specified lexer exists and set the lexer to use
string lexername = "lexer" + config.Lexer.ToString(CultureInfo.InvariantCulture); string lexername = "lexer" + scriptconfig.Lexer.ToString(CultureInfo.InvariantCulture);
if(!lexercfg.SettingExists(lexername)) throw new InvalidOperationException("Unknown lexer " + config.Lexer + " specified in script configuration!"); if(!lexercfg.SettingExists(lexername)) throw new InvalidOperationException("Unknown lexer " + scriptconfig.Lexer + " specified in script configuration!");
scriptedit.Lexer = config.Lexer; scriptedit.Lexer = scriptconfig.Lexer;
// Set the default style and settings // Set the default style and settings
scriptedit.StyleSetFont(DEFAULT_STYLE, "Lucida Console"); scriptedit.StyleSetFont(DEFAULT_STYLE, "Lucida Console");
@ -189,7 +195,7 @@ namespace CodeImp.DoomBuilder.Controls
if(keywordsindex > -1) if(keywordsindex > -1)
{ {
StringBuilder keywordslist = new StringBuilder(""); StringBuilder keywordslist = new StringBuilder("");
foreach(string k in config.Keywords) foreach(string k in scriptconfig.Keywords)
{ {
if(keywordslist.Length > 0) keywordslist.Append(" "); if(keywordslist.Length > 0) keywordslist.Append(" ");
keywordslist.Append(k); keywordslist.Append(k);
@ -204,7 +210,7 @@ namespace CodeImp.DoomBuilder.Controls
if(constantsindex > -1) if(constantsindex > -1)
{ {
StringBuilder constantslist = new StringBuilder(""); StringBuilder constantslist = new StringBuilder("");
foreach(string c in config.Constants) foreach(string c in scriptconfig.Constants)
{ {
if(constantslist.Length > 0) constantslist.Append(" "); if(constantslist.Length > 0) constantslist.Append(" ");
constantslist.Append(c); constantslist.Append(c);
@ -219,6 +225,18 @@ namespace CodeImp.DoomBuilder.Controls
autocompletestring = string.Join(" ", autocompletelist.ToArray()); 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 #endregion
#region ================== Events #region ================== Events