Fixed and closed #379: positional parameterized snippets are now inserted on a single line by default.
This commit is contained in:
parent
9738b0470b
commit
cd75e9df29
2 changed files with 23 additions and 6 deletions
|
@ -16,5 +16,5 @@ using System.Reflection;
|
|||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("3.0.0.350")]
|
||||
[assembly: AssemblyFileVersion("3.0.0.350")]
|
||||
[assembly: AssemblyVersion("3.0.0.351")]
|
||||
[assembly: AssemblyFileVersion("3.0.0.351")]
|
||||
|
|
|
@ -203,26 +203,43 @@ namespace ScrewTurn.Wiki {
|
|||
label, s.Name);
|
||||
}
|
||||
else {
|
||||
bool isPositional = IsSnippetPositional(parameters);
|
||||
label = string.Format("{0} ({1} {2})", s.Name, paramCount, Properties.Messages.Parameters);
|
||||
sb.AppendFormat(@"<a href=""#"" title=""{0}"" onclick=""javascript:return InsertMarkup('{s:{1}\n{2}}');"" class=""menulink"">{0}</a>",
|
||||
label, s.Name, GetParametersPlaceHolders(parameters));
|
||||
sb.AppendFormat(@"<a href=""#"" title=""{0}"" onclick=""javascript:return InsertMarkup('{s:{1}{2}{3}}');"" class=""menulink"">{0}</a>",
|
||||
label, s.Name, isPositional ? "" : "\\r\\n", GetParametersPlaceHolders(parameters, isPositional));
|
||||
}
|
||||
}
|
||||
if(sb.Length == 0) sb.Append("<i>" + Properties.Messages.NoSnippets + "</i>");
|
||||
lblSnippets.Text = sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the parameters of a snippet are positional or not.
|
||||
/// </summary>
|
||||
/// <param name="parameters">The parameters.</param>
|
||||
/// <returns><c>true</c> if the parameters are positional, <c>false</c> otherwise.</returns>
|
||||
private static bool IsSnippetPositional(string[] parameters) {
|
||||
int dummy;
|
||||
for(int i = 0; i < parameters.Length; i++) {
|
||||
if(!int.TryParse(parameters[i], out dummy)) return false;
|
||||
if(dummy != i + 1) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the placeholder for snippet parameters.
|
||||
/// </summary>
|
||||
/// <param name="parameters">The parameters.</param>
|
||||
/// <param name="isSnippetPositional">A value indicating whether the snippet parameters are positional.</param>
|
||||
/// <returns>The snippet placeholder/template.</returns>
|
||||
private static string GetParametersPlaceHolders(string[] parameters) {
|
||||
private static string GetParametersPlaceHolders(string[] parameters, bool isSnippetPositional) {
|
||||
if(parameters.Length == 0) return "";
|
||||
else {
|
||||
StringBuilder sb = new StringBuilder(20);
|
||||
foreach(string param in parameters) {
|
||||
sb.AppendFormat("| {0} = PLACE YOUR VALUE HERE\\r\\n", param);
|
||||
if(isSnippetPositional) sb.AppendFormat("|PLACE YOUR VALUE HERE ({0})", param);
|
||||
else sb.AppendFormat("| {0} = PLACE YOUR VALUE HERE\\r\\n", param);
|
||||
}
|
||||
/*for(int i = 1; i <= paramCount; i++) {
|
||||
sb.Append("|P");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue