added margin images and autocomplete images in script editor

This commit is contained in:
codeimp 2008-11-09 10:34:03 +00:00
parent 360bd58b0c
commit b1792c9c10
14 changed files with 665 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 409 B

View file

@ -0,0 +1,95 @@
/* XPM */
static char *image_xpm[] = {
/* width height ncolors chars_per_pixel */
"16 16 74 1",
" c #00ffff",
". c #eceff4",
"+ c #e5e8ee",
"@ c #4e607a",
"# c #fbfbfc",
"$ c #c4ccda",
"% c #a2adc4",
"& c #3f546e",
"* c #8494ad",
"= c #8796af",
"- c #ffffff",
"; c #d3dae3",
"> c #485c75",
", c #93a2bb",
"' c #9da9c1",
") c #96a3bc",
"! c #eceff3",
"~ c #dce0e8",
"{ c #556880",
"] c #f4f6f8",
"^ c #9ba8bf",
"/ c #dce0e9",
"( c #52667e",
"_ c #e4e7ee",
": c #a6b1c6",
"< c #586a83",
"[ c #ccd2df",
"} c #b5bdc8",
"| c #b5bed0",
"1 c #40546e",
"2 c #adb8cc",
"3 c #9fabc3",
"4 c #edeff3",
"5 c #ccd3df",
"6 c #e4e8ef",
"7 c #8b9ab3",
"8 c #d8dde6",
"9 c #f4f5f8",
"0 c #acb8cb",
"a c #798aa3",
"b c #909eb7",
"c c #d3d9e3",
"d c #d4d9e3",
"e c #e4e8ee",
"f c #fafbfc",
"g c #aab4c9",
"h c #3b4f6a",
"i c #d3d9e4",
"j c #b4bed0",
"k c #e5e7ee",
"l c #374b67",
"m c #334863",
"n c #a5b1c6",
"o c #52657e",
"p c #a9b4c9",
"q c #dce1e9",
"r c #66778e",
"s c #435771",
"t c #a4aeba",
"u c #5d7088",
"v c #f5f6f9",
"w c #465a73",
"x c #8e9cb5",
"y c #7f8fa8",
"z c #394e68",
"A c #ccd2de",
"B c #c5ccda",
"C c #a3afc5",
"D c #3e536d",
"E c #bcc5d5",
"F c #8998b2",
"G c #ccd3de",
"H c #cbd3df",
"I c #dbe1e9",
" ",
" ",
" ",
" ",
" 8p%^,xF*ya} ",
" g--f9!k~d5r ",
" C-#v._IiABu ",
" '#].(&mG$E{ ",
" )]46/cHBE|@ ",
" b!e~o1mEj0w ",
" 7+qd[$E|2nD ",
" =/;G$E|0:3z ",
" }u<o@>sDhlt ",
" ",
" ",
" ",
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 B

View file

@ -0,0 +1,100 @@
/* XPM */
static char *image_xpm[] = {
/* width height ncolors chars_per_pixel */
"16 16 79 1",
" c #00ffff",
". c #f33b00",
"+ c #ea3900",
"@ c #ee3a00",
"# c #e43600",
"$ c #ba7a64",
"% c #ff8b65",
"& c #ff7c52",
"* c #ffbea9",
"= c #ffa183",
"- c #f87247",
"; c #ff9a79",
"> c #d49b8a",
", c #bd3306",
"' c #f1ab95",
") c #ff6a39",
"! c #ff6f41",
"~ c #d19481",
"{ c #fb7950",
"] c #7c250a",
"^ c #fe5c28",
"/ c #ff5f2c",
"( c #ff8e69",
"_ c #dc9d89",
": c #e5b6a7",
"< c #ff9c7c",
"[ c #fe7f56",
"} c #fb8660",
"| c #fa8059",
"1 c #fd5721",
"2 c #f29679",
"3 c #ffa487",
"4 c #fa4409",
"5 c #fb480d",
"6 c #e0ad9d",
"7 c #dc957e",
"8 c #b9725a",
"9 c #bb5a3b",
"0 c #e23903",
"a c #77311b",
"b c #e35a2e",
"c c #b62f05",
"d c #feb8a2",
"e c #fed8cc",
"f c #f83e02",
"g c #7f2e14",
"h c #6e2a14",
"i c #d03c0c",
"j c #dda797",
"k c #fec7b5",
"l c #b27967",
"m c #fed3c5",
"n c #fb5018",
"o c #f94107",
"p c #a45f49",
"q c #f2d8cf",
"r c #ddaa9b",
"s c #ffa88d",
"t c #ff6d3e",
"u c #ac4d2e",
"v c #ff612d",
"w c #fefefe",
"x c #fd521b",
"y c #b8411c",
"z c #ffc4b1",
"A c #c66b50",
"B c #d48c75",
"C c #dc3602",
"D c #dd4c1c",
"E c #d4947f",
"F c #ee734c",
"G c #962a09",
"H c #ff8660",
"I c #933e23",
"J c #d9704d",
"K c #ffb197",
"L c #d58970",
"M c #e5a38d",
"N c #ecc2b4",
" ",
" e6_>~L~e ",
" NjM2}{FJA7 ",
" Nr'3;%&tvb9B ",
" qj'Ks*ww=vxDuq ",
" :M3s3mwwk/x4y$ ",
" _2;<;zwwd^noiI ",
" >}%(%Kww;15f0a ",
" ~{&[&Hwwtn4.Ch ",
" LFt!t)(Hx5f+,g ",
" :J/v/%ww{f@#Gp ",
" qAbxx[ww|@#c]q ",
" _9D4o--+#c]l ",
" Euyi0C,G]l ",
" q8Iahgpq ",
" ",
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

View file

@ -0,0 +1,92 @@
/* XPM */
static char *image_xpm[] = {
/* width height ncolors chars_per_pixel */
"16 16 71 1",
" c #00ffff",
". c #8e468f",
"+ c #edd8ed",
"@ c #8d358e",
"# c #f4e6f4",
"$ c #a74fa8",
"% c #a950aa",
"& c #d5d5ac",
"* c #a952aa",
"= c #f0e3f0",
"- c #acb4ae",
"; c #e2afe2",
"> c #712472",
", c #f2dbf2",
"' c #f0d4f0",
") c #7c2d7d",
"! c #ee9def",
"~ c #7e2e7e",
"{ c #d36ed4",
"] c #eb91ec",
"^ c #f0d5f0",
"/ c #9f3c9f",
"( c #752775",
"_ c #cb67cc",
": c #eea5ef",
"< c #e8d1e8",
"[ c #965297",
"} c #a650a7",
"| c #c1c4ac",
"1 c #d56fd5",
"2 c #f3e3f3",
"3 c #fefbfe",
"4 c #7f3080",
"5 c #ecd2ec",
"6 c #d26bd3",
"7 c #7e307f",
"8 c #eebeee",
"9 c #a850a9",
"0 c #7a2b7b",
"a c #e9e5ab",
"b c #953896",
"c c #fa9bfb",
"d c #b5bbad",
"e c #bc70bd",
"f c #fa98fb",
"g c #904e91",
"h c #e698e7",
"i c #e5e2ab",
"j c #faaefb",
"k c #dd98de",
"l c #e4cae4",
"m c #e6cce6",
"n c #7c2e7c",
"o c #ccceac",
"p c #faabfb",
"q c #9ca7ae",
"r c #bb6fbc",
"s c #cf88cf",
"t c #9c3c9d",
"u c #e990ea",
"v c #e3ace3",
"w c #f7f0ab",
"x c #d16ad2",
"y c #fa9ffb",
"z c #ebd1eb",
"A c #acb5ad",
"B c #8a99ae",
"C c #fa99fb",
"D c #f2e0f3",
"E c #98a4ae",
"F c #d16dd2",
" ",
" 3 ",
" ,s= ",
" ,svs2 ",
" 's8j]sD ",
" w&-B s;pffus#",
" }r:cfChg",
" wa&|AE $Fr:y![n",
" *x1ek.t~",
" wiodq l96{7/@)",
" <%_~b0^",
" +94(z ",
" 5>m ",
" ",
" ",
" ",
};

View file

@ -646,6 +646,9 @@
<None Include="Resources\Cut.png" />
<Content Include="Resources\DB2.ico" />
<None Include="Resources\ScriptCompile.png" />
<None Include="Resources\ScriptConstant.xpm" />
<None Include="Resources\ScriptError.xpm" />
<None Include="Resources\ScriptKeyword.xpm" />
<None Include="Resources\ScriptPalette.png" />
<None Include="Resources\SaveAll.png" />
<None Include="Resources\SaveScript.png" />

View file

@ -2215,6 +2215,10 @@ namespace CodeImp.DoomBuilder.Controls
}
// Clean up
// Why does this crash?
//ClearRegisteredImages();
// Dispose unmanaged elements
if(controlptr != IntPtr.Zero) General.DestroyWindow(controlptr);
if(libraryptr != IntPtr.Zero) General.FreeLibrary(libraryptr);

View file

@ -31,6 +31,7 @@ using CodeImp.DoomBuilder.IO;
using System.Collections;
using System.Globalization;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Properties;
#endregion
@ -43,6 +44,14 @@ namespace CodeImp.DoomBuilder.Controls
private const string LEXERS_RESOURCE = "Lexers.cfg";
private const int DEFAULT_STYLE = (int)ScriptStylesCommon.Default;
private const int MAX_BACKTRACK_LENGTH = 200;
// Index for registered images
private enum ImageIndex : int
{
ScriptConstant = 0,
ScriptKeyword = 1,
ScriptError = 2
}
#endregion
@ -91,7 +100,7 @@ namespace CodeImp.DoomBuilder.Controls
// because the control is not really loaded in design mode
scriptedit.AutoCMaximumHeight = 8;
scriptedit.AutoCSeparator = ' ';
scriptedit.AutoCTypeSeparator = ',';
scriptedit.AutoCTypeSeparator = '?';
scriptedit.CaretWidth = 2;
scriptedit.EndAtLastLine = 1;
scriptedit.EndOfLineMode = ScriptEndOfLine.CRLF;
@ -109,21 +118,33 @@ namespace CodeImp.DoomBuilder.Controls
scriptedit.IsViewEOL = false;
scriptedit.IsVScrollBar = true;
scriptedit.SetFoldFlags((int)ScriptFoldFlag.Box);
// Symbol margin
scriptedit.SetMarginTypeN(0, (int)ScriptMarginType.Symbol);
scriptedit.SetMarginWidthN(0, 20);
scriptedit.SetMarginMaskN(0, -1); // all
// Line numbers margin
scriptedit.SetMarginTypeN(1, (int)ScriptMarginType.Number);
scriptedit.SetMarginTypeN(2, (int)ScriptMarginType.Symbol);
scriptedit.SetMarginWidthN(0, 16);
scriptedit.SetMarginWidthN(1, 40);
scriptedit.SetMarginMaskN(1, 0); // none
// Spacing margin
scriptedit.SetMarginTypeN(2, (int)ScriptMarginType.Symbol);
scriptedit.SetMarginWidthN(2, 5);
//scriptedit.AddIgnoredKey(Keys.ControlKey, Keys.None);
//scriptedit.AddIgnoredKey(Keys.Space, Keys.None);
//scriptedit.AddIgnoredKey(Keys.Space, Keys.Control);
scriptedit.SetMarginMaskN(2, 0); // none
// Events
scriptedit.TextChanged += new EventHandler(scriptedit_TextChanged);
// Setup with default script config
// Disabled, the form designer doesn't like this
//SetupStyles(new ScriptConfiguration());
// Images
RegisterAutoCompleteImage(ImageIndex.ScriptConstant, Resources.ScriptConstant);
RegisterAutoCompleteImage(ImageIndex.ScriptKeyword, Resources.ScriptKeyword);
RegisterMarkerImage(ImageIndex.ScriptError, Resources.ScriptError);
}
#endregion
@ -138,6 +159,7 @@ namespace CodeImp.DoomBuilder.Controls
Configuration lexercfg = new Configuration();
List<string> autocompletelist = new List<string>();
string[] resnames;
int imageindex;
// Make collections
stylelookup = new Dictionary<int, ScriptStyleType>();
@ -229,6 +251,7 @@ namespace CodeImp.DoomBuilder.Controls
}
// Create the keywords list and apply it
imageindex = (int)ImageIndex.ScriptKeyword;
int keywordsindex = lexercfg.ReadSetting(lexername + ".keywordsindex", -1);
if(keywordsindex > -1)
{
@ -237,13 +260,14 @@ namespace CodeImp.DoomBuilder.Controls
{
if(keywordslist.Length > 0) keywordslist.Append(" ");
keywordslist.Append(k);
autocompletelist.Add(k);
autocompletelist.Add(k + "?" + imageindex.ToString(CultureInfo.InvariantCulture));
}
string words = keywordslist.ToString();
scriptedit.KeyWords(keywordsindex, words.ToLowerInvariant());
}
// Create the constants list and apply it
imageindex = (int)ImageIndex.ScriptConstant;
int constantsindex = lexercfg.ReadSetting(lexername + ".constantsindex", -1);
if(constantsindex > -1)
{
@ -252,7 +276,7 @@ namespace CodeImp.DoomBuilder.Controls
{
if(constantslist.Length > 0) constantslist.Append(" ");
constantslist.Append(c);
autocompletelist.Add(c);
autocompletelist.Add(c + "?" + imageindex.ToString(CultureInfo.InvariantCulture));
}
string words = constantslist.ToString();
scriptedit.KeyWords(constantsindex, words.ToLowerInvariant());
@ -422,6 +446,26 @@ namespace CodeImp.DoomBuilder.Controls
scriptedit.EmptyUndoBuffer();
}
// This registers an XPM image for the autocomplete list
private unsafe void RegisterAutoCompleteImage(ImageIndex index, byte[] imagedata)
{
// Convert to string
string bigstring = Encoding.UTF8.GetString(imagedata);
// Register image
scriptedit.RegisterImage((int)index, bigstring);
}
// This registers an XPM image for the markes list
private unsafe void RegisterMarkerImage(ImageIndex index, byte[] imagedata)
{
// Convert to string
string bigstring = Encoding.UTF8.GetString(imagedata);
// Register image
scriptedit.MarkerDefinePixmap((int)index, bigstring);
}
#endregion
#region ================== Events
@ -456,6 +500,8 @@ namespace CodeImp.DoomBuilder.Controls
// CTRL+Space to autocomplete
if((e.KeyCode == Keys.Space) && (e.Modifiers == Keys.Control))
{
scriptedit.MarkerAdd(scriptedit.LineFromPosition(scriptedit.CurrentPos), (int)ImageIndex.ScriptError);
// Hide call tip if any
scriptedit.CallTipCancel();

View file

@ -249,6 +249,27 @@ namespace CodeImp.DoomBuilder.Properties {
}
}
internal static byte[] ScriptConstant {
get {
object obj = ResourceManager.GetObject("ScriptConstant", resourceCulture);
return ((byte[])(obj));
}
}
internal static byte[] ScriptError {
get {
object obj = ResourceManager.GetObject("ScriptError", resourceCulture);
return ((byte[])(obj));
}
}
internal static byte[] ScriptKeyword {
get {
object obj = ResourceManager.GetObject("ScriptKeyword", resourceCulture);
return ((byte[])(obj));
}
}
internal static System.Drawing.Bitmap ScriptPalette {
get {
object obj = ResourceManager.GetObject("ScriptPalette", resourceCulture);

View file

@ -256,4 +256,13 @@
<data name="ScriptCompile" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ScriptCompile.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ScriptConstant" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ScriptConstant.xpm;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="ScriptError" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ScriptError.xpm;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="ScriptKeyword" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ScriptKeyword.xpm;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>

View file

@ -0,0 +1,95 @@
/* XPM */
static char *image_xpm[] = {
/* width height ncolors chars_per_pixel */
"16 16 74 1",
" c #00ffff",
". c #eceff4",
"+ c #e5e8ee",
"@ c #4e607a",
"# c #fbfbfc",
"$ c #c4ccda",
"% c #a2adc4",
"& c #3f546e",
"* c #8494ad",
"= c #8796af",
"- c #ffffff",
"; c #d3dae3",
"> c #485c75",
", c #93a2bb",
"' c #9da9c1",
") c #96a3bc",
"! c #eceff3",
"~ c #dce0e8",
"{ c #556880",
"] c #f4f6f8",
"^ c #9ba8bf",
"/ c #dce0e9",
"( c #52667e",
"_ c #e4e7ee",
": c #a6b1c6",
"< c #586a83",
"[ c #ccd2df",
"} c #b5bdc8",
"| c #b5bed0",
"1 c #40546e",
"2 c #adb8cc",
"3 c #9fabc3",
"4 c #edeff3",
"5 c #ccd3df",
"6 c #e4e8ef",
"7 c #8b9ab3",
"8 c #d8dde6",
"9 c #f4f5f8",
"0 c #acb8cb",
"a c #798aa3",
"b c #909eb7",
"c c #d3d9e3",
"d c #d4d9e3",
"e c #e4e8ee",
"f c #fafbfc",
"g c #aab4c9",
"h c #3b4f6a",
"i c #d3d9e4",
"j c #b4bed0",
"k c #e5e7ee",
"l c #374b67",
"m c #334863",
"n c #a5b1c6",
"o c #52657e",
"p c #a9b4c9",
"q c #dce1e9",
"r c #66778e",
"s c #435771",
"t c #a4aeba",
"u c #5d7088",
"v c #f5f6f9",
"w c #465a73",
"x c #8e9cb5",
"y c #7f8fa8",
"z c #394e68",
"A c #ccd2de",
"B c #c5ccda",
"C c #a3afc5",
"D c #3e536d",
"E c #bcc5d5",
"F c #8998b2",
"G c #ccd3de",
"H c #cbd3df",
"I c #dbe1e9",
" ",
" ",
" ",
" ",
" 8p%^,xF*ya} ",
" g--f9!k~d5r ",
" C-#v._IiABu ",
" '#].(&mG$E{ ",
" )]46/cHBE|@ ",
" b!e~o1mEj0w ",
" 7+qd[$E|2nD ",
" =/;G$E|0:3z ",
" }u<o@>sDhlt ",
" ",
" ",
" ",
};

View file

@ -0,0 +1,100 @@
/* XPM */
static char *image_xpm[] = {
/* width height ncolors chars_per_pixel */
"16 16 79 1",
" c #00ffff",
". c #f33b00",
"+ c #ea3900",
"@ c #ee3a00",
"# c #e43600",
"$ c #ba7a64",
"% c #ff8b65",
"& c #ff7c52",
"* c #ffbea9",
"= c #ffa183",
"- c #f87247",
"; c #ff9a79",
"> c #d49b8a",
", c #bd3306",
"' c #f1ab95",
") c #ff6a39",
"! c #ff6f41",
"~ c #d19481",
"{ c #fb7950",
"] c #7c250a",
"^ c #fe5c28",
"/ c #ff5f2c",
"( c #ff8e69",
"_ c #dc9d89",
": c #e5b6a7",
"< c #ff9c7c",
"[ c #fe7f56",
"} c #fb8660",
"| c #fa8059",
"1 c #fd5721",
"2 c #f29679",
"3 c #ffa487",
"4 c #fa4409",
"5 c #fb480d",
"6 c #e0ad9d",
"7 c #dc957e",
"8 c #b9725a",
"9 c #bb5a3b",
"0 c #e23903",
"a c #77311b",
"b c #e35a2e",
"c c #b62f05",
"d c #feb8a2",
"e c #fed8cc",
"f c #f83e02",
"g c #7f2e14",
"h c #6e2a14",
"i c #d03c0c",
"j c #dda797",
"k c #fec7b5",
"l c #b27967",
"m c #fed3c5",
"n c #fb5018",
"o c #f94107",
"p c #a45f49",
"q c #f2d8cf",
"r c #ddaa9b",
"s c #ffa88d",
"t c #ff6d3e",
"u c #ac4d2e",
"v c #ff612d",
"w c #fefefe",
"x c #fd521b",
"y c #b8411c",
"z c #ffc4b1",
"A c #c66b50",
"B c #d48c75",
"C c #dc3602",
"D c #dd4c1c",
"E c #d4947f",
"F c #ee734c",
"G c #962a09",
"H c #ff8660",
"I c #933e23",
"J c #d9704d",
"K c #ffb197",
"L c #d58970",
"M c #e5a38d",
"N c #ecc2b4",
" ",
" e6_>~L~e ",
" NjM2}{FJA7 ",
" Nr'3;%&tvb9B ",
" qj'Ks*ww=vxDuq ",
" :M3s3mwwk/x4y$ ",
" _2;<;zwwd^noiI ",
" >}%(%Kww;15f0a ",
" ~{&[&Hwwtn4.Ch ",
" LFt!t)(Hx5f+,g ",
" :J/v/%ww{f@#Gp ",
" qAbxx[ww|@#c]q ",
" _9D4o--+#c]l ",
" Euyi0C,G]l ",
" q8Iahgpq ",
" ",
};

View file

@ -0,0 +1,92 @@
/* XPM */
static char *image_xpm[] = {
/* width height ncolors chars_per_pixel */
"16 16 71 1",
" c #00ffff",
". c #8e468f",
"+ c #edd8ed",
"@ c #8d358e",
"# c #f4e6f4",
"$ c #a74fa8",
"% c #a950aa",
"& c #d5d5ac",
"* c #a952aa",
"= c #f0e3f0",
"- c #acb4ae",
"; c #e2afe2",
"> c #712472",
", c #f2dbf2",
"' c #f0d4f0",
") c #7c2d7d",
"! c #ee9def",
"~ c #7e2e7e",
"{ c #d36ed4",
"] c #eb91ec",
"^ c #f0d5f0",
"/ c #9f3c9f",
"( c #752775",
"_ c #cb67cc",
": c #eea5ef",
"< c #e8d1e8",
"[ c #965297",
"} c #a650a7",
"| c #c1c4ac",
"1 c #d56fd5",
"2 c #f3e3f3",
"3 c #fefbfe",
"4 c #7f3080",
"5 c #ecd2ec",
"6 c #d26bd3",
"7 c #7e307f",
"8 c #eebeee",
"9 c #a850a9",
"0 c #7a2b7b",
"a c #e9e5ab",
"b c #953896",
"c c #fa9bfb",
"d c #b5bbad",
"e c #bc70bd",
"f c #fa98fb",
"g c #904e91",
"h c #e698e7",
"i c #e5e2ab",
"j c #faaefb",
"k c #dd98de",
"l c #e4cae4",
"m c #e6cce6",
"n c #7c2e7c",
"o c #ccceac",
"p c #faabfb",
"q c #9ca7ae",
"r c #bb6fbc",
"s c #cf88cf",
"t c #9c3c9d",
"u c #e990ea",
"v c #e3ace3",
"w c #f7f0ab",
"x c #d16ad2",
"y c #fa9ffb",
"z c #ebd1eb",
"A c #acb5ad",
"B c #8a99ae",
"C c #fa99fb",
"D c #f2e0f3",
"E c #98a4ae",
"F c #d16dd2",
" ",
" 3 ",
" ,s= ",
" ,svs2 ",
" 's8j]sD ",
" w&-B s;pffus#",
" }r:cfChg",
" wa&|AE $Fr:y![n",
" *x1ek.t~",
" wiodq l96{7/@)",
" <%_~b0^",
" +94(z ",
" 5>m ",
" ",
" ",
" ",
};