204
205
font = new Font(fontFamily, fontSize, style);
209
// replace nick completer if needed
210
bool wantBashCompletion = (bool)config["Interface/Entry/BashStyleCompletion"];
211
if (wantBashCompletion && !(NickCompleter is LongestPrefixNickCompleter)) {
212
NickCompleter = new LongestPrefixNickCompleter();
213
} else if (!wantBashCompletion && !(NickCompleter is TabCycleNickCompleter)) {
214
NickCompleter = new TabCycleNickCompleter();
217
// set the completion character
218
NickCompleter.CompletionChar = (string)config["Interface/Entry/CompletionChar"];
209
222
public string HistoryCurrent()
671
684
private void _NickCompletion()
686
// perform completion
673
688
int position = SelectionStart;
679
// find the current word
681
temp = text.Substring(0, position);
682
previous_space = temp.LastIndexOf(' ');
683
next_space = text.IndexOf(' ', position);
686
_Logger.Debug("previous_space: "+previous_space);
687
_Logger.Debug("next_space: "+next_space);
690
if (previous_space != -1 && next_space != -1) {
691
// previous and next space exist
692
word = text.Substring(previous_space + 1, next_space - previous_space - 1);
693
} else if (previous_space != -1) {
694
// previous space exist
695
word = text.Substring(previous_space + 1);
696
} else if (next_space != -1) {
698
word = text.Substring(0, next_space);
704
if (word == String.Empty) {
708
// find the possible nickname
710
bool partial_found = false;
712
//GroupChatModel cp = (GroupChatModel) Frontend.FrontendManager.CurrentChat;
713
GroupChatModel cp = (GroupChatModel) _Notebook.CurrentChatView.ChatModel;
714
if ((bool)Frontend.UserConfig["Interface/Entry/BashStyleCompletion"]) {
715
IList<string> result = cp.PersonLookupAll(word);
716
if (result == null || result.Count == 0) {
718
} else if (result.Count == 1) {
721
} else if (result.Count >= 2) {
722
string[] nickArray = new string[result.Count];
723
result.CopyTo(nickArray, 0);
724
string nicks = String.Join(" ", nickArray, 1, nickArray.Length - 1);
725
Frontend.FrontendManager.AddTextToChat(cp, "-!- " + nicks);
727
partial_found = true;
731
PersonModel person = cp.PersonLookup(word);
732
if (person != null) {
734
nick = person.IdentityName;
739
// put the found nickname in place
740
if (previous_space != -1 && next_space != -1) {
741
// previous and next space exist
742
temp = text.Remove(previous_space + 1, word.Length);
743
temp = temp.Insert(previous_space + 1, nick);
746
SelectionStart = previous_space + 1 + nick.Length;
748
SelectionStart = previous_space + 2 + nick.Length;
750
} else if (previous_space != -1) {
751
// only previous space exist
752
temp = text.Remove(previous_space + 1, word.Length);
753
temp = temp.Insert(previous_space + 1, nick);
759
SelectionStart = previous_space + 2 + nick.Length;
760
} else if (next_space != -1) {
761
// only next space exist
762
temp = text.Remove(0, next_space + 1);
764
Text = nick + " " + temp;
765
SelectionStart = nick.Length;
767
Text = nick+(string)Frontend.UserConfig["Interface/Entry/CompletionCharacter"] + " " + temp;
768
SelectionStart = nick.Length + 2;
775
Text = nick+(string)Frontend.UserConfig["Interface/Entry/CompletionCharacter"]+" ";
689
NickCompleter.Complete(ref text, ref position, _Notebook.CurrentChatView);
691
SelectionStart = position;
782
694
private static string _(string msg)