Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
c8d46da1
Commit
c8d46da1
authored
Oct 25, 2013
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
help: use direct ioctl() rather than spawning stty to get console width
parent
62fe4d5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
29 deletions
+27
-29
src/config/help.c
src/config/help.c
+27
-29
No files found.
src/config/help.c
View file @
c8d46da1
...
...
@@ -41,13 +41,39 @@ static void PauseConsole (void);
# define ShowConsole() (void)0
# define PauseConsole() (void)0
# include <unistd.h>
# include <sys/ioctl.h>
#endif
static
void
Help
(
vlc_object_t
*
,
const
char
*
);
static
void
Usage
(
vlc_object_t
*
,
const
char
*
);
static
void
Version
(
void
);
static
void
ListModules
(
vlc_object_t
*
,
bool
);
static
int
ConsoleWidth
(
void
);
/**
* Returns the console width or a best guess.
*/
static
unsigned
ConsoleWidth
(
void
)
{
#ifdef TIOCGWINSZ
struct
winsize
ws
;
if
(
ioctl
(
STDOUT_FILENO
,
TIOCGWINSZ
,
&
ws
)
==
0
)
return
ws
.
ws_col
;
#endif
#ifdef WIOCGETD
struct
uwdata
uw
;
if
(
ioctl
(
STDOUT_FILENO
,
WIOCGETD
,
&
uw
)
==
0
)
return
uw
.
uw_height
/
uw
.
uw_vs
;
#endif
#if defined (_WIN32) && !VLC_WINSTORE_APP
CONSOLE_SCREEN_BUFFER_INFO
buf
;
if
(
GetConsoleScreenBufferInfo
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
&
buf
))
return
buf
.
dwSize
.
X
;
#endif
return
80
;
}
/**
* Checks for help command line options such as --help or --version.
...
...
@@ -819,31 +845,3 @@ static void PauseConsole( void )
fclose
(
stdout
);
}
#endif
/*****************************************************************************
* ConsoleWidth: Return the console width in characters
*****************************************************************************
* We use the stty shell command to get the console width; if this fails or
* if the width is less than 80, we default to 80.
*****************************************************************************/
static
int
ConsoleWidth
(
void
)
{
unsigned
i_width
=
80
;
#ifndef _WIN32
FILE
*
file
=
popen
(
"stty size 2>/dev/null"
,
"r"
);
if
(
file
!=
NULL
)
{
if
(
fscanf
(
file
,
"%*u %u"
,
&
i_width
)
<=
0
)
i_width
=
80
;
pclose
(
file
);
}
#elif !VLC_WINSTORE_APP
CONSOLE_SCREEN_BUFFER_INFO
buf
;
if
(
GetConsoleScreenBufferInfo
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
&
buf
))
i_width
=
buf
.
dwSize
.
X
;
#endif
return
i_width
;
}
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