Script Editor: function arguments helper pop-up was obscuring the text cursor in some cases.

Reverted some changes from previous commit.
Updated documentation.
This commit is contained in:
MaxED 2014-05-14 15:17:14 +00:00
parent b4b0b4cc33
commit 9401828f73
5 changed files with 20 additions and 17 deletions

View file

@ -29,7 +29,10 @@
<div style="float:right; padding-left:10px;"><br /><img src="snippets1.jpg"/></div>
<p>In the Script Editor you can use and create code snippets, which are small blocks of reusable code that you can insert where you need it in your code.</p>
<p><strong>Using code snippets:</strong><br />
To use a snippet, just pick it from the drop-down menu.</p>
To use a snippet, pick it from the drop-down menu.<br />
Alternatively, type the name of a snippet (or place the cursor inside of already existing one), then press the <strong>Tab</strong> key to expand it.<br /><br />
<strong>Example:</strong> to create the while loop, type &quot;<strong>while</strong>&quot;...<br /><img src="snippets_expand1.jpg"/><br />
<br />...and press the <strong>Tab</strong> key.<br /><img src="snippets_expand2.jpg"/></p>
<p><strong>Creating new code snippets:</strong><br />
Code snippets are plain text files stored in [GZDB]\Snippets\[category], so just create a new text file there and add the code you want into it. Currently the only supported &quot;special&quot; token is <strong>$EP</strong> (Entry Point) - that's the place where the cursor will be placed after inserting a snippet.<br />
<span class="style1">Warning:</span> snippet's file name should not contain spaces.</p>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -133,7 +133,7 @@ namespace CodeImp.DoomBuilder.Controls
// This ignores key combinations so that they are passed
// on to the other controls on the parent form
private Dictionary<int, int> ignoredkeys;
private readonly Dictionary<int, int> ignoredkeys;
// States
private ScriptMarginType indexmargintype;

View file

@ -325,7 +325,7 @@ namespace CodeImp.DoomBuilder.Controls
foreach(DictionaryEntry de in dic)
{
// Check if this is a numeric key
int stylenum = -1;
int stylenum;
if(int.TryParse(de.Key.ToString(), out stylenum))
{
// Add style to lookup table
@ -824,22 +824,12 @@ namespace CodeImp.DoomBuilder.Controls
{
// Get the current line index and check if its not the first line
int curline = scriptedit.LineFromPosition(scriptedit.CurrentPos);
if(curline > 0)
if(curline > 0 && scriptedit.GetLineIndentation(curline) == 0)
{
// Apply identation of the previous line to this line
int ident = scriptedit.GetLineIndentation(curline - 1);
//mxd. Indent a bit more if a code block is started on the previous line
string prevline = scriptedit.GetLine(curline - 1);
int blockstartpos = prevline.LastIndexOf("{"); //TODO: should we move block start/end symbols to script configuration?..
int blockendpos = prevline.LastIndexOf("}");
if(blockstartpos > blockendpos) ident += General.Settings.ScriptTabWidth;
if(scriptedit.GetLineIndentation(curline) == 0)
{
scriptedit.SetLineIndentation(curline, ident);
scriptedit.SetSel(scriptedit.SelectionStart + ident, scriptedit.SelectionStart + ident);
}
scriptedit.SetLineIndentation(curline, ident);
scriptedit.SetSel(scriptedit.SelectionStart + ident, scriptedit.SelectionStart + ident);
}
}
}
@ -889,9 +879,19 @@ namespace CodeImp.DoomBuilder.Controls
highlightend = highlightstart + args[curargumentindex].Length;
}
}
//mxd. If the tip obscures the view, move it down
int tippos;
int funcline = scriptedit.LineFromPosition(curfunctionstartpos);
int curline = scriptedit.LineFromPosition(scriptedit.CurrentPos);
if(curline > funcline) {
tippos = scriptedit.PositionFromLine(curline) + scriptedit.GetLineIndentation(curline); //scriptedit.PositionFromLine(curline) /*+ (curfunctionstartpos - scriptedit.PositionFromLine(funcline))*/;
} else {
tippos = curfunctionstartpos;
}
// Show tip
scriptedit.CallTipShow(curfunctionstartpos, functiondef);
scriptedit.CallTipShow(tippos, functiondef);
scriptedit.CallTipSetHlt(highlightstart, highlightend);
}
}