Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
c39385a5
Commit
c39385a5
authored
Apr 14, 2014
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve help file finding after kiway breakage.
parent
d2e56665
Changes
21
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
484 additions
and
447 deletions
+484
-447
CMakeLists.txt
common/CMakeLists.txt
+2
-0
basicframe.cpp
common/basicframe.cpp
+36
-29
eda_doc.cpp
common/eda_doc.cpp
+10
-5
findkicadhelppath.cpp.notused
common/findkicadhelppath.cpp.notused
+126
-0
gestfich.cpp
common/gestfich.cpp
+86
-200
kiface_i.cpp
common/kiface_i.cpp
+5
-85
pgm_base.cpp
common/pgm_base.cpp
+30
-23
search_stack.cpp
common/search_stack.cpp
+0
-25
searchhelpfilefullpath.cpp
common/searchhelpfilefullpath.cpp
+128
-0
cvframe.cpp
cvpcb/cvframe.cpp
+0
-7
bin_mod.h
include/bin_mod.h
+2
-0
common.h
include/common.h
+21
-0
gestfich.h
include/gestfich.h
+0
-22
kiface_i.h
include/kiface_i.h
+5
-21
pgm_base.h
include/pgm_base.h
+3
-9
search_stack.h
include/search_stack.h
+0
-9
wxstruct.h
include/wxstruct.h
+9
-0
kicad.h
kicad/kicad.h
+5
-0
mainframe.cpp
kicad/mainframe.cpp
+12
-9
pgm_kicad.h
kicad/pgm_kicad.h
+2
-0
tree_project_frame.cpp
kicad/tree_project_frame.cpp
+2
-3
No files found.
common/CMakeLists.txt
View file @
c39385a5
...
@@ -172,6 +172,7 @@ set( COMMON_SRCS
...
@@ -172,6 +172,7 @@ set( COMMON_SRCS
eda_dde.cpp
eda_dde.cpp
eda_doc.cpp
eda_doc.cpp
filter_reader.cpp
filter_reader.cpp
# findkicadhelppath.cpp.notused deprecated, use searchhelpfilefullpath.cpp
gestfich.cpp
gestfich.cpp
getrunningmicrosecs.cpp
getrunningmicrosecs.cpp
grid_tricks.cpp
grid_tricks.cpp
...
@@ -189,6 +190,7 @@ set( COMMON_SRCS
...
@@ -189,6 +190,7 @@ set( COMMON_SRCS
ptree.cpp
ptree.cpp
reporter.cpp
reporter.cpp
richio.cpp
richio.cpp
searchhelpfilefullpath.cpp
search_stack.cpp
search_stack.cpp
selcolor.cpp
selcolor.cpp
systemdirsappend.cpp
systemdirsappend.cpp
...
...
common/basicframe.cpp
View file @
c39385a5
...
@@ -271,6 +271,18 @@ wxConfigBase* EDA_BASE_FRAME::config()
...
@@ -271,6 +271,18 @@ wxConfigBase* EDA_BASE_FRAME::config()
}
}
const
SEARCH_STACK
&
EDA_BASE_FRAME
::
sys_search
()
{
return
Kiface
().
KifaceSearch
();
}
wxString
EDA_BASE_FRAME
::
help_name
()
{
return
Kiface
().
GetHelpFileName
();
}
void
EDA_BASE_FRAME
::
PrintMsg
(
const
wxString
&
text
)
void
EDA_BASE_FRAME
::
PrintMsg
(
const
wxString
&
text
)
{
{
SetStatusText
(
text
);
SetStatusText
(
text
);
...
@@ -327,33 +339,28 @@ wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
...
@@ -327,33 +339,28 @@ wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
void
EDA_BASE_FRAME
::
GetKicadHelp
(
wxCommandEvent
&
event
)
void
EDA_BASE_FRAME
::
GetKicadHelp
(
wxCommandEvent
&
event
)
{
{
wxString
msg
;
const
SEARCH_STACK
&
search
=
sys_search
()
;
/* We have to get document for beginners,
/* We have to get document for beginners,
* or the
the
full specific doc
* or the full specific doc
* if event id is wxID_INDEX, we want the document for beginners.
* if event id is wxID_INDEX, we want the document for beginners.
* else the specific doc file (its name is in Kiface().GetHelpFileName())
* else the specific doc file (its name is in Kiface().GetHelpFileName())
* The document for beginners is the same for all KiCad utilities
* The document for beginners is the same for all KiCad utilities
*/
*/
if
(
event
.
GetId
()
==
wxID_INDEX
)
if
(
event
.
GetId
()
==
wxID_INDEX
)
{
{
// Temporarily change the help filename
wxString
tmp
=
Kiface
().
GetHelpFileName
();
// Search for "getting_started_in_kicad.pdf" or "Getting_Started_in_KiCad.pdf"
// Search for "getting_started_in_kicad.pdf" or "Getting_Started_in_KiCad.pdf"
Kiface
().
SetHelpFileName
(
wxT
(
"getting_started_in_kicad.pdf"
)
);
wxString
helpFile
=
SearchHelpFileFullPath
(
search
,
wxT
(
"getting_started_in_kicad.pdf"
)
);
wxString
helpFile
=
Kiface
().
GetHelpFile
();
if
(
!
helpFile
)
if
(
!
helpFile
)
{
// Try to find "Getting_Started_in_KiCad.pdf"
helpFile
=
SearchHelpFileFullPath
(
search
,
wxT
(
"Getting_Started_in_KiCad.pdf"
)
);
Kiface
().
SetHelpFileName
(
wxT
(
"Getting_Started_in_KiCad.pdf"
)
);
helpFile
=
Kiface
().
GetHelpFile
();
}
if
(
!
helpFile
)
if
(
!
helpFile
)
{
{
msg
.
Printf
(
_
(
"Help file %s could not be found."
),
wxString
msg
=
wxString
::
Format
(
_
(
GetChars
(
Kiface
().
GetHelpFileName
()
)
);
"Help file '%s' could not be found."
),
wxT
(
"getting_started_in_kicad.pdf"
)
);
wxMessageBox
(
msg
);
wxMessageBox
(
msg
);
}
}
else
else
...
@@ -361,36 +368,36 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
...
@@ -361,36 +368,36 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
GetAssociatedDocument
(
this
,
helpFile
);
GetAssociatedDocument
(
this
,
helpFile
);
}
}
Kiface
().
SetHelpFileName
(
tmp
);
return
;
return
;
}
}
wxString
base_name
=
help_name
();
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
if
(
Kiface
().
GetHtmlHelpController
()
==
NULL
)
wxHtmlHelpController
*
hc
=
Pgm
().
GetHtmlHelpController
();
{
Kiface
().
InitOnLineHelp
();
}
wxString
helpFile
=
SearchHelpFileFullPath
(
search
,
);
if
(
Kiface
().
GetHtmlHelpController
()
)
if
(
!!
helpFile
)
{
{
Kiface
().
GetHtmlHelpController
()
->
DisplayContents
();
hc
->
UseConfig
(
Pgm
().
CommonSettings
()
);
Kiface
().
GetHtmlHelpController
()
->
Display
(
Kiface
().
GetHelpFileName
()
);
hc
->
SetTitleFormat
(
wxT
(
"KiCad Help"
)
);
}
hc
->
AddBook
(
helpFile
);
else
{
msg
.
Printf
(
_
(
"Help file %s could not be found."
),
GetChars
(
Kiface
().
GetHelpFileName
()
)
);
wxMessageBox
(
msg
);
}
}
hc
->
DisplayContents
();
hc
->
Display
(
helpFile
);
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
wxString
helpFile
=
Kiface
().
GetHelpFile
(
);
wxString
helpFile
=
SearchHelpFileFullPath
(
search
,
base_name
);
if
(
!
helpFile
)
if
(
!
helpFile
)
{
{
msg
.
Printf
(
_
(
"Help file %s could not be found."
),
wxString
msg
=
wxString
::
Format
(
_
(
GetChars
(
Kiface
().
GetHelpFileName
()
)
);
"Help file '%s' could not be found."
),
GetChars
(
base_name
)
);
wxMessageBox
(
msg
);
wxMessageBox
(
msg
);
}
}
else
else
...
...
common/eda_doc.cpp
View file @
c39385a5
...
@@ -64,15 +64,19 @@ bool GetAssociatedDocument( wxFrame* aFrame,
...
@@ -64,15 +64,19 @@ bool GetAssociatedDocument( wxFrame* aFrame,
const
wxPathList
*
aPaths
)
const
wxPathList
*
aPaths
)
{
{
wxString
docname
,
fullfilename
,
file_ext
;
wxString
docname
,
fullfilename
;
wxString
msg
;
wxString
msg
;
wxString
command
;
wxString
command
;
bool
success
=
false
;
bool
success
=
false
;
// Is an internet url
// Is an internet url
static
const
wxString
url_header
[
3
]
=
{
wxT
(
"http:"
),
wxT
(
"ftp:"
),
wxT
(
"www."
)
};
static
const
wxChar
*
url_header
[
3
]
=
{
wxT
(
"http:"
),
wxT
(
"ftp:"
),
wxT
(
"www."
)
};
for
(
int
ii
=
0
;
ii
<
3
;
ii
++
)
for
(
unsigned
ii
=
0
;
ii
<
DIM
(
url_header
)
;
ii
++
)
{
{
if
(
aDocName
.
First
(
url_header
[
ii
]
)
==
0
)
//. seems an internet url
if
(
aDocName
.
First
(
url_header
[
ii
]
)
==
0
)
//. seems an internet url
{
{
...
@@ -133,8 +137,9 @@ bool GetAssociatedDocument( wxFrame* aFrame,
...
@@ -133,8 +137,9 @@ bool GetAssociatedDocument( wxFrame* aFrame,
return
false
;
return
false
;
}
}
wxFileName
CurrentFileName
(
fullfilename
);
wxFileName
currentFileName
(
fullfilename
);
file_ext
=
CurrentFileName
.
GetExt
();
wxString
file_ext
=
currentFileName
.
GetExt
();
if
(
file_ext
==
wxT
(
"pdf"
)
)
if
(
file_ext
==
wxT
(
"pdf"
)
)
{
{
...
...
common/findkicadhelppath.cpp.notused
0 → 100644
View file @
c39385a5
#include <fctsys.h>
#include <pgm_base.h>
#include <macros.h>
#include <gestfich.h>
/**
* Function FindKicadHelpPath
* finds the absolute path for KiCad "help" (or "help/<language>")
* Find path kicad/doc/help/xx/ or kicad/doc/help/:
* from BinDir
* else from environment variable KICAD
* else from one of s_HelpPathList
* typically c:/kicad/doc/help or /usr/share/kicad/help
* or /usr/local/share/kicad/help
* (must have kicad in path name)
*
* xx = iso639-1 language id (2 letters (generic) or 4 letters):
* fr = french (or fr_FR)
* en = English (or en_GB or en_US ...)
* de = deutch
* es = spanish
* pt = portuguese (or pt_BR ...)
*
* default = en (if not found = fr)
*/
wxString FindKicadHelpPath()
{
bool found = false;
wxString bin_dir = Pgm().GetExecutablePath();
if( bin_dir.Last() == '/' )
bin_dir.RemoveLast();
wxString fullPath = bin_dir.BeforeLast( '/' ); // cd ..
fullPath += wxT( "/doc/help/" );
wxString localeString = Pgm().GetLocale()->GetCanonicalName();
wxString path_tmp = fullPath;
#ifdef __WINDOWS__
path_tmp.MakeLower();
#endif
if( path_tmp.Contains( wxT( "kicad" ) ) )
{
if( wxDirExists( fullPath ) )
found = true;
}
// find kicad/help/ from environment variable KICAD
if( !found && Pgm().IsKicadEnvVariableDefined() )
{
fullPath = Pgm().GetKicadEnvVariable() + wxT( "/doc/help/" );
if( wxDirExists( fullPath ) )
found = true;
}
if( !found )
{
// Possibilities online help
const static wxChar* possibilities[] = {
#ifdef __WINDOWS__
wxT( "c:/kicad/doc/help/" ),
wxT( "d:/kicad/doc/help/" ),
wxT( "c:/Program Files/kicad/doc/help/" ),
wxT( "d:/Program Files/kicad/doc/help/" ),
#else
wxT( "/usr/share/doc/kicad/help/" ),
wxT( "/usr/local/share/doc/kicad/help/" ),
wxT( "/usr/local/kicad/doc/help/" ), // default install for "universal
// tarballs" and build for a server
// (new)
wxT( "/usr/local/kicad/help/" ), // default install for "universal
// tarballs" and build for a server
// (old)
#endif
};
for( unsigned i=0; i<DIM(possibilities); ++i )
{
fullPath = possibilities[i];
if( wxDirExists( fullPath ) )
{
found = true;
break;
}
}
}
if( found )
{
wxString langFullPath = fullPath + localeString + UNIX_STRING_DIR_SEP;
if( wxDirExists( langFullPath ) )
return langFullPath;
langFullPath = fullPath + localeString.Left( 2 ) + UNIX_STRING_DIR_SEP;
if( wxDirExists( langFullPath ) )
return langFullPath;
langFullPath = fullPath + wxT( "en/" );
if( wxDirExists( langFullPath ) )
{
return langFullPath;
}
else
{
langFullPath = fullPath + wxT( "fr/" );
if( wxDirExists( langFullPath ) )
return langFullPath;
}
return fullPath;
}
return wxEmptyString;
}
common/gestfich.cpp
View file @
c39385a5
This diff is collapsed.
Click to expand it.
common/kiface_i.cpp
View file @
c39385a5
...
@@ -55,10 +55,11 @@ static void setSearchPaths( SEARCH_STACK* aDst, KIWAY::FACE_T aId )
...
@@ -55,10 +55,11 @@ static void setSearchPaths( SEARCH_STACK* aDst, KIWAY::FACE_T aId )
// we must add <kicad path>/library and <kicad path>/library/doc
// we must add <kicad path>/library and <kicad path>/library/doc
if
(
aId
==
KIWAY
::
FACE_SCH
)
if
(
aId
==
KIWAY
::
FACE_SCH
)
{
{
// Add schematic doc file path (library/doc) to search path list.
fn
.
AppendDir
(
wxT
(
"library"
)
);
fn
.
AppendDir
(
wxT
(
"library"
)
);
aDst
->
AddPaths
(
fn
.
GetPath
()
);
aDst
->
AddPaths
(
fn
.
GetPath
()
);
// Add schematic doc file path (library/doc)to search path list.
fn
.
AppendDir
(
wxT
(
"doc"
)
);
fn
.
AppendDir
(
wxT
(
"doc"
)
);
aDst
->
AddPaths
(
fn
.
GetPath
()
);
aDst
->
AddPaths
(
fn
.
GetPath
()
);
...
@@ -85,8 +86,10 @@ static void setSearchPaths( SEARCH_STACK* aDst, KIWAY::FACE_T aId )
...
@@ -85,8 +86,10 @@ static void setSearchPaths( SEARCH_STACK* aDst, KIWAY::FACE_T aId )
aDst
->
AddPaths
(
fn
.
GetPath
()
);
aDst
->
AddPaths
(
fn
.
GetPath
()
);
}
}
aDst
->
AddPaths
(
wxT
(
"/usr/local/share"
)
);
#if 1 && defined(DEBUG)
#if 1 && defined(DEBUG)
aDst
->
Show
(
"ki
way
"
);
aDst
->
Show
(
"ki
face
"
);
#endif
#endif
}
}
...
@@ -121,86 +124,3 @@ void KIFACE_I::end_common()
...
@@ -121,86 +124,3 @@ void KIFACE_I::end_common()
m_bm
.
End
();
m_bm
.
End
();
}
}
wxString
KIFACE_I
::
GetHelpFile
()
{
wxString
fn
;
wxArrayString
subdirs
;
wxArrayString
altsubdirs
;
// FIXME: This is not the ideal way to handle this. Unfortunately, the
// CMake install paths seem to be a moving target so this crude
// hack solves the problem of install path differences between
// Windows and non-Windows platforms.
// Partially fixed, but must be enhanced
// Create subdir tree for "standard" linux distributions, when KiCad comes
// from a distribution files are in /usr/share/doc/kicad/help and binaries
// in /usr/bin or /usr/local/bin
subdirs
.
Add
(
wxT
(
"share"
)
);
subdirs
.
Add
(
wxT
(
"doc"
)
);
subdirs
.
Add
(
wxT
(
"kicad"
)
);
subdirs
.
Add
(
wxT
(
"help"
)
);
// Create subdir tree for linux and Windows KiCad pack.
// Note the pack form under linux is also useful if a user wants to
// install KiCad to a server because there is only one path to mount
// or export (something like /usr/local/kicad).
// files are in <install dir>/kicad/doc/help
// (often /usr/local/kicad/kicad/doc/help)
// <install dir>/kicad/ is retrieved from m_BinDir
altsubdirs
.
Add
(
wxT
(
"doc"
)
);
altsubdirs
.
Add
(
wxT
(
"help"
)
);
/* Search for a help file.
* we *must* find a help file.
* so help is searched in directories in this order:
* help/<canonical name> like help/en_GB
* help/<short name> like help/en
* help/en
*/
wxLocale
*
i18n
=
Pgm
().
GetLocale
();
// Step 1 : Try to find help file in help/<canonical name>
subdirs
.
Add
(
i18n
->
GetCanonicalName
()
);
altsubdirs
.
Add
(
i18n
->
GetCanonicalName
()
);
fn
=
m_bm
.
m_search
.
FindFileInSearchPaths
(
m_bm
.
m_help_file
,
&
altsubdirs
);
if
(
!
fn
)
fn
=
m_bm
.
m_search
.
FindFileInSearchPaths
(
m_bm
.
m_help_file
,
&
subdirs
);
// Step 2 : if not found Try to find help file in help/<short name>
if
(
!
fn
)
{
subdirs
.
RemoveAt
(
subdirs
.
GetCount
()
-
1
);
altsubdirs
.
RemoveAt
(
altsubdirs
.
GetCount
()
-
1
);
// wxLocale::GetName() does not return always the short name
subdirs
.
Add
(
i18n
->
GetName
().
BeforeLast
(
'_'
)
);
altsubdirs
.
Add
(
i18n
->
GetName
().
BeforeLast
(
'_'
)
);
fn
=
m_bm
.
m_search
.
FindFileInSearchPaths
(
m_bm
.
m_help_file
,
&
altsubdirs
);
if
(
!
fn
)
fn
=
m_bm
.
m_search
.
FindFileInSearchPaths
(
m_bm
.
m_help_file
,
&
subdirs
);
}
// Step 3 : if not found Try to find help file in help/en
if
(
!
fn
)
{
subdirs
.
RemoveAt
(
subdirs
.
GetCount
()
-
1
);
altsubdirs
.
RemoveAt
(
altsubdirs
.
GetCount
()
-
1
);
subdirs
.
Add
(
wxT
(
"en"
)
);
altsubdirs
.
Add
(
wxT
(
"en"
)
);
fn
=
m_bm
.
m_search
.
FindFileInSearchPaths
(
m_bm
.
m_help_file
,
&
altsubdirs
);
if
(
!
fn
)
fn
=
m_bm
.
m_search
.
FindFileInSearchPaths
(
m_bm
.
m_help_file
,
&
subdirs
);
}
return
fn
;
}
common/pgm_base.cpp
View file @
c39385a5
...
@@ -297,6 +297,13 @@ void PGM_BASE::destroy()
...
@@ -297,6 +297,13 @@ void PGM_BASE::destroy()
delete
m_locale
;
delete
m_locale
;
m_locale
=
0
;
m_locale
=
0
;
/*
// Close the help frame
if( m_html_ctrl && m_html_ctrl->GetFrame() ) // returns NULL if no help frame active
m_html_ctrl->GetFrame()->Close( true );
}
*/
delete
m_html_ctrl
;
delete
m_html_ctrl
;
m_html_ctrl
=
0
;
m_html_ctrl
=
0
;
}
}
...
@@ -415,30 +422,18 @@ bool PGM_BASE::initPgm()
...
@@ -415,30 +422,18 @@ bool PGM_BASE::initPgm()
}
}
void
PGM_BASE
::
SetHtmlHelpController
(
wxHtmlHelpController
*
aController
)
void
PGM_BASE
::
initHtmlHelpController
()
{
delete
m_html_ctrl
;
m_html_ctrl
=
aController
;
}
void
PGM_BASE
::
InitOnLineHelp
()
{
{
wxString
fullfilename
=
FindKicadHelpPath
();
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
m_HelpFileName
=
fullfilename
+
wxT
(
".html"
);
fullfilename
+=
wxT
(
"kicad.hhp"
);
if
(
wxFileExists
(
fullfilename
)
)
if
(
!
m_html_ctrl
)
{
m_html_ctrl
=
new
wxHtmlHelpController
(
m_html_ctrl
=
new
wxHtmlHelpController
(
wxHF_TOOLBAR
|
wxHF_CONTENTS
|
wxHF_TOOLBAR
|
wxHF_CONTENTS
|
wxHF_PRINT
|
wxHF_OPEN_FILES
wxHF_PRINT
|
wxHF_OPEN_FILES
/*| wxHF_SEARCH */
);
// | wxHF_SEARCH
m_html_ctrl
->
UseConfig
(
m_common_settings
);
);
m_html_ctrl
->
SetTitleFormat
(
wxT
(
"KiCad Help"
)
);
m_html_ctrl
->
AddBook
(
fullfilename
);
wxASSERT
(
m_html_ctrl
);
// may not leave here as NULL
}
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
m_html_ctrl
=
NULL
;
m_html_ctrl
=
NULL
;
...
@@ -449,10 +444,22 @@ void PGM_BASE::InitOnLineHelp()
...
@@ -449,10 +444,22 @@ void PGM_BASE::InitOnLineHelp()
}
}
wxHtmlHelpController
*
PGM_BASE
::
HtmlHelpController
()
{
if
(
!
m_html_ctrl
)
initHtmlHelpController
();
// there should not be calls to this unless ONLINE_HELP_FILES_FORMAT_IS_HTML is defined
wxASSERT
(
m_html_ctrl
);
return
m_html_ctrl
;
}
bool
PGM_BASE
::
setExecutablePath
()
bool
PGM_BASE
::
setExecutablePath
()
{
{
// Apple MacOSx
#ifdef __APPLE__ // Apple MacOSx
#ifdef __APPLE__
// Derive path from location of the app bundle
// Derive path from location of the app bundle
CFBundleRef
mainBundle
=
CFBundleGetMainBundle
();
CFBundleRef
mainBundle
=
CFBundleGetMainBundle
();
...
...
common/search_stack.cpp
View file @
c39385a5
...
@@ -104,31 +104,6 @@ void SEARCH_STACK::AddPaths( const wxString& aPaths, int aIndex )
...
@@ -104,31 +104,6 @@ void SEARCH_STACK::AddPaths( const wxString& aPaths, int aIndex )
}
}
wxString
SEARCH_STACK
::
FindFileInSearchPaths
(
const
wxString
&
aFilename
,
const
wxArrayString
*
aSubdirs
)
{
wxPathList
paths
;
for
(
unsigned
i
=
0
;
i
<
GetCount
();
++
i
)
{
wxFileName
fn
(
(
*
this
)[
i
]
);
if
(
aSubdirs
)
{
for
(
unsigned
j
=
0
;
j
<
aSubdirs
->
GetCount
();
j
++
)
fn
.
AppendDir
(
(
*
aSubdirs
)[
j
]
);
}
if
(
fn
.
DirExists
()
)
{
paths
.
Add
(
fn
.
GetPath
()
);
}
}
return
paths
.
FindValidPath
(
aFilename
);
}
void
RETAINED_PATH
::
Clear
()
void
RETAINED_PATH
::
Clear
()
{
{
m_retained_path
.
Clear
();
m_retained_path
.
Clear
();
...
...
common/searchhelpfilefullpath.cpp
0 → 100644
View file @
c39385a5
#include <pgm_base.h>
#include <common.h>
/**
* Function FindFileInSearchPaths
* looks in "this" for \a aFilename, but first modifies every search
* path by appending a list of path fragments from aSubdirs. That modification
* is not rentative.
*/
wxString
FindFileInSearchPaths
(
const
SEARCH_STACK
&
aStack
,
const
wxString
&
aFilename
,
const
wxArrayString
*
aSubdirs
)
{
wxPathList
paths
;
for
(
unsigned
i
=
0
;
i
<
aStack
.
GetCount
();
++
i
)
{
wxFileName
fn
(
aStack
[
i
],
wxEmptyString
);
if
(
aSubdirs
)
{
for
(
unsigned
j
=
0
;
j
<
aSubdirs
->
GetCount
();
j
++
)
fn
.
AppendDir
(
(
*
aSubdirs
)[
j
]
);
}
if
(
fn
.
DirExists
()
)
{
paths
.
Add
(
fn
.
GetPath
()
);
}
}
return
paths
.
FindValidPath
(
aFilename
);
}
// See also FindKicadHelpPath.cpp.notused.
wxString
SearchHelpFileFullPath
(
const
SEARCH_STACK
&
aSStack
,
const
wxString
&
aBaseName
)
{
wxArrayString
subdirs
;
wxArrayString
altsubdirs
;
SEARCH_STACK
ss
=
aSStack
;
// It might already be in aSStack, but why depend on other code
// far away when it's so easy to add it again (to our copy) as the first place to look.
// This is CMAKE_INSTALL_PREFIX:
ss
.
AddPaths
(
wxT
(
DEFAULT_INSTALL_PATH
),
0
);
// If there's a KICAD environment variable set, use that guy's path also
ss
.
AddPaths
(
Pgm
().
GetKicadEnvVariable
(),
0
);
#if 1 // && defined(__linux__)
// Based on kicad-doc.bzr/CMakeLists.txt, line 20, the help files are
// installed into "<CMAKE_INSTALL_PREFIX>/share/doc/kicad/help" for linux.
// This is ${KICAD_HELP} var in that CMakeLists.txt file.
// Below we account for an international subdirectory.
subdirs
.
Add
(
wxT
(
"share"
)
);
subdirs
.
Add
(
wxT
(
"doc"
)
);
subdirs
.
Add
(
wxT
(
"kicad"
)
);
subdirs
.
Add
(
wxT
(
"help"
)
);
#endif
#if 1 // && defined(__WINDOWS__)
// Based on kicad-doc.bzr/CMakeLists.txt, line 35, the help files are
// installed into "<CMAKE_INSTALL_PREFIX>/doc/help" for Windows.
// This is ${KICAD_HELP} var in that CMakeLists.txt file.
// Below we account for an international subdirectory.
altsubdirs
.
Add
(
wxT
(
"doc"
)
);
altsubdirs
.
Add
(
wxT
(
"help"
)
);
#endif
/* Search for a help file.
* we *must* find a help file.
* so help is searched in directories in this order:
* help/<canonical name> like help/en_GB
* help/<short name> like help/en
* help/en
*/
wxLocale
*
i18n
=
Pgm
().
GetLocale
();
// Step 1 : Try to find help file in help/<canonical name>
subdirs
.
Add
(
i18n
->
GetCanonicalName
()
);
altsubdirs
.
Add
(
i18n
->
GetCanonicalName
()
);
#if defined(DEBUG) && 0
ss
.
Show
(
__func__
);
printf
(
"%s: m_help_file:'%s'
\n
"
,
__func__
,
TO_UTF8
(
aBaseName
)
);
#endif
wxString
fn
=
FindFileInSearchPaths
(
ss
,
aBaseName
,
&
altsubdirs
);
if
(
!
fn
)
fn
=
FindFileInSearchPaths
(
ss
,
aBaseName
,
&
subdirs
);
// Step 2 : if not found Try to find help file in help/<short name>
if
(
!
fn
)
{
subdirs
.
RemoveAt
(
subdirs
.
GetCount
()
-
1
);
altsubdirs
.
RemoveAt
(
altsubdirs
.
GetCount
()
-
1
);
// wxLocale::GetName() does not return always the short name
subdirs
.
Add
(
i18n
->
GetName
().
BeforeLast
(
'_'
)
);
altsubdirs
.
Add
(
i18n
->
GetName
().
BeforeLast
(
'_'
)
);
fn
=
FindFileInSearchPaths
(
ss
,
aBaseName
,
&
altsubdirs
);
if
(
!
fn
)
fn
=
FindFileInSearchPaths
(
ss
,
aBaseName
,
&
subdirs
);
}
// Step 3 : if not found Try to find help file in help/en
if
(
!
fn
)
{
subdirs
.
RemoveAt
(
subdirs
.
GetCount
()
-
1
);
altsubdirs
.
RemoveAt
(
altsubdirs
.
GetCount
()
-
1
);
subdirs
.
Add
(
wxT
(
"en"
)
);
altsubdirs
.
Add
(
wxT
(
"en"
)
);
fn
=
FindFileInSearchPaths
(
ss
,
aBaseName
,
&
altsubdirs
);
if
(
!
fn
)
fn
=
FindFileInSearchPaths
(
ss
,
aBaseName
,
&
subdirs
);
}
return
fn
;
}
cvpcb/cvframe.cpp
View file @
c39385a5
...
@@ -301,13 +301,6 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
...
@@ -301,13 +301,6 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
}
}
}
}
// Close the help frame
if
(
Pgm
().
GetHtmlHelpController
()
)
{
if
(
Pgm
().
GetHtmlHelpController
()
->
GetFrame
()
)
// returns NULL if no help frame active
Pgm
().
GetHtmlHelpController
()
->
GetFrame
()
->
Close
(
true
);
}
if
(
m_NetlistFileName
.
IsOk
()
)
if
(
m_NetlistFileName
.
IsOk
()
)
{
{
UpdateFileHistory
(
m_NetlistFileName
.
GetFullPath
()
);
UpdateFileHistory
(
m_NetlistFileName
.
GetFullPath
()
);
...
...
include/bin_mod.h
View file @
c39385a5
...
@@ -59,6 +59,8 @@ struct BIN_MOD
...
@@ -59,6 +59,8 @@ struct BIN_MOD
wxString
m_help_file
;
wxString
m_help_file
;
SEARCH_STACK
m_search
;
SEARCH_STACK
m_search
;
};
};
#endif // BIN_MOD_H_
#endif // BIN_MOD_H_
include/common.h
View file @
c39385a5
...
@@ -589,4 +589,25 @@ wxString FormatDateLong( const wxDateTime &aDate );
...
@@ -589,4 +589,25 @@ wxString FormatDateLong( const wxDateTime &aDate );
*/
*/
void
SystemDirsAppend
(
SEARCH_STACK
*
aSearchStack
);
void
SystemDirsAppend
(
SEARCH_STACK
*
aSearchStack
);
/**
* Function SearchHelpFileFullPath
* returns the help file's full path.
* <p>
* Return the KiCad help file with path.
* If the help file for the current locale is not found, an attempt to find
* the English version of the help file is made.
* Help file is searched in directories in this order:
* help/\<canonical name\> like help/en_GB
* help/\<short name\> like help/en
* help/en
* </p>
* @param aSearchStack contains some possible base dirs that may be above the
* the one actually holding @a aBaseName. These are starting points for nested searches.
* @param aBaseName is the name of the help file to search for.
* @return wxEmptyString is returned if aBaseName is not found, else the full path & filename.
*/
wxString
SearchHelpFileFullPath
(
const
SEARCH_STACK
&
aSearchStack
,
const
wxString
&
aBaseName
);
#endif // INCLUDE__COMMON_H_
#endif // INCLUDE__COMMON_H_
include/gestfich.h
View file @
c39385a5
...
@@ -89,28 +89,6 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile,
...
@@ -89,28 +89,6 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile,
*/
*/
void
AddDelimiterString
(
wxString
&
string
);
void
AddDelimiterString
(
wxString
&
string
);
/**
* Function FindKicadHelpPath
* finds the absolute path for KiCad "help" (or "help/<language>")
* Find path kicad/doc/help/xx/ or kicad/doc/help/:
* from BinDir
* else from environment variable KICAD
* else from one of s_HelpPathList
* typically c:/kicad/doc/help or /usr/share/kicad/help
* or /usr/local/share/kicad/help
* (must have kicad in path name)
*
* xx = iso639-1 language id (2 letters (generic) or 4 letters):
* fr = french (or fr_FR)
* en = English (or en_GB or en_US ...)
* de = deutch
* es = spanish
* pt = portuguese (or pt_BR ...)
*
* default = en (if not found = fr)
*/
wxString
FindKicadHelpPath
();
/**
/**
* Function KicadDatasPath
* Function KicadDatasPath
* returns the data path common to KiCad.
* returns the data path common to KiCad.
...
...
include/kiface_i.h
View file @
c39385a5
...
@@ -100,27 +100,11 @@ public:
...
@@ -100,27 +100,11 @@ public:
wxConfigBase
*
KifaceSettings
()
const
{
return
m_bm
.
m_config
;
}
wxConfigBase
*
KifaceSettings
()
const
{
return
m_bm
.
m_config
;
}
const
wxString
&
GetHelpFileName
()
const
{
return
m_bm
.
m_help_file
;
}
void
SetHelpFileName
(
const
wxString
&
aFileName
)
{
m_bm
.
m_help_file
=
aFileName
;
}
/**
/**
* Function GetHelpFile
* Function GetHelpFileName
* gets the help file path.
* returns just the basename portion of the current help file.
* <p>
* Return the KiCad help file with path. The base paths defined in
* m_searchPaths are tested for a valid file. The path returned can
* be relative depending on the paths added to m_searchPaths. See the
* documentation for wxPathList for more information. If the help file
* for the current locale is not found, an attempt to find the English
* version of the help file is made.
* wxEmptyString is returned if help file not found.
* Help file is searched in directories in this order:
* help/\<canonical name\> like help/en_GB
* help/\<short name\> like help/en
* help/en
* </p>
*/
*/
wxString
GetHelpFile
();
const
wxString
&
GetHelpFileName
()
const
{
return
m_bm
.
m_help_file
;
}
wxFileHistory
&
GetFileHistory
()
{
return
m_bm
.
m_history
;
}
wxFileHistory
&
GetFileHistory
()
{
return
m_bm
.
m_history
;
}
...
...
include/pgm_base.h
View file @
c39385a5
...
@@ -86,9 +86,7 @@ public:
...
@@ -86,9 +86,7 @@ public:
//----<Cross Module API>-----------------------------------------------------
//----<Cross Module API>-----------------------------------------------------
VTBL_ENTRY
wxHtmlHelpController
*
GetHtmlHelpController
()
{
return
m_html_ctrl
;
}
VTBL_ENTRY
wxHtmlHelpController
*
HtmlHelpController
();
VTBL_ENTRY
void
SetHtmlHelpController
(
wxHtmlHelpController
*
aController
);
VTBL_ENTRY
wxConfigBase
*
CommonSettings
()
const
{
return
m_common_settings
;
}
VTBL_ENTRY
wxConfigBase
*
CommonSettings
()
const
{
return
m_common_settings
;
}
...
@@ -161,12 +159,6 @@ public:
...
@@ -161,12 +159,6 @@ public:
VTBL_ENTRY
void
SetLanguagePath
();
VTBL_ENTRY
void
SetLanguagePath
();
/**
* Function InitOnLineHelp
* initializes KiCad's online help.
*/
VTBL_ENTRY
void
InitOnLineHelp
();
/**
/**
* Function ReadPdfBrowserInfos
* Function ReadPdfBrowserInfos
* reads the PDF browser choice from the common configuration.
* reads the PDF browser choice from the common configuration.
...
@@ -217,6 +209,8 @@ protected:
...
@@ -217,6 +209,8 @@ protected:
*/
*/
bool
initPgm
();
bool
initPgm
();
void
initHtmlHelpController
();
/**
/**
* Function loadCommonSettings
* Function loadCommonSettings
* loads the program (process) settings subset which are stored in .kicad_common
* loads the program (process) settings subset which are stored in .kicad_common
...
...
include/search_stack.h
View file @
c39385a5
...
@@ -57,15 +57,6 @@ public:
...
@@ -57,15 +57,6 @@ public:
* ";" on windows, or ":" | ";" on unix.
* ";" on windows, or ":" | ";" on unix.
*/
*/
void
RemovePaths
(
const
wxString
&
aPaths
);
void
RemovePaths
(
const
wxString
&
aPaths
);
/**
* Function FindFileInSearchPaths
* looks in "this" for \a aFilename, but first modifies every search
* path by appending a list of path fragments from aSubdirs. That modification
* is not rentative.
*/
wxString
FindFileInSearchPaths
(
const
wxString
&
aFilename
,
const
wxArrayString
*
aSubdirs
=
NULL
);
};
};
...
...
include/wxstruct.h
View file @
c39385a5
...
@@ -186,6 +186,15 @@ protected:
...
@@ -186,6 +186,15 @@ protected:
*/
*/
virtual
wxConfigBase
*
config
();
virtual
wxConfigBase
*
config
();
/**
* Function sys_search
* returns a SEARCH_STACK pertaining to entire program, and is overloaded in
* KICAD_MANAGER_FRAME
*/
virtual
const
SEARCH_STACK
&
sys_search
();
virtual
wxString
help_name
();
public
:
public
:
EDA_BASE_FRAME
(
wxWindow
*
aParent
,
ID_DRAWFRAME_TYPE
aFrameType
,
EDA_BASE_FRAME
(
wxWindow
*
aParent
,
ID_DRAWFRAME_TYPE
aFrameType
,
const
wxString
&
aTitle
,
const
wxPoint
&
aPos
,
const
wxSize
&
aSize
,
const
wxString
&
aTitle
,
const
wxPoint
&
aPos
,
const
wxSize
&
aSize
,
...
...
kicad/kicad.h
View file @
c39385a5
...
@@ -123,6 +123,11 @@ class KICAD_MANAGER_FRAME : public EDA_BASE_FRAME
...
@@ -123,6 +123,11 @@ class KICAD_MANAGER_FRAME : public EDA_BASE_FRAME
protected
:
protected
:
wxConfigBase
*
config
();
// override EDA_BASE_FRAME virtual
wxConfigBase
*
config
();
// override EDA_BASE_FRAME virtual
const
SEARCH_STACK
&
sys_search
();
// override EDA_BASE_FRAME virtual
wxString
help_name
();
// override EDA_BASE_FRAME virtual
public
:
public
:
TREE_PROJECT_FRAME
*
m_LeftWin
;
TREE_PROJECT_FRAME
*
m_LeftWin
;
LAUNCHER_PANEL
*
m_Launcher
;
LAUNCHER_PANEL
*
m_Launcher
;
...
...
kicad/mainframe.cpp
View file @
c39385a5
...
@@ -123,6 +123,18 @@ wxConfigBase* KICAD_MANAGER_FRAME::config()
...
@@ -123,6 +123,18 @@ wxConfigBase* KICAD_MANAGER_FRAME::config()
}
}
const
SEARCH_STACK
&
KICAD_MANAGER_FRAME
::
sys_search
()
{
return
Pgm
().
SysSearch
();
}
wxString
KICAD_MANAGER_FRAME
::
help_name
()
{
return
Pgm
().
GetHelpFileName
();
}
void
KICAD_MANAGER_FRAME
::
PrintMsg
(
const
wxString
&
aText
)
void
KICAD_MANAGER_FRAME
::
PrintMsg
(
const
wxString
&
aText
)
{
{
m_MessagesBox
->
AppendText
(
aText
);
m_MessagesBox
->
AppendText
(
aText
);
...
@@ -157,15 +169,6 @@ void KICAD_MANAGER_FRAME::OnCloseWindow( wxCloseEvent& Event )
...
@@ -157,15 +169,6 @@ void KICAD_MANAGER_FRAME::OnCloseWindow( wxCloseEvent& Event )
Event
.
SetCanVeto
(
true
);
Event
.
SetCanVeto
(
true
);
// Close the help frame
if
(
Pgm
().
GetHtmlHelpController
()
)
{
if
(
Pgm
().
GetHtmlHelpController
()
->
GetFrame
()
)
// returns NULL if no help frame active
Pgm
().
GetHtmlHelpController
()
->
GetFrame
()
->
Close
(
true
);
Pgm
().
SetHtmlHelpController
(
NULL
);
}
m_LeftWin
->
Show
(
false
);
m_LeftWin
->
Show
(
false
);
Destroy
();
Destroy
();
...
...
kicad/pgm_kicad.h
View file @
c39385a5
...
@@ -58,6 +58,8 @@ public:
...
@@ -58,6 +58,8 @@ public:
SEARCH_STACK
&
SysSearch
()
{
return
m_bm
.
m_search
;
}
SEARCH_STACK
&
SysSearch
()
{
return
m_bm
.
m_search
;
}
wxString
GetHelpFileName
()
{
return
m_bm
.
m_help_file
;
}
protected
:
protected
:
// The PGM_* classes can have difficulties at termination if they
// The PGM_* classes can have difficulties at termination if they
...
...
kicad/tree_project_frame.cpp
View file @
c39385a5
...
@@ -94,10 +94,10 @@ static const wxChar* s_allowedExtensionsToList[] =
...
@@ -94,10 +94,10 @@ static const wxChar* s_allowedExtensionsToList[] =
*/
*/
/* File extension definitions. */
/* File extension definitions. */
const
wx
String
TextFileExtension
(
wxT
(
"txt"
)
);
const
wx
Char
TextFileExtension
[]
=
wxT
(
"txt"
);
/* File wildcard definitions. */
/* File wildcard definitions. */
const
wx
String
TextFileWildcard
(
wxT
(
"Text files (*.txt)|*.txt"
)
);
const
wx
Char
TextFileWildcard
[]
=
wxT
(
"Text files (*.txt)|*.txt"
);
/**
/**
...
@@ -177,7 +177,6 @@ void TREE_PROJECT_FRAME::RemoveFilter( const wxString& filter )
...
@@ -177,7 +177,6 @@ void TREE_PROJECT_FRAME::RemoveFilter( const wxString& filter )
}
}
/**
/**
* Called by the popup menu in the tree frame
* Called by the popup menu in the tree frame
* Creates a new subdirectory inside the current kicad project directory
* Creates a new subdirectory inside the current kicad project directory
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment