Subversion Repositories LassyPad

Compare Revisions

Ignore whitespace Rev 7 → Rev 9

/LassyPad/bin/Debug/LassyPad.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/LassyPad/bin/Debug/LassyPad.pdb
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/LassyPad/bin/Debug/icons/Thumbs.db
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/LassyPad/obj/x86/Debug/LassyPad.exe
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/LassyPad/obj/x86/Debug/LassyPad.csproj.GenerateResource.Cache
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/LassyPad/obj/x86/Debug/LassyPad.pdb
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/LassyPad/obj/x86/Debug/LassyPad.MainForm.resources
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/LassyPad/MainForm.Designer.cs
43,6 → 43,7
this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
this.toolStripButton3 = new System.Windows.Forms.ToolStripButton();
this.toolStripButton4 = new System.Windows.Forms.ToolStripButton();
this.toolStripButton9 = new System.Windows.Forms.ToolStripButton();
this.formatBar = new System.Windows.Forms.ToolStrip();
this.sizeF = new System.Windows.Forms.ToolStripTextBox();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
65,6 → 66,7
this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.wordWrapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.syntaxHighlightingToolStripMenuItem = new System.Windows.Forms.ToolStripComboBox();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.tabControl = new System.Windows.Forms.TabControl();
104,10 → 106,11
this.toolStripButton1,
this.toolStripButton2,
this.toolStripButton3,
this.toolStripButton4});
this.fileBar.Location = new System.Drawing.Point(3, 0);
this.toolStripButton4,
this.toolStripButton9});
this.fileBar.Location = new System.Drawing.Point(3, 25);
this.fileBar.Name = "fileBar";
this.fileBar.Size = new System.Drawing.Size(104, 25);
this.fileBar.Size = new System.Drawing.Size(127, 25);
this.fileBar.TabIndex = 1;
this.fileBar.Text = "toolStrip1";
//
155,6 → 158,17
this.toolStripButton4.ToolTipText = "Close File";
this.toolStripButton4.Click += new System.EventHandler(this.ToolStripButton4Click);
//
// toolStripButton9
//
this.toolStripButton9.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.toolStripButton9.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton9.Image")));
this.toolStripButton9.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton9.Name = "toolStripButton9";
this.toolStripButton9.Size = new System.Drawing.Size(23, 22);
this.toolStripButton9.Text = "toolStripButton9";
this.toolStripButton9.ToolTipText = "Save All";
this.toolStripButton9.Click += new System.EventHandler(this.ToolStripButton9Click);
//
// formatBar
//
this.formatBar.Dock = System.Windows.Forms.DockStyle.None;
172,7 → 186,7
this.toolStripButton7,
this.toolStripSeparator1,
this.toolStripButton8});
this.formatBar.Location = new System.Drawing.Point(107, 0);
this.formatBar.Location = new System.Drawing.Point(3, 0);
this.formatBar.Name = "formatBar";
this.formatBar.Size = new System.Drawing.Size(272, 25);
this.formatBar.TabIndex = 2;
198,8 → 212,8
this.textColourF.Name = "textColourF";
this.textColourF.Size = new System.Drawing.Size(23, 22);
this.textColourF.Text = "A";
this.textColourF.ToolTipText = "Set Text Colour";
this.textColourF.Click += new System.EventHandler(this.ToolStripButton9Click);
this.textColourF.ToolTipText = "Text Colour";
this.textColourF.Click += new System.EventHandler(this.TextColourFClick);
//
// toolStripSeparator4
//
343,7 → 357,8
// editorToolStripMenuItem
//
this.editorToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.wordWrapToolStripMenuItem});
this.wordWrapToolStripMenuItem,
this.syntaxHighlightingToolStripMenuItem});
this.editorToolStripMenuItem.Name = "editorToolStripMenuItem";
this.editorToolStripMenuItem.Size = new System.Drawing.Size(47, 20);
this.editorToolStripMenuItem.Text = "Editor";
353,10 → 368,21
this.wordWrapToolStripMenuItem.Checked = true;
this.wordWrapToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
this.wordWrapToolStripMenuItem.Name = "wordWrapToolStripMenuItem";
this.wordWrapToolStripMenuItem.Size = new System.Drawing.Size(140, 22);
this.wordWrapToolStripMenuItem.Size = new System.Drawing.Size(237, 22);
this.wordWrapToolStripMenuItem.Text = "Word Wrap";
this.wordWrapToolStripMenuItem.Click += new System.EventHandler(this.WordWrapToolStripMenuItemClick);
//
// syntaxHighlightingToolStripMenuItem
//
this.syntaxHighlightingToolStripMenuItem.Enabled = false;
this.syntaxHighlightingToolStripMenuItem.Items.AddRange(new object[] {
"None",
"Auto-Detect"});
this.syntaxHighlightingToolStripMenuItem.Name = "syntaxHighlightingToolStripMenuItem";
this.syntaxHighlightingToolStripMenuItem.Size = new System.Drawing.Size(177, 21);
this.syntaxHighlightingToolStripMenuItem.Text = "Syntax Highlighting";
this.syntaxHighlightingToolStripMenuItem.SelectedIndexChanged += new System.EventHandler(this.SyntaxHighlightingToolStripMenuItemSelectedIndexChanged);
//
// openFileDialog1
//
this.openFileDialog1.FileName = "openFileDialog1";
374,8 → 400,9
this.tabControl.Location = new System.Drawing.Point(0, 0);
this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0;
this.tabControl.Size = new System.Drawing.Size(502, 355);
this.tabControl.Size = new System.Drawing.Size(502, 330);
this.tabControl.TabIndex = 0;
this.tabControl.SelectedIndexChanged += new System.EventHandler(this.TabControlSelectedIndexChanged);
//
// welcomeTab
//
383,7 → 410,7
this.welcomeTab.Location = new System.Drawing.Point(4, 22);
this.welcomeTab.Name = "welcomeTab";
this.welcomeTab.Padding = new System.Windows.Forms.Padding(3);
this.welcomeTab.Size = new System.Drawing.Size(494, 329);
this.welcomeTab.Size = new System.Drawing.Size(494, 304);
this.welcomeTab.TabIndex = 0;
this.welcomeTab.Text = "Welcome";
this.welcomeTab.UseVisualStyleBackColor = true;
394,7 → 421,7
this.welcomeView.Location = new System.Drawing.Point(3, 3);
this.welcomeView.MinimumSize = new System.Drawing.Size(20, 20);
this.welcomeView.Name = "welcomeView";
this.welcomeView.Size = new System.Drawing.Size(488, 323);
this.welcomeView.Size = new System.Drawing.Size(488, 298);
this.welcomeView.TabIndex = 0;
//
// editorTab
403,7 → 430,7
this.editorTab.Location = new System.Drawing.Point(4, 22);
this.editorTab.Name = "editorTab";
this.editorTab.Padding = new System.Windows.Forms.Padding(3);
this.editorTab.Size = new System.Drawing.Size(494, 329);
this.editorTab.Size = new System.Drawing.Size(494, 304);
this.editorTab.TabIndex = 1;
this.editorTab.Text = "Editor";
this.editorTab.UseVisualStyleBackColor = true;
410,6 → 437,7
//
// editorView
//
this.editorView.AcceptsTab = true;
this.editorView.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.editorView.ContextMenuStrip = this.editorMenuStrip;
this.editorView.DetectUrls = false;
418,7 → 446,7
this.editorView.HideSelection = false;
this.editorView.Location = new System.Drawing.Point(3, 3);
this.editorView.Name = "editorView";
this.editorView.Size = new System.Drawing.Size(488, 323);
this.editorView.Size = new System.Drawing.Size(488, 298);
this.editorView.TabIndex = 0;
this.editorView.Text = "";
this.editorView.SelectionChanged += new System.EventHandler(this.EditorViewSelectionChanged);
482,7 → 510,7
this.treeView.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeView.Location = new System.Drawing.Point(0, 0);
this.treeView.Name = "treeView";
this.treeView.Size = new System.Drawing.Size(249, 355);
this.treeView.Size = new System.Drawing.Size(249, 330);
this.treeView.TabIndex = 0;
this.treeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.TreeViewNodeMouseClick);
//
499,7 → 527,7
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.tabControl);
this.splitContainer1.Size = new System.Drawing.Size(755, 355);
this.splitContainer1.Size = new System.Drawing.Size(755, 330);
this.splitContainer1.SplitterDistance = 249;
this.splitContainer1.TabIndex = 3;
//
509,7 → 537,7
// toolStripContainer1.ContentPanel
//
this.toolStripContainer1.ContentPanel.Controls.Add(this.splitContainer1);
this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(755, 355);
this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(755, 330);
this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.toolStripContainer1.Location = new System.Drawing.Point(0, 24);
this.toolStripContainer1.Name = "toolStripContainer1";
519,8 → 547,8
//
// toolStripContainer1.TopToolStripPanel
//
this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.formatBar);
this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.fileBar);
this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.formatBar);
//
// MainForm
//
553,6 → 581,8
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.ToolStripComboBox syntaxHighlightingToolStripMenuItem;
private System.Windows.Forms.ToolStripButton toolStripButton9;
private System.Windows.Forms.ToolStripButton textColourF;
private System.Windows.Forms.ColorDialog colorDialog1;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
/LassyPad/MainForm.cs
18,13 → 18,52
/// </summary>
public partial class MainForm : Form
{
public class word
{
public Color colour;
public List<string> words;
public word(Color colourN, string wordsN)
{
colour = colourN;
words = new List<string>();
string[] tempWords = wordsN.Split(',');
for (int i = 0; i < tempWords.Length; i++)
words.Add(tempWords[i]);
}
}
public class comment
{
public Color colour;
public string start;
public string end;
public comment(Color colourN, string startN, string endN)
{
colour = colourN;
start = startN;
end = endN;
}
public comment(Color colourN, string startN)
{
colour = colourN;
start = startN;
end = "\n";
}
}
public class rtfFile
{
public string loc;
public RichTextBox rtfBox;
public bool saved;
public bool isRtf;
public int syntax;
public rtfFile(string locN)
{
loc = locN;
34,7 → 73,15
public void save()
{
rtfBox.SaveFile(loc);
if (loc.EndsWith(".rtf"))
rtfBox.SaveFile(loc);
else
{
string str = rtfBox.Rtf;
rtfBox.Rtf = rtfBox.Text;
rtfBox.SaveFile(loc);
rtfBox.Rtf = str;
}
saved = true;
}
44,19 → 91,51
{
rtfBox.LoadFile(loc);
saved = true;
if (loc.EndsWith(".rtf"))
isRtf = true;
else
isRtf = false;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Load Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
try
{
System.IO.StreamReader reader = new System.IO.StreamReader(loc);
rtfBox.Text = reader.ReadToEnd();
// MessageBox.Show("File not loaded as RTF: " + ex.Message, "Load Notice", MessageBoxButtons.OK, MessageBoxIcon.Warning);
isRtf = false;
}
catch (Exception ex2)
{
MessageBox.Show(ex2.Message, "Load Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
return true;
}
}
public class syntax
{
public string id;
public List<word> words;
public List<comment> comments;
public syntax(string idN)
{
id = idN;
words = new List<MainForm.word>();
comments = new List<MainForm.comment>();
}
}
public List<rtfFile> files = new List<rtfFile>();
public int curFileID;
public List<syntax> syntaxes = new List<syntax>();
public int selectionStart;
public int selectionLength;
94,6 → 173,7
public void initAll()
{
initTreeView();
loadSyntaxes();
}
public void initTreeView()
107,6 → 187,42
treeView.Nodes.Add("Files", "Files");
}
public void loadSyntaxes()
{
System.IO.StreamReader reader = new System.IO.StreamReader("data/syntaxes.dat");
string r = reader.ReadToEnd();
string[] data = r.Split('\n');
string[] d, d2;
for (int i = 0; i < data.Length; i++)
{
data[i] = data[i].Replace("\r", "");
if (data[i].EndsWith(":"))
{
syntaxes.Add(new syntax(data[i].Substring(0, data[i].Length - 1)));
syntaxHighlightingToolStripMenuItem.Items.Add(data[i].Substring(0, data[i].Length - 1));
}
else
{
d = data[i].Split(' ');
switch (d[0])
{
case ("word"):
{
if (d.Length == 3)
syntaxes[syntaxes.Count - 1].words.Add(new word(Color.FromName(d[1]), d[2]));
else if (d.Length == 5)
{
d2 = d[1].Split(',');
syntaxes[syntaxes.Count - 1].words.Add(new word(Color.FromArgb(int.Parse(d2[0]), int.Parse(d2[1]), int.Parse(d2[2])), d[2]));
}
break;
}
}
}
}
}
void TreeViewNodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (e.Node.Level == 0)
173,6 → 289,10
tabControl.SelectedIndex = 1;
editorView.Rtf = files[fileID].rtfBox.Rtf;
curFileID = fileID;
if (files[curFileID].isRtf)
syntaxHighlightingToolStripMenuItem.Enabled = false;
else
syntaxHighlightingToolStripMenuItem.Enabled = true;
}
public void showFile(string filename)
184,6 → 304,10
{
editorView.Rtf = files[i].rtfBox.Rtf;
curFileID = i;
if (files[curFileID].isRtf)
syntaxHighlightingToolStripMenuItem.Enabled = false;
else
syntaxHighlightingToolStripMenuItem.Enabled = true;
return;
}
}
207,6 → 331,7
{
files.Add(new rtfFile("NewFile" + i.ToString() + ".rtf"));
treeView.Nodes["Files"].Nodes.Add("NewFile" + i.ToString() + ".rtf", "NewFile" + i.ToString() + ".rtf");
files[files.Count - 1].isRtf = true;
showFile(files.Count - 1);
return;
}
266,6 → 391,12
}
}
public void saveAll()
{
for (int i = 0; i < files.Count; i++)
files[i].save();
}
// format functions
public void addStyle(FontStyle newStyles)
440,7 → 571,7
#endregion
void ToolStripButton9Click(object sender, EventArgs e)
void TextColourFClick(object sender, EventArgs e)
{
DialogResult res = colorDialog1.ShowDialog();
if (res != DialogResult.Cancel)
449,5 → 580,73
editorView.SelectionColor = colorDialog1.Color;
}
}
void ToolStripButton9Click(object sender, EventArgs e)
{
saveAll();
}
void TabControlSelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl.SelectedIndex == 1 && files.Count == 0)
{
newFile();
}
}
void SyntaxHighlightingToolStripMenuItemSelectedIndexChanged(object sender, EventArgs e)
{
// clear own highlighting
files[curFileID].rtfBox.Rtf = editorView.Text;
files[curFileID].syntax = -1;
// sort out new stuff
if (syntaxHighlightingToolStripMenuItem.SelectedIndex == 1)
{
for (int i = 0; i < syntaxes.Count; i++)
{
if (files[curFileID].loc.EndsWith(syntaxes[i].id))
{
files[curFileID].syntax = i;
break;
}
}
}
else
files[curFileID].syntax = syntaxHighlightingToolStripMenuItem.SelectedIndex - 2;
applySyntax(curFileID);
showFile(curFileID);
}
public void applySyntax(int fileID)
{
if (files[fileID].isRtf)
return;
if (files[fileID].syntax == -1)
files[fileID].rtfBox.Rtf = files[fileID].rtfBox.Text;
else
{
int pos;
string[] data = files[fileID].rtfBox.Text.Split(new char[] { ' ', '\n' });
for (int i = 0; i < syntaxes[files[fileID].syntax].words.Count; i++)
{
pos = 0;
for (int j = 0; j < data.Length; j++)
{
if (syntaxes[files[fileID].syntax].words[i].words.Contains(data[j]))
{
files[fileID].rtfBox.Select(pos, data[j].Length);
files[fileID].rtfBox.SelectionColor = syntaxes[files[fileID].syntax].words[i].colour;
}
pos += data[j].Length + 1;
}
}
}
}
}
}
/LassyPad/MainForm.resx
156,6 → 156,15
Vk9hNcqhrwbq02Nae4Pc6wJDlo2KjrbsMAAAAABJRU5ErkJggg==
</value>
</data>
<data name="toolStripButton9.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAIhJREFUOE9jYBg+
YOmUlv8g38BoXD7Dqu5/NQNYM4hGNwCZD5OHqUexBCSIbgA2PkwzikXILkA2FZsBMJcSFXnYvESURpDz
QBhmAIxPKIAZnty7DtaEC4PkYRjDJf9/ATXCMDZDkORBhmA3YBXQEBhGNgRZHGgQcQYgayLaAGRv4GET
FRN0UwQAEFv9OJDo/4QAAAAASUVORK5CYII=
</value>
</data>
<metadata name="formatBar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>116, 17</value>
</metadata>