2006-01-16 22:02:54 +01:00
|
|
|
// Copyright (c) 2005, Rodrigo Braz Monteiro
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
|
|
|
/// @file subs_edit_ctrl.h
|
|
|
|
/// @see subs_edit_ctrl.cpp
|
|
|
|
/// @ingroup main_ui
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2013-06-08 06:19:40 +02:00
|
|
|
#include <memory>
|
2012-01-11 20:19:30 +01:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2009-09-11 04:36:34 +02:00
|
|
|
#include "scintilla_text_ctrl.h"
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2006-12-24 22:52:54 +01:00
|
|
|
class SubsEditBox;
|
2010-07-20 05:11:11 +02:00
|
|
|
class Thesaurus;
|
2012-10-30 16:59:47 +01:00
|
|
|
namespace agi {
|
2012-11-01 03:49:29 +01:00
|
|
|
class CalltipProvider;
|
2012-10-30 16:59:47 +01:00
|
|
|
class SpellChecker;
|
|
|
|
struct Context;
|
2012-11-06 15:33:44 +01:00
|
|
|
namespace ass { struct DialogueToken; }
|
2012-10-30 16:59:47 +01:00
|
|
|
}
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @class SubsTextEditCtrl
|
2012-03-13 00:34:45 +01:00
|
|
|
/// @brief A Scintilla control with spell checking and syntax highlighting
|
2007-06-23 01:43:21 +02:00
|
|
|
class SubsTextEditCtrl : public ScintillaTextCtrl {
|
2012-03-13 00:34:45 +01:00
|
|
|
/// Backend spellchecker to use
|
2013-06-08 06:19:40 +02:00
|
|
|
std::unique_ptr<agi::SpellChecker> spellchecker;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2012-03-13 00:34:45 +01:00
|
|
|
/// Backend thesaurus to use
|
2013-06-08 06:19:40 +02:00
|
|
|
std::unique_ptr<Thesaurus> thesaurus;
|
2006-12-25 22:56:56 +01:00
|
|
|
|
2013-06-08 06:19:40 +02:00
|
|
|
std::unique_ptr<agi::CalltipProvider> calltip_provider;
|
2012-11-01 03:49:29 +01:00
|
|
|
|
2012-03-13 00:34:45 +01:00
|
|
|
/// Project context, for splitting lines
|
2012-01-11 20:19:30 +01:00
|
|
|
agi::Context *context;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2012-01-11 20:19:30 +01:00
|
|
|
/// The word right-clicked on, used for spellchecker replacing
|
2012-10-30 16:59:47 +01:00
|
|
|
std::string currentWord;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2012-01-11 20:19:30 +01:00
|
|
|
/// The beginning of the word right-clicked on, for spellchecker replacing
|
2012-11-07 01:26:00 +01:00
|
|
|
std::pair<int, int> currentWordPos;
|
2012-01-11 20:19:30 +01:00
|
|
|
|
2012-03-13 00:34:45 +01:00
|
|
|
/// Spellchecker suggestions for the last right-clicked word
|
2012-10-30 16:59:47 +01:00
|
|
|
std::vector<std::string> sugs;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2012-03-13 00:34:45 +01:00
|
|
|
/// Thesaurus suggestions for the last right-clicked word
|
2012-01-08 02:36:50 +01:00
|
|
|
std::vector<std::string> thesSugs;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2012-11-01 03:49:29 +01:00
|
|
|
/// Text of the currently shown calltip, to avoid flickering from
|
|
|
|
/// pointlessly reshowing the current tip
|
|
|
|
std::string calltip_text;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2012-11-01 03:49:29 +01:00
|
|
|
/// Position of the currently show calltip
|
|
|
|
size_t calltip_position;
|
2007-01-02 19:09:56 +01:00
|
|
|
|
2012-11-06 15:33:44 +01:00
|
|
|
/// Cursor position which the current calltip is for
|
|
|
|
int cursor_pos;
|
|
|
|
|
|
|
|
/// The last seen line text, used to avoid reparsing the line for syntax
|
|
|
|
/// highlighting when possible
|
|
|
|
std::string line_text;
|
|
|
|
|
|
|
|
/// Tokenized version of line_text
|
|
|
|
std::vector<agi::ass::DialogueToken> tokenized_line;
|
|
|
|
|
2011-08-31 06:17:37 +02:00
|
|
|
void OnContextMenu(wxContextMenuEvent &);
|
2006-12-25 06:43:00 +01:00
|
|
|
void OnUseSuggestion(wxCommandEvent &event);
|
2007-01-01 05:53:55 +01:00
|
|
|
void OnSetDicLanguage(wxCommandEvent &event);
|
|
|
|
void OnSetThesLanguage(wxCommandEvent &event);
|
2007-01-14 00:34:04 +01:00
|
|
|
void OnLoseFocus(wxFocusEvent &event);
|
2012-05-28 16:18:07 +02:00
|
|
|
void OnKeyDown(wxKeyEvent &event);
|
2006-12-25 04:42:44 +01:00
|
|
|
|
2011-12-28 22:27:22 +01:00
|
|
|
void SetSyntaxStyle(int id, wxFont &font, std::string const& name);
|
2011-09-28 21:44:34 +02:00
|
|
|
void Subscribe(std::string const& name);
|
|
|
|
|
|
|
|
void StyleSpellCheck();
|
2012-11-06 15:33:44 +01:00
|
|
|
void UpdateCallTip();
|
2011-09-28 21:44:34 +02:00
|
|
|
void SetStyles();
|
|
|
|
|
2011-10-10 22:59:04 +02:00
|
|
|
void UpdateStyle();
|
|
|
|
|
2012-01-11 20:18:45 +01:00
|
|
|
/// Add the thesaurus suggestions to a menu
|
|
|
|
void AddThesaurusEntries(wxMenu &menu);
|
|
|
|
|
|
|
|
/// Add the spell checker suggestions to a menu
|
|
|
|
void AddSpellCheckerEntries(wxMenu &menu);
|
|
|
|
|
|
|
|
/// Generate a languages submenu from a list of locales and a current language
|
|
|
|
/// @param base_id ID to use for the first menu item
|
|
|
|
/// @param curLang Currently selected language
|
|
|
|
/// @param lang Full list of languages
|
|
|
|
wxMenu *GetLanguagesMenu(int base_id, wxString const& curLang, wxArrayString const& langs);
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
public:
|
2012-01-11 20:19:30 +01:00
|
|
|
SubsTextEditCtrl(wxWindow* parent, wxSize size, long style, agi::Context *context);
|
2006-12-24 22:52:54 +01:00
|
|
|
~SubsTextEditCtrl();
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2012-11-06 15:33:44 +01:00
|
|
|
void SetTextTo(wxString const& text);
|
2011-10-10 22:59:04 +02:00
|
|
|
void Paste();
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2012-11-07 01:26:00 +01:00
|
|
|
std::pair<int, int> GetBoundsOfWordAtPosition(int pos);
|
|
|
|
|
2006-01-19 11:33:56 +01:00
|
|
|
DECLARE_EVENT_TABLE()
|
2006-01-16 22:02:54 +01:00
|
|
|
};
|