ctkConsole_p.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.commontk.org/LICENSE
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkConsole_p_h
  15. #define __ctkConsole_p_h
  16. // Qt includes
  17. #include <QTextEdit>
  18. // CTK includes
  19. #include "ctkConsole.h"
  20. #include "ctkWidgetsExport.h"
  21. class CTK_WIDGETS_EXPORT ctkConsolePrivate : public QTextEdit
  22. {
  23. Q_DECLARE_PUBLIC(ctkConsole);
  24. protected:
  25. ctkConsole* const q_ptr;
  26. public:
  27. ctkConsolePrivate(ctkConsole& object);
  28. void keyPressEvent(QKeyEvent* e);
  29. /// Returns the end of the document
  30. /*const*/ int documentEnd();
  31. void focusOutEvent(QFocusEvent *e);
  32. void updateCompleterIfVisible();
  33. /// If there is exactly 1 completion, insert it and hide the completer,
  34. /// else do nothing.
  35. void selectCompletion();
  36. void updateCompleter();
  37. /// Update the contents of the command buffer from the contents of the widget
  38. void updateCommandBuffer();
  39. /// Replace the contents of the command buffer, updating the display
  40. void replaceCommandBuffer(const QString& Text);
  41. /// References the buffer where the current un-executed command is stored
  42. QString& commandBuffer();
  43. /// Implements command-execution
  44. void internalExecuteCommand();
  45. void setCompleter(ctkConsoleCompleter* completer);
  46. /// A custom completer
  47. QPointer<ctkConsoleCompleter> Completer;
  48. /** Stores the beginning of the area of interactive input, outside which
  49. changes can't be made to the text edit contents */
  50. int InteractivePosition;
  51. /// Stores command-history, plus the current command buffer
  52. QStringList CommandHistory;
  53. /// Stores the current position in the command-history
  54. int CommandPosition;
  55. };
  56. #endif