show descriptions in Lua functions list

This commit is contained in:
adelikat 2014-01-25 20:04:26 +00:00
parent ee1cea5d08
commit e22227160d
4 changed files with 96 additions and 90 deletions

View File

@ -16,10 +16,9 @@ namespace BizHawk.Client.Common
public void Add(string method_lib, string method_name, System.Reflection.MethodInfo method, string description) public void Add(string method_lib, string method_name, System.Reflection.MethodInfo method, string description)
{ {
var f = new LibraryFunction(method_lib, method_name, method); FunctionList.Add(
FunctionList.Add(f); new LibraryFunction(method_lib, method_name, method, description)
);
// TODO: use description;
} }
public void Clear() public void Clear()
@ -32,15 +31,9 @@ namespace BizHawk.Client.Common
FunctionList = FunctionList.OrderBy(x => x.Library).ThenBy(x => x.Name).ToList(); FunctionList = FunctionList.OrderBy(x => x.Library).ThenBy(x => x.Name).ToList();
} }
public List<string> GetLibraryList() public IEnumerable<string> GetLibraryList()
{ {
var libs = new HashSet<string>(); return FunctionList.Select(x => x.Library);
foreach (var function in FunctionList)
{
libs.Add(function.Library);
}
return libs.ToList();
} }
public List<string> GetFunctionsByLibrary(string library) public List<string> GetFunctionsByLibrary(string library)
@ -50,7 +43,7 @@ namespace BizHawk.Client.Common
public class LibraryFunction public class LibraryFunction
{ {
public LibraryFunction(string method_lib, string method_name, System.Reflection.MethodInfo method) public LibraryFunction(string method_lib, string method_name, System.Reflection.MethodInfo method, string description)
{ {
Library = method_lib; Library = method_lib;
Name = method_name; Name = method_name;
@ -61,6 +54,8 @@ namespace BizHawk.Client.Common
} }
return_type = method.ReturnType.ToString(); return_type = method.ReturnType.ToString();
Description = description;
} }
public string Library = String.Empty; public string Library = String.Empty;
@ -68,6 +63,8 @@ namespace BizHawk.Client.Common
public List<string> Parameters = new List<string>(); public List<string> Parameters = new List<string>();
public string return_type = String.Empty; public string return_type = String.Empty;
public string Description { get; set; }
public string ParameterList public string ParameterList
{ {
get get

View File

@ -28,84 +28,91 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LuaFunctionsForm)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LuaFunctionsForm));
this.OK = new System.Windows.Forms.Button(); this.OK = new System.Windows.Forms.Button();
this.directoryEntry1 = new System.DirectoryServices.DirectoryEntry(); this.directoryEntry1 = new System.DirectoryServices.DirectoryEntry();
this.FunctionView = new System.Windows.Forms.ListView(); this.FunctionView = new System.Windows.Forms.ListView();
this.LibraryReturn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.LibraryReturn = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.LibraryHead = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.LibraryHead = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.LibraryName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.LibraryName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.LibraryParameters = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.LibraryParameters = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.SuspendLayout(); this.LibraryDescription = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
// this.SuspendLayout();
// OK //
// // OK
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); //
this.OK.Location = new System.Drawing.Point(434, 284); this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.OK.Name = "OK"; this.OK.Location = new System.Drawing.Point(647, 309);
this.OK.Size = new System.Drawing.Size(75, 23); this.OK.Name = "OK";
this.OK.TabIndex = 0; this.OK.Size = new System.Drawing.Size(75, 23);
this.OK.Text = "&Ok"; this.OK.TabIndex = 0;
this.OK.UseVisualStyleBackColor = true; this.OK.Text = "&Ok";
this.OK.Click += new System.EventHandler(this.OK_Click); this.OK.UseVisualStyleBackColor = true;
// this.OK.Click += new System.EventHandler(this.OK_Click);
// FunctionView //
// // FunctionView
this.FunctionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) //
this.FunctionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.FunctionView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.FunctionView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.LibraryReturn, this.LibraryReturn,
this.LibraryHead, this.LibraryHead,
this.LibraryName, this.LibraryName,
this.LibraryParameters}); this.LibraryParameters,
this.FunctionView.FullRowSelect = true; this.LibraryDescription});
this.FunctionView.GridLines = true; this.FunctionView.FullRowSelect = true;
this.FunctionView.Location = new System.Drawing.Point(12, 12); this.FunctionView.GridLines = true;
this.FunctionView.Name = "FunctionView"; this.FunctionView.Location = new System.Drawing.Point(12, 12);
this.FunctionView.Size = new System.Drawing.Size(497, 266); this.FunctionView.Name = "FunctionView";
this.FunctionView.TabIndex = 1; this.FunctionView.Size = new System.Drawing.Size(710, 291);
this.FunctionView.UseCompatibleStateImageBehavior = false; this.FunctionView.TabIndex = 1;
this.FunctionView.View = System.Windows.Forms.View.Details; this.FunctionView.UseCompatibleStateImageBehavior = false;
this.FunctionView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.FunctionView_ColumnClick); this.FunctionView.View = System.Windows.Forms.View.Details;
this.FunctionView.SelectedIndexChanged += new System.EventHandler(this.FunctionView_SelectedIndexChanged); this.FunctionView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.FunctionView_ColumnClick);
this.FunctionView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FunctionView_KeyDown); this.FunctionView.SelectedIndexChanged += new System.EventHandler(this.FunctionView_SelectedIndexChanged);
// this.FunctionView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FunctionView_KeyDown);
// LibraryReturn //
// // LibraryReturn
this.LibraryReturn.Text = "Return"; //
// this.LibraryReturn.Text = "Return";
// LibraryHead //
// // LibraryHead
this.LibraryHead.Text = "Library"; //
this.LibraryHead.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.LibraryHead.Text = "Library";
this.LibraryHead.Width = 85; this.LibraryHead.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
// this.LibraryHead.Width = 68;
// LibraryName //
// // LibraryName
this.LibraryName.Text = "Name"; //
this.LibraryName.Width = 131; this.LibraryName.Text = "Name";
// this.LibraryName.Width = 131;
// LibraryParameters //
// // LibraryParameters
this.LibraryParameters.Text = "Parameters"; //
this.LibraryParameters.Width = 217; this.LibraryParameters.Text = "Parameters";
// this.LibraryParameters.Width = 170;
// LuaFunctionsForm //
// // LibraryDescription
this.AcceptButton = this.OK; //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.LibraryDescription.Text = "Description";
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.LibraryDescription.Width = 296;
this.ClientSize = new System.Drawing.Size(521, 319); //
this.Controls.Add(this.FunctionView); // LuaFunctionsForm
this.Controls.Add(this.OK); //
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.AcceptButton = this.OK;
this.MinimumSize = new System.Drawing.Size(200, 50); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.Name = "LuaFunctionsForm"; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.ClientSize = new System.Drawing.Size(730, 340);
this.Text = "Lua Functions"; this.Controls.Add(this.FunctionView);
this.Load += new System.EventHandler(this.LuaFunctionList_Load); this.Controls.Add(this.OK);
this.ResumeLayout(false); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MinimumSize = new System.Drawing.Size(200, 50);
this.Name = "LuaFunctionsForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Lua Functions";
this.Load += new System.EventHandler(this.LuaFunctionList_Load);
this.ResumeLayout(false);
} }
@ -118,5 +125,6 @@
private System.Windows.Forms.ColumnHeader LibraryReturn; private System.Windows.Forms.ColumnHeader LibraryReturn;
private System.Windows.Forms.ColumnHeader LibraryName; private System.Windows.Forms.ColumnHeader LibraryName;
private System.Windows.Forms.ColumnHeader LibraryParameters; private System.Windows.Forms.ColumnHeader LibraryParameters;
private System.Windows.Forms.ColumnHeader LibraryDescription;
} }
} }

View File

@ -24,12 +24,13 @@ namespace BizHawk.Client.EmuHawk
private void PopulateListView() private void PopulateListView()
{ {
FunctionView.Items.Clear(); FunctionView.Items.Clear();
foreach (LuaDocumentation.LibraryFunction l in GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList) foreach (var l in GlobalWin.Tools.LuaConsole.LuaImp.Docs.FunctionList)
{ {
ListViewItem item = new ListViewItem {Text = l.ReturnType}; ListViewItem item = new ListViewItem {Text = l.ReturnType};
item.SubItems.Add(l.Library + "."); item.SubItems.Add(l.Library + ".");
item.SubItems.Add(l.Name); item.SubItems.Add(l.Name);
item.SubItems.Add(l.ParameterList); item.SubItems.Add(l.ParameterList);
item.SubItems.Add(l.Description);
FunctionView.Items.Add(item); FunctionView.Items.Add(item);
} }
} }

View File

@ -442,7 +442,7 @@ namespace BizHawk.Client.EmuHawk
private void GenerateLibraryRegex() private void GenerateLibraryRegex()
{ {
StringBuilder list = new StringBuilder(); StringBuilder list = new StringBuilder();
List<string> Libs = GlobalWin.Tools.LuaConsole.LuaImp.Docs.GetLibraryList(); List<string> Libs = GlobalWin.Tools.LuaConsole.LuaImp.Docs.GetLibraryList().ToList();
for (int i = 0; i < Libs.Count; i++) for (int i = 0; i < Libs.Count; i++)
{ {
list.Append(Libs[i]); list.Append(Libs[i]);
@ -820,7 +820,7 @@ namespace BizHawk.Client.EmuHawk
String currentWord = CurrentWord(); String currentWord = CurrentWord();
currentWord += e.KeyCode; currentWord += e.KeyCode;
currentWord = currentWord.ToLower(); currentWord = currentWord.ToLower();
List<string> libList = GlobalWin.Tools.LuaConsole.LuaImp.Docs.GetLibraryList(); List<string> libList = GlobalWin.Tools.LuaConsole.LuaImp.Docs.GetLibraryList().ToList();
int x = LuaText.GetPositionFromCharIndex(LuaText.SelectionStart).X + LuaText.Location.X + 5; int x = LuaText.GetPositionFromCharIndex(LuaText.SelectionStart).X + LuaText.Location.X + 5;
int y = LuaText.GetPositionFromCharIndex(LuaText.SelectionStart).Y + LuaText.Location.Y + (int)LuaText.Font.GetHeight() + 5; // One row down int y = LuaText.GetPositionFromCharIndex(LuaText.SelectionStart).Y + LuaText.Location.Y + (int)LuaText.Font.GetHeight() + 5; // One row down
@ -893,7 +893,7 @@ namespace BizHawk.Client.EmuHawk
private bool IsLibraryWord(string word) private bool IsLibraryWord(string word)
{ {
List<string> Libs = GlobalWin.Tools.LuaConsole.LuaImp.Docs.GetLibraryList(); List<string> Libs = GlobalWin.Tools.LuaConsole.LuaImp.Docs.GetLibraryList().ToList();
if (Libs.Contains(word)) if (Libs.Contains(word))
{ {
return true; return true;