Sweeping changes to style-spelling check interfaces. Known issue: edit from spellcheck.
This commit is contained in:
parent
b6c1b7b8df
commit
da958e3326
|
@ -46,13 +46,18 @@ CommandPanel::CommandPanel (
|
|||
name = _ ( "{name}" );
|
||||
extension = _ ( "{extension}" );
|
||||
fullpath = _ ( "{fullpath}" );
|
||||
int sizerOffset = 2;
|
||||
|
||||
wxButton *pathButton = new wxButton ( this, ID_BUTTON_PATH, path, wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER );
|
||||
wxButton *nameButton = new wxButton ( this, ID_BUTTON_NAME, name, wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER );
|
||||
wxButton *extensionButton = new wxButton ( this, ID_BUTTON_EXTENSION, extension, wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER );
|
||||
wxButton *fullpathButton = new wxButton ( this, ID_BUTTON_FULLPATH, fullpath, wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER );
|
||||
|
||||
int editWidth = 480;
|
||||
|
||||
int editWidth, editHeight;
|
||||
parent->GetSize( &editWidth, &editHeight);
|
||||
editWidth -= sizerOffset * 2;
|
||||
|
||||
commandEdit = new wxTextCtrl (
|
||||
this,
|
||||
wxID_ANY,
|
||||
|
@ -60,6 +65,7 @@ CommandPanel::CommandPanel (
|
|||
wxDefaultPosition,
|
||||
wxSize ( editWidth, -1 )
|
||||
);
|
||||
|
||||
commandEdit->SetValue ( cmd );
|
||||
|
||||
runButton = new wxButton (
|
||||
|
@ -118,7 +124,6 @@ CommandPanel::CommandPanel (
|
|||
wxID_ANY,
|
||||
_ ( "Variables" ) );
|
||||
|
||||
int sizerOffset = 2;
|
||||
|
||||
wxStaticBoxSizer *outputSizer = new wxStaticBoxSizer ( outputBox, wxHORIZONTAL );
|
||||
outputSizer->Add ( outputIgnore, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, sizerOffset );
|
||||
|
@ -134,12 +139,12 @@ CommandPanel::CommandPanel (
|
|||
|
||||
topSizer = new wxBoxSizer ( wxHORIZONTAL );
|
||||
topSizer->Add ( commandEdit, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL | wxEXPAND, sizerOffset );
|
||||
topSizer->Add ( runButton, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, sizerOffset );
|
||||
topSizer->Add ( syncBox, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, sizerOffset );
|
||||
|
||||
topSizer->Layout();
|
||||
|
||||
bottomSizer = new wxBoxSizer ( wxHORIZONTAL );
|
||||
bottomSizer->Add ( runButton, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, sizerOffset );
|
||||
bottomSizer->Add ( syncBox, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, sizerOffset );
|
||||
bottomSizer->Add ( variablesSizer, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, sizerOffset );
|
||||
bottomSizer->Add ( outputSizer, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, sizerOffset );
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@ class CommandPanel : public wxPanel
|
|||
private:
|
||||
wxString path, name, extension, fullpath;
|
||||
wxTextCtrl *commandEdit;
|
||||
//wxStaticText *label;
|
||||
wxButton *runButton;
|
||||
wxCheckBox *syncBox;
|
||||
wxRadioButton *outputIgnore, *outputInsert, *outputNewDocument;
|
||||
|
|
|
@ -18,10 +18,14 @@
|
|||
*/
|
||||
|
||||
#include "getlinuxappdir.h"
|
||||
#include <wx/filename.h>
|
||||
#include <wx/stdpaths.h>
|
||||
//#include <wx/filename.h>
|
||||
|
||||
wxString GetLinuxAppDir::run()
|
||||
{
|
||||
wxStandardPaths *paths = ( wxStandardPaths *) &wxStandardPaths::Get();
|
||||
return paths->GetDataDir();
|
||||
/*
|
||||
wxString s;
|
||||
const int stringArrayLen = 2;
|
||||
wxString stringArray[stringArrayLen];
|
||||
|
@ -38,4 +42,5 @@ wxString GetLinuxAppDir::run()
|
|||
s = wxGetCwd();
|
||||
|
||||
return s;
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -52,9 +52,15 @@ char *GetWord::run ( char **s, size_t *len )
|
|||
}
|
||||
t = u;
|
||||
}
|
||||
else if ( *t == '<' )
|
||||
{
|
||||
t = skipTags ( t );
|
||||
}
|
||||
else
|
||||
{
|
||||
t += bytes;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -95,3 +101,51 @@ bool GetWord::isWordCharacter ( char *s, size_t *bytes )
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
char *GetWord::skipTags ( char *s )
|
||||
{
|
||||
if (*s == '<')
|
||||
{
|
||||
// CDATA
|
||||
if ( * ( s + 1 ) == '!' &&
|
||||
* ( s + 2) == '[' &&
|
||||
* ( s + 3) == 'C' )
|
||||
{
|
||||
s += 3;
|
||||
for ( ; *s; s++ )
|
||||
{
|
||||
if ( *s == ']' &&
|
||||
* (s + 1 ) == ']' &&
|
||||
* (s + 2 ) == '>')
|
||||
{
|
||||
return s += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
// comment
|
||||
else if ( * ( s + 1 ) == '!' &&
|
||||
* ( s + 2 ) == '-' &&
|
||||
* ( s + 3 ) == '-')
|
||||
{
|
||||
s += 3;
|
||||
for ( ; *s; s++ )
|
||||
{
|
||||
if ( *s == '-' &&
|
||||
* ( s + 1 ) == '-' &&
|
||||
* ( s + 2 ) == '>')
|
||||
{
|
||||
return s + 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( ; *s; s++ )
|
||||
{
|
||||
if ( *s == '>' )
|
||||
return ++s;
|
||||
}
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ class GetWord
|
|||
static char *run ( char **s, size_t *len );
|
||||
private:
|
||||
static bool isWordCharacter ( char *s, size_t *bytes );
|
||||
static char *skipTags ( char *s );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -50,9 +50,11 @@ void HouseStyle::collectFilter (
|
|||
std::set<std::string>& excludeSet,
|
||||
int *filterCount )
|
||||
{
|
||||
if ( type == HS_TYPE_SPELL || fileName == "(No filter)" )
|
||||
// from v. 1.1.0.7: always ignore
|
||||
//if ( type == HS_TYPE_SPELL || fileName == "(No filter)" )
|
||||
return;
|
||||
|
||||
/*
|
||||
string filePath, buffer;
|
||||
filePath = filterDirectory + pathSeparator + fileName;
|
||||
|
||||
|
@ -107,6 +109,7 @@ void HouseStyle::collectFilter (
|
|||
if ( !excludeSet.count ( *includeIterator ) )
|
||||
collectFilter ( *includeIterator, excludeSet, filterCount );
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void HouseStyle::collectRules ( string& fileName,
|
||||
|
@ -170,6 +173,7 @@ bool HouseStyle::createReport()
|
|||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
updateFilter();
|
||||
|
||||
auto_ptr<HouseStyleReader> xtr ( new HouseStyleReader ( filterMap ) );
|
||||
|
@ -178,8 +182,10 @@ bool HouseStyle::createReport()
|
|||
error = "file is not well-formed";
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
std::vector<std::pair<std::string, unsigned> > nodeVector;
|
||||
xtr->getNodeVector ( nodeVector );
|
||||
//xtr->getNodeVector ( nodeVector );
|
||||
nodeVector.push_back( make_pair ( buffer, 0 ) ); // new from 1.1.0.7
|
||||
|
||||
int ruleVectorsize, nodeVectorSize;
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ StyleDialog::StyleDialog (
|
|||
_T ( "" ),
|
||||
wxDefaultPosition,
|
||||
wxSize ( 200, -1 ) );
|
||||
if (type != ID_TYPE_STYLE)
|
||||
//if (type != ID_TYPE_STYLE) // from v. 1.1.0.7: never show
|
||||
filterCombo->Show ( false );
|
||||
|
||||
wxButton *createReportButton = new wxButton (
|
||||
|
@ -164,7 +164,7 @@ StyleDialog::StyleDialog (
|
|||
new wxButton (
|
||||
this,
|
||||
ID_STYLE_CHANGE_ALL,
|
||||
_ ( "&Select all" ),
|
||||
_ ( "C&hange all" ),
|
||||
wxDefaultPosition,
|
||||
wxSize ( -1, buttonSize.GetHeight() ),
|
||||
0 );
|
||||
|
@ -215,7 +215,7 @@ StyleDialog::StyleDialog (
|
|||
entries[1].Set ( wxACCEL_ALT, ( int ) 'A', ID_STYLE_EDIT );
|
||||
entries[2].Set ( wxACCEL_ALT, ( int ) 'W', ID_STYLE_WEB_REPORT );
|
||||
entries[3].Set ( wxACCEL_ALT, ( int ) 'B', ID_STYLE_WEB_SUMMARY );
|
||||
entries[4].Set ( wxACCEL_ALT, ( int ) 'S', ID_STYLE_CHANGE_ALL );
|
||||
entries[4].Set ( wxACCEL_ALT, ( int ) 'H', ID_STYLE_CHANGE_ALL );
|
||||
entries[5].Set ( wxACCEL_ALT, ( int ) 'I', ID_STYLE_IGNORE_ALL );
|
||||
entries[6].Set ( wxACCEL_ALT, ( int ) 'N', wxID_CANCEL );
|
||||
|
||||
|
@ -489,6 +489,7 @@ void StyleDialog::OnStyleEdit ( wxCommandEvent& event )
|
|||
|
||||
sort ( v.begin(), v.end(), elementAndOffsetCompareFunction );
|
||||
|
||||
/*
|
||||
HouseStyleWriter hsw ( v );
|
||||
if ( !hsw.parse ( bufferUtf8 ) )
|
||||
{
|
||||
|
@ -502,6 +503,56 @@ void StyleDialog::OnStyleEdit ( wxCommandEvent& event )
|
|||
return;
|
||||
}
|
||||
bufferUtf8 = hsw.getOutput();
|
||||
*/
|
||||
|
||||
|
||||
//unsigned elementCount = 1; // from v. 1.1.0.7: one raw text element only
|
||||
int vectorsize, os_adjust, exclusion;
|
||||
|
||||
vectorsize = v.size();
|
||||
os_adjust = exclusion = 0;
|
||||
string cmp1, cmp2, buffer;
|
||||
buffer = bufferUtf8;
|
||||
|
||||
for ( int i = 0; i < vectorsize; ++i )
|
||||
{
|
||||
/*
|
||||
unsigned vectorElementCount = v[i].elementCount;
|
||||
if ( vectorElementCount < elementCount )
|
||||
continue;
|
||||
else if ( vectorElementCount > elementCount )
|
||||
break;
|
||||
else if ( vectorElementCount == elementCount )
|
||||
{
|
||||
*/
|
||||
int offset = ( int ) v[i].offset + os_adjust;
|
||||
|
||||
if ( offset < exclusion )
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
cmp1 = v[i].match;
|
||||
cmp2 = buffer.substr ( offset, v[i].match.size() );
|
||||
}
|
||||
catch ( std::exception& e )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( cmp1.compare ( cmp2 ) )
|
||||
continue;
|
||||
|
||||
buffer.replace ( offset, v[i].match.size(), v[i].replace.c_str() );
|
||||
|
||||
os_adjust += v[i].replace.size() - v[i].match.size();
|
||||
exclusion = offset + v[i].replace.size();
|
||||
|
||||
//}
|
||||
|
||||
}
|
||||
bufferUtf8 = buffer;
|
||||
|
||||
wxCommandEvent e;
|
||||
EndModal ( wxID_OK );
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <fstream>
|
||||
#include <string>
|
||||
#include <wx/aboutdlg.h>
|
||||
#include <wx/stdpaths.h>
|
||||
#include "xmlcopyeditor.h"
|
||||
#include "readfile.h"
|
||||
#include "xmldoc.h"
|
||||
|
@ -194,8 +195,8 @@ MyApp::MyApp() : checker ( NULL ), server ( NULL ), connection ( NULL ),
|
|||
int fdnull = open ( "/dev/null", O_WRONLY, 0 );
|
||||
dup2 ( fdnull, STDERR_FILENO );
|
||||
#endif
|
||||
myLocale.Init();
|
||||
int systemLocale = myLocale.GetSystemLanguage();
|
||||
//myLocale.Init();
|
||||
int systemLocale = wxLocale::GetSystemLanguage();//myLocale.GetSystemLanguage();
|
||||
switch ( systemLocale )
|
||||
{
|
||||
case wxLANGUAGE_GERMAN:
|
||||
|
@ -275,17 +276,49 @@ MyApp::MyApp() : checker ( NULL ), server ( NULL ), connection ( NULL ),
|
|||
#endif
|
||||
}
|
||||
|
||||
myLocale.Init ( lang, wxLOCALE_LOAD_DEFAULT );
|
||||
/*
|
||||
#ifndef __WXMSW__
|
||||
lang = wxLANGUAGE_ENGLISH; // temp
|
||||
#endif
|
||||
*/
|
||||
myLocale.Init ( lang, wxLOCALE_CONV_ENCODING );
|
||||
|
||||
#ifdef __WXMSW__
|
||||
|
||||
wxLocale::AddCatalogLookupPathPrefix ( wxT ( "." ) );
|
||||
wxLocale::AddCatalogLookupPathPrefix ( wxT ( ".." ) );
|
||||
|
||||
#ifndef __WXMSW__
|
||||
wxString poDir = GetLinuxAppDir::run() + wxFileName::GetPathSeparator() + _T ( "po" ) + wxFileName::GetPathSeparator();
|
||||
wxLocale::AddCatalogLookupPathPrefix ( poDir );
|
||||
#endif
|
||||
|
||||
if ( !myLocale.AddCatalog ( _T ( "messages" ) ) )
|
||||
;
|
||||
#else // Linux
|
||||
if ( wxLocale::IsAvailable ( lang ) )
|
||||
{
|
||||
wxStandardPaths *paths = (wxStandardPaths *) &wxStandardPaths::Get();
|
||||
wxString prefix = paths->GetInstallPrefix();
|
||||
myLocale.AddCatalogLookupPathPrefix( prefix );
|
||||
myLocale.AddCatalog ( _T ("xmlcopyeditor") );
|
||||
if (!myLocale.IsOk() )
|
||||
{
|
||||
std::cout << "Locale is not OK" << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Locale unavailable" << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifndef __WXMSW__
|
||||
wxString poDir = GetLinuxAppDir::run() + wxFileName::GetPathSeparator() + _T ( "po" ); //+ wxFileName::GetPathSeparator();
|
||||
//wxLocale::AddCatalogLookupPathPrefix ( poDir );
|
||||
//myLocale.AddCatalogLookupPathPrefix ( poDir );
|
||||
//std::cout << poDir.mb_str(wxConvUTF8) << std::endl;
|
||||
if (lang == wxLANGUAGE_ITALIAN)
|
||||
std::cout << "OK it's set to Italian... let's see" << std::endl;
|
||||
myLocale.AddCatalogLookupPathPrefix ( _T ("/usr/share/locale/it/LC_MESSAGES") );
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __WXMSW__
|
||||
{
|
||||
|
@ -293,6 +326,7 @@ MyApp::MyApp() : checker ( NULL ), server ( NULL ), connection ( NULL ),
|
|||
myLocale.AddCatalog ( _T ( "fileutils" ) );
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
|
||||
MyApp::~MyApp()
|
||||
|
@ -3235,6 +3269,10 @@ void MyFrame::OnSpelling ( wxCommandEvent& event )
|
|||
std::string rawBufferUtf8;
|
||||
getRawText ( doc, rawBufferUtf8 );
|
||||
|
||||
/*
|
||||
* removed due to entity reference headaches
|
||||
* from v. 1.1.0.7 always check raw text only
|
||||
*
|
||||
// handle unusual encodings
|
||||
if ( !XmlEncodingHandler::setUtf8 ( rawBufferUtf8 ) )
|
||||
{
|
||||
|
@ -3276,11 +3314,12 @@ void MyFrame::OnSpelling ( wxCommandEvent& event )
|
|||
{
|
||||
bufferParameterUtf8 = wl->getOutput();
|
||||
}
|
||||
*/
|
||||
|
||||
auto_ptr<StyleDialog> sd ( new StyleDialog (
|
||||
this,
|
||||
wxICON ( appicon ),
|
||||
bufferParameterUtf8,
|
||||
rawBufferUtf8, //bufferParameterUtf8,
|
||||
doc->getShortFileName(),
|
||||
ruleSetDir,
|
||||
filterDir,
|
||||
|
@ -3288,7 +3327,7 @@ void MyFrame::OnSpelling ( wxCommandEvent& event )
|
|||
( type == ID_TYPE_SPELL ) ? dictionaryPreset : ruleSetPreset,
|
||||
filterPreset,
|
||||
type,
|
||||
( success ) ? false : true,
|
||||
false,//( success ) ? false : true,
|
||||
stylePosition,
|
||||
styleSize ) );
|
||||
|
||||
|
|
|
@ -41,5 +41,5 @@
|
|||
"License along with this program; if not, write to the Free\n"\
|
||||
"Software Foundation, Inc., 59 Temple Place, Suite 330,\n"\
|
||||
"Boston, MA 02111-1307 USA.")
|
||||
#define ABOUT_VERSION _T("1.1.0.6")
|
||||
#define ABOUT_VERSION _T("1.1.0.7")
|
||||
#define XMLCE_VAR _T("XMLCE_VAR")
|
||||
|
|
Loading…
Reference in New Issue