public static bool HandleKeys(ScintillaControl sci, Keys key) { int index; switch (key) { case Keys.Back: if (word.Length >= MinWordLength) { word = word.Substring(0, word.Length - 1); currentPos = sci.CurrentPos - 1; lastIndex = 0; FindWordStartingWith(word); } else CompletionList.Hide((char)8); return false; case Keys.Enter: if (noAutoInsert || !ReplaceText(sci, '\n')) { CompletionList.Hide(); return false; } return true; case Keys.Tab: if (!ReplaceText(sci, '\t')) { CompletionList.Hide(); return false; } return true; case Keys.Space: if (noAutoInsert) CompletionList.Hide(); return false; case Keys.Up: noAutoInsert = false; // the list was hidden and it should not appear if (!completionList.Visible) { CompletionList.Hide(); if (key == Keys.Up) sci.LineUp(); else sci.CharLeft(); return false; } // go up the list if (completionList.SelectedIndex > 0) { RefreshTip(); index = completionList.SelectedIndex-1; completionList.SelectedIndex = index; } // wrap else if (PluginBase.MainForm.Settings.WrapList) { RefreshTip(); index = completionList.Items.Count-1; completionList.SelectedIndex = index; } break; case Keys.Down: noAutoInsert = false; // the list was hidden and it should not appear if (!completionList.Visible) { CompletionList.Hide(); if (key == Keys.Down) sci.LineDown(); else sci.CharRight(); return false; } // go down the list if (completionList.SelectedIndex < completionList.Items.Count-1) { RefreshTip(); index = completionList.SelectedIndex+1; completionList.SelectedIndex = index; } // wrap else if (PluginBase.MainForm.Settings.WrapList) { RefreshTip(); index = 0; completionList.SelectedIndex = index; } break; case Keys.PageUp: noAutoInsert = false; // the list was hidden and it should not appear if (!completionList.Visible) { CompletionList.Hide(); sci.PageUp(); return false; } // go up the list if (completionList.SelectedIndex > 0) { RefreshTip(); index = completionList.SelectedIndex-completionList.Height/completionList.ItemHeight; if (index < 0) index = 0; completionList.SelectedIndex = index; } break; case Keys.PageDown: noAutoInsert = false; // the list was hidden and it should not appear if (!completionList.Visible) { CompletionList.Hide(); sci.PageDown(); return false; } // go down the list if (completionList.SelectedIndex < completionList.Items.Count-1) { RefreshTip(); index = completionList.SelectedIndex+completionList.Height/completionList.ItemHeight; if (index > completionList.Items.Count-1) index = completionList.Items.Count-1; completionList.SelectedIndex = index; } break; case (Keys.Control | Keys.Space): break; case Keys.Left: sci.CharLeft(); CompletionList.Hide(); break; case Keys.Right: sci.CharRight(); CompletionList.Hide(); break; default: CompletionList.Hide(); return false; } return true; }
static public bool HandleKeys(ScintillaControl sci, Keys key) { int index; switch (key) { case Keys.Back: sci.DeleteBack(); if (word.Length > 0) { word = word.Substring(0, word.Length-1); currentPos = sci.CurrentPos; lastIndex = 0; FindWordStartingWith(word); } else CompletionList.Hide(); return true; case Keys.Enter: case Keys.Tab: ReplaceText(sci); return true; case Keys.Space: return false; case Keys.Up: case Keys.Left: // the list was hidden and it should not appear if (!completionList.Visible) { CompletionList.Hide(); if (key == Keys.Up) sci.LineUp(); else sci.CharLeft(); return false; } // go up the list else if (completionList.SelectedIndex > 0) { index = completionList.SelectedIndex-1; completionList.SelectedIndex = index; } // wrap else if (wrapList) { index = completionList.Items.Count-1; completionList.SelectedIndex = index; } break; case Keys.Down: case Keys.Right: // the list was hidden and it should not appear if (!completionList.Visible) { CompletionList.Hide(); if (key == Keys.Down) sci.LineDown(); else sci.CharRight(); return false; } // go down the list else if (completionList.SelectedIndex < completionList.Items.Count-1) { index = completionList.SelectedIndex+1; completionList.SelectedIndex = index; } // wrap else if (wrapList) { index = 0; completionList.SelectedIndex = index; } break; case Keys.PageUp: // the list was hidden and it should not appear if (!completionList.Visible) { CompletionList.Hide(); sci.PageUp(); return false; } // go up the list else if (completionList.SelectedIndex > 0) { index = completionList.SelectedIndex-completionList.Height/completionList.ItemHeight; if (index < 0) index = 0; completionList.SelectedIndex = index; } break; case Keys.PageDown: // the list was hidden and it should not appear if (!completionList.Visible) { CompletionList.Hide(); sci.PageDown(); return false; } // go down the list else if (completionList.SelectedIndex < completionList.Items.Count-1) { index = completionList.SelectedIndex+completionList.Height/completionList.ItemHeight; if (index > completionList.Items.Count-1) index = completionList.Items.Count-1; completionList.SelectedIndex = index; } break; case (Keys.Control | Keys.Space): break; default: CompletionList.Hide(); return false; } return true; }