Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PoroCYon
Bonzomatic
Commits
259e8f5e
Commit
259e8f5e
authored
May 19, 2018
by
Gargaj
Browse files
move osx directory init to Misc
parent
988c78ae
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/Misc.h
View file @
259e8f5e
...
...
@@ -2,9 +2,13 @@
namespace
Misc
{
void
PlatformStartup
();
void
PlatformShutdown
();
void
InitKeymaps
();
void
GetKeymapName
(
char
*
sz
);
bool
ExecuteCommand
(
char
*
cmd
,
char
*
param
);
bool
FileExists
(
const
char
*
path
);
const
char
*
GetDefaultFontPath
();
}
\ No newline at end of file
src/main.cpp
View file @
259e8f5e
...
...
@@ -12,12 +12,6 @@
#include
"jsonxx.h"
#include
"Capture.h"
#ifdef WIN32
#include
<windows.h>
#else
#include
<unistd.h>
#endif
void
ReplaceTokens
(
std
::
string
&
sDefShader
,
const
char
*
sTokenBegin
,
const
char
*
sTokenName
,
const
char
*
sTokenEnd
,
std
::
vector
<
std
::
string
>
&
tokens
)
{
if
(
sDefShader
.
find
(
sTokenBegin
)
!=
std
::
string
::
npos
...
...
@@ -47,35 +41,9 @@ void ReplaceTokens( std::string &sDefShader, const char * sTokenBegin, const cha
}
}
#ifdef __APPLE__
#include
<sys/param.h>
// For MAXPATHLEN
#include
"CoreFoundation/CoreFoundation.h"
static
void
changeToAppsCurrentDirectory
()
{
char
appPath
[
MAXPATHLEN
];
CFBundleRef
bundle
=
CFBundleGetMainBundle
();
if
(
!
bundle
)
return
;
CFURLRef
bundleURL
=
CFBundleCopyBundleURL
(
bundle
);
CFURLRef
pathURL
=
CFURLCreateCopyDeletingLastPathComponent
(
NULL
,
bundleURL
);
if
(
!
CFURLGetFileSystemRepresentation
(
pathURL
,
true
,
(
UInt8
*
)
appPath
,
MAXPATHLEN
))
{
CFRelease
(
bundleURL
);
CFRelease
(
pathURL
);
return
;
}
CFRelease
(
bundleURL
);
CFRelease
(
pathURL
);
chdir
(
appPath
);
}
#endif
int
main
(
int
argc
,
char
*
argv
[])
{
#ifdef __APPLE__
changeToAppsCurrentDirectory
();
#endif
Misc
::
PlatformStartup
();
jsonxx
::
Object
options
;
FILE
*
fConf
=
fopen
(
(
argc
>
1
)
?
argv
[
1
]
:
"config.json"
,
"rb"
);
...
...
@@ -534,5 +502,7 @@ int main(int argc, char *argv[])
Misc
::
ExecuteCommand
(
(
char
*
)
sPostExitCmd
.
c_str
(),
Renderer
::
defaultShaderFilename
);
}
Misc
::
PlatformShutdown
();
return
0
;
}
src/platform_osx/Misc.cpp
View file @
259e8f5e
...
...
@@ -4,11 +4,41 @@
#include
<string.h>
#include
"../Misc.h"
void
Misc
::
InitKeymaps
()
{
return
;
#include
<unistd.h>
#include
<sys/param.h>
// For MAXPATHLEN
#include
"CoreFoundation/CoreFoundation.h"
void
Misc
::
PlatformStartup
()
{
char
appPath
[
MAXPATHLEN
];
CFBundleRef
bundle
=
CFBundleGetMainBundle
();
if
(
!
bundle
)
return
;
CFURLRef
bundleURL
=
CFBundleCopyBundleURL
(
bundle
);
CFURLRef
pathURL
=
CFURLCreateCopyDeletingLastPathComponent
(
NULL
,
bundleURL
);
if
(
!
CFURLGetFileSystemRepresentation
(
pathURL
,
true
,
(
UInt8
*
)
appPath
,
MAXPATHLEN
))
{
CFRelease
(
bundleURL
);
CFRelease
(
pathURL
);
return
;
}
CFRelease
(
bundleURL
);
CFRelease
(
pathURL
);
chdir
(
appPath
);
}
void
Misc
::
GetKeymapName
(
char
*
sz
)
{
void
Misc
::
PlatformShutdown
()
{
}
void
Misc
::
InitKeymaps
()
{
}
void
Misc
::
GetKeymapName
(
char
*
sz
)
{
strncpy
(
sz
,
"<native>"
,
7
);
}
...
...
@@ -26,7 +56,7 @@ const char * Misc::GetDefaultFontPath()
{
// Linux case
// TODO: use fonts.conf(5) or X resources or something like that
const
char
*
fontPaths
[]
=
const
char
*
fontPaths
[]
=
{
"/Library/Fonts/Courier New.ttf"
,
NULL
...
...
src/platform_w32_common/Misc.cpp
View file @
259e8f5e
...
...
@@ -6,6 +6,14 @@
namespace
Misc
{
void
PlatformStartup
()
{
}
void
PlatformShutdown
()
{
}
std
::
map
<
std
::
string
,
std
::
string
>
keymaps
;
void
InitKeymaps
()
{
...
...
@@ -37,6 +45,7 @@ namespace Misc
idx
++
;
}
}
void
GetKeymapName
(
char
*
sz
)
{
char
szCode
[
KL_NAMELENGTH
];
...
...
@@ -44,15 +53,18 @@ namespace Misc
CharLowerA
(
szCode
);
strncpy
(
sz
,
keymaps
.
count
(
szCode
)
?
keymaps
[
szCode
].
c_str
()
:
"<unknown>"
,
255
);
}
bool
ExecuteCommand
(
char
*
cmd
,
char
*
param
)
{
HINSTANCE
hI
=
ShellExecute
(
NULL
,
NULL
,
cmd
,
param
,
NULL
,
SW_SHOW
);
return
(
int
)
hI
>=
32
;
}
bool
FileExists
(
const
char
*
path
)
{
return
GetFileAttributesA
(
path
)
!=
INVALID_FILE_ATTRIBUTES
;
}
const
char
*
GetDefaultFontPath
()
{
const
char
*
fontPaths
[]
=
...
...
src/platform_x11/Misc.cpp
View file @
259e8f5e
...
...
@@ -4,11 +4,23 @@
#include
<string.h>
#include
"../Misc.h"
void
Misc
::
InitKeymaps
()
{
#include
<unistd.h>
void
Misc
::
PlatformStartup
()
{
}
void
Misc
::
PlatformShutdown
()
{
}
void
Misc
::
InitKeymaps
()
{
return
;
}
void
Misc
::
GetKeymapName
(
char
*
sz
)
{
void
Misc
::
GetKeymapName
(
char
*
sz
)
{
strncpy
(
sz
,
"<native>"
,
7
);
}
...
...
@@ -26,7 +38,7 @@ const char * Misc::GetDefaultFontPath()
{
// Linux case
// TODO: use fonts.conf(5) or X resources or something like that
const
char
*
fontPaths
[]
=
const
char
*
fontPaths
[]
=
{
"/usr/share/fonts/TTF/DejaVuSansMono.ttf"
,
"/usr/share/fonts/TTF/FreeMono.ttf"
,
...
...
Write
Preview
Supports
Markdown
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