mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-28 16:58:01 +01:00
xmldoc and whitespace fixes
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Terminal.Gui {
|
||||
|
||||
public override void ClearSuggestions ()
|
||||
{
|
||||
base.ClearSuggestions();
|
||||
base.ClearSuggestions ();
|
||||
textField.SetNeedsDisplay ();
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Terminal.Gui {
|
||||
|
||||
var insert = this.Suggestions.ElementAt (this.SelectedIdx);
|
||||
var newText = textField.Text.ToString ();
|
||||
newText = newText.Substring(0,newText.Length - insert.Remove);
|
||||
newText = newText.Substring (0, newText.Length - insert.Remove);
|
||||
newText += insert.Replacement;
|
||||
textField.Text = newText;
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace Terminal.Gui {
|
||||
/// <returns></returns>
|
||||
private bool MakingSuggestion ()
|
||||
{
|
||||
return Suggestions.Any() && this.SelectedIdx != -1 && textField.HasFocus && this.CursorIsAtEnd ();
|
||||
return Suggestions.Any () && this.SelectedIdx != -1 && textField.HasFocus && this.CursorIsAtEnd ();
|
||||
}
|
||||
|
||||
private bool CycleSuggestion (int direction)
|
||||
@@ -130,7 +130,7 @@ namespace Terminal.Gui {
|
||||
this.SelectedIdx = (this.SelectedIdx + direction) % this.Suggestions.Count;
|
||||
|
||||
if (this.SelectedIdx < 0) {
|
||||
this.SelectedIdx = this.Suggestions.Count() - 1;
|
||||
this.SelectedIdx = this.Suggestions.Count () - 1;
|
||||
}
|
||||
textField.SetNeedsDisplay ();
|
||||
return true;
|
||||
|
||||
@@ -8,13 +8,13 @@ using Rune = System.Rune;
|
||||
namespace Terminal.Gui {
|
||||
|
||||
public abstract class AutocompleteBase : IAutocomplete {
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract View HostControl { get; set; }
|
||||
/// <inheritdoc/>
|
||||
public bool PopupInsideContainer { get; set; }
|
||||
|
||||
public ISuggestionGenerator SuggestionGenerator {get;set;} = new SingleWordSuggestionGenerator();
|
||||
|
||||
public ISuggestionGenerator SuggestionGenerator { get; set; } = new SingleWordSuggestionGenerator ();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public virtual int MaxWidth { get; set; } = 10;
|
||||
@@ -67,7 +67,7 @@ namespace Terminal.Gui {
|
||||
/// <inheritdoc/>
|
||||
public virtual void GenerateSuggestions (List<Rune> currentLine, int idx)
|
||||
{
|
||||
Suggestions = SuggestionGenerator.GenerateSuggestions(currentLine, idx).ToList().AsReadOnly();
|
||||
Suggestions = SuggestionGenerator.GenerateSuggestions (currentLine, idx).ToList ().AsReadOnly ();
|
||||
|
||||
EnsureSelectedIdxIsValid ();
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Terminal.Gui {
|
||||
/// </summary>
|
||||
void ClearSuggestions ();
|
||||
|
||||
ISuggestionGenerator SuggestionGenerator {get;set;}
|
||||
ISuggestionGenerator SuggestionGenerator { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
using Rune = System.Rune;
|
||||
|
||||
namespace Terminal.Gui {
|
||||
public interface ISuggestionGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates autocomplete <see cref="Suggestion"/> based on a given cursor location within a string
|
||||
/// </summary>
|
||||
public interface ISuggestionGenerator {
|
||||
|
||||
/// <summary>
|
||||
/// Populates <see cref="Suggestions"/> with all strings in <see cref="AllSuggestions"/> that
|
||||
/// match with the current cursor position/text in the <see cref="HostControl"/>.
|
||||
/// Generates autocomplete <see cref="Suggestion"/> based on a given cursor location <paramref name="idx"/>
|
||||
/// within a <paramref name="currentLine"/>
|
||||
/// </summary>
|
||||
/// <param name="columnOffset">The column offset. Current (zero - default), left (negative), right (positive).</param>
|
||||
IEnumerable<Suggestion> GenerateSuggestions (List<Rune> currentLine, int idx);
|
||||
|
||||
bool IsWordChar (Rune rune);
|
||||
|
||||
@@ -408,7 +408,7 @@ namespace Terminal.Gui {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Completes the autocomplete selection process. Called when user hits the <see cref="SelectionKey"/>.
|
||||
/// Completes the autocomplete selection process. Called when user hits the <see cref="IAutocomplete.SelectionKey"/>.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected bool Select ()
|
||||
@@ -456,7 +456,7 @@ namespace Terminal.Gui {
|
||||
protected abstract void InsertText (string accepted);
|
||||
|
||||
/// <summary>
|
||||
/// Closes the Autocomplete context menu if it is showing and <see cref="ClearSuggestions"/>
|
||||
/// Closes the Autocomplete context menu if it is showing and <see cref="IAutocomplete.ClearSuggestions"/>
|
||||
/// </summary>
|
||||
protected void Close ()
|
||||
{
|
||||
|
||||
@@ -5,8 +5,7 @@ using System.Text;
|
||||
using Rune = System.Rune;
|
||||
|
||||
namespace Terminal.Gui {
|
||||
public class SingleWordSuggestionGenerator : ISuggestionGenerator
|
||||
{
|
||||
public class SingleWordSuggestionGenerator : ISuggestionGenerator {
|
||||
/// <summary>
|
||||
/// The full set of all strings that can be suggested.
|
||||
/// </summary>
|
||||
@@ -17,18 +16,18 @@ namespace Terminal.Gui {
|
||||
{
|
||||
// if there is nothing to pick from
|
||||
if (AllSuggestions.Count == 0) {
|
||||
return Enumerable.Empty<Suggestion>();
|
||||
return Enumerable.Empty<Suggestion> ();
|
||||
}
|
||||
|
||||
var currentWord = IdxToWord (currentLine, idx);
|
||||
|
||||
if (string.IsNullOrWhiteSpace (currentWord)) {
|
||||
return Enumerable.Empty<Suggestion>();
|
||||
return Enumerable.Empty<Suggestion> ();
|
||||
} else {
|
||||
return AllSuggestions.Where (o =>
|
||||
o.StartsWith (currentWord, StringComparison.CurrentCultureIgnoreCase) &&
|
||||
!o.Equals (currentWord, StringComparison.CurrentCultureIgnoreCase)
|
||||
).Select(o=>new Suggestion(currentWord.Length,o))
|
||||
).Select (o => new Suggestion (currentWord.Length, o))
|
||||
.ToList ().AsReadOnly ();
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
/// this would be the same as <see cref="Replacement"/> but may vary in advanced
|
||||
/// use cases (e.g. Title= "ctor", Replacement = "MyClass()\n{\n}")
|
||||
/// </summary>
|
||||
public string Title {get;}
|
||||
public string Title { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The replacement text that will be added
|
||||
|
||||
@@ -272,7 +272,7 @@ namespace Terminal.Gui {
|
||||
|
||||
/// <summary>
|
||||
/// Provides autocomplete context menu based on suggestions at the current cursor
|
||||
/// position. Populate <see cref="Autocomplete.AllSuggestions"/> to enable this feature.
|
||||
/// position. Configure <see cref="ISuggestionGenerator"/> to enable this feature.
|
||||
/// </summary>
|
||||
public IAutocomplete Autocomplete { get; set; } = new TextFieldAutocomplete ();
|
||||
|
||||
|
||||
@@ -1146,7 +1146,7 @@ namespace Terminal.Gui {
|
||||
|
||||
/// <summary>
|
||||
/// Provides autocomplete context menu based on suggestions at the current cursor
|
||||
/// position. Populate <see cref="IAutocomplete.AllSuggestions"/> to enable this feature
|
||||
/// position. Configure <see cref="IAutocomplete.SuggestionGenerator"/> to enable this feature
|
||||
/// </summary>
|
||||
public IAutocomplete Autocomplete { get; protected set; } = new TextViewAutocomplete ();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user