You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.6KB

  1. /*
  2. Copyright (C) 2012 Rory Walsh
  3. Cabbage is free software; you can redistribute it
  4. and/or modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. Cabbage is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with Csound; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA
  15. */
  16. #ifndef __CODE_EDITOR__
  17. #define __CODE_EDITOR__
  18. #include "../JuceHeader.h"
  19. #include "CsoundTokeniser.h"
  20. #include "PythonTokeniser.h"
  21. #include "CommandManager.h"
  22. #include "../CabbageUtils.h"
  23. extern ApplicationProperties* appProperties;
  24. extern CabbageTimer* cabbageTimer;
  25. class CsoundCodeEditor : public CodeEditorComponent,
  26. public ActionBroadcaster,
  27. public CodeDocument::Listener
  28. {
  29. public:
  30. CodeDocument::Position positionInCode;
  31. CsoundCodeEditor(String type, CodeDocument &document, CodeTokeniser *codeTokeniser);
  32. ~CsoundCodeEditor();
  33. bool keyPressed (const KeyPress& key);
  34. void handleTabKey(String direction);
  35. void toggleComments();
  36. void handleDirectionKey(){}
  37. void handleEscapeKey(){
  38. if(type=="python")
  39. sendActionMessage("make python invisible");
  40. if(type=="csound")
  41. sendActionMessage("make popup invisible");
  42. }
  43. void handleReturnKey ();
  44. void addPopupMenuItems (PopupMenu &menuToAddTo, const MouseEvent *mouseClickEvent);
  45. void performPopupMenuAction (int menuItemID);
  46. String getLineText();
  47. String getTempChannelInstr();
  48. String getSelectedText();
  49. String getInstrumentText();
  50. Rectangle<int> getCaretPoisition();
  51. StringArray getSelectedTextArray();
  52. void addRepoToSettings();
  53. void insertText(String text);
  54. void addToRepository();
  55. StringArray repoEntries;
  56. String getAllText();
  57. void setAllText(String text);
  58. void highlightLine(String line);
  59. void codeDocumentTextDeleted(int,int);
  60. void codeDocumentTextInserted(const juce::String &,int);
  61. bool textChanged;
  62. void insertNewLine(String text);
  63. void setOpcodeStrings(String opcodes){
  64. opcodeStrings.addLines(opcodes);
  65. }
  66. void updateCaretPosition();
  67. void insertMultiTextAtCaret(String text);
  68. String getOpcodeToken(int index){
  69. return opcodeTokens[index];
  70. }
  71. private:
  72. int xPos, yPos, prevXpos;
  73. CodeDocument::Position pos1, pos2;
  74. Colour selectedColour;
  75. String type;
  76. StringArray opcodeStrings;
  77. StringArray opcodeTokens;
  78. };
  79. #endif