Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
derf
feh
Commits
84c27062
Commit
84c27062
authored
7 years ago
by
Birte Kristina Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Put terminal into (mostly) raw mode when reading commands from stdin
Also, restore the previous terminal mode on exit
parent
aaa67e2d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.c
+17
-4
17 additions, 4 deletions
src/main.c
with
17 additions
and
4 deletions
src/main.c
+
17
−
4
View file @
84c27062
...
...
@@ -38,6 +38,9 @@ char **cmdargv = NULL;
int
cmdargc
=
0
;
char
*
mode
=
NULL
;
struct
termios
old_term_settings
;
int
control_via_stdin
=
0
;
int
main
(
int
argc
,
char
**
argv
)
{
atexit
(
feh_clean_exit
);
...
...
@@ -92,7 +95,6 @@ int feh_main_iteration(int block)
static
int
xfd
=
0
;
static
int
fdsize
=
0
;
static
double
pt
=
0
.
0
;
static
int
read_stdin
=
0
;
XEvent
ev
;
struct
timeval
tval
;
fd_set
fdset
;
...
...
@@ -110,11 +112,18 @@ int feh_main_iteration(int block)
pt
=
feh_get_time
();
first
=
0
;
if
(
isatty
(
STDIN_FILENO
))
{
read
_stdin
=
1
;
control_via
_stdin
=
1
;
struct
termios
ctrl
;
if
(
tcgetattr
(
STDIN_FILENO
,
&
old_term_settings
)
==
-
1
)
eprintf
(
"tcgetattr failed"
);
if
(
tcgetattr
(
STDIN_FILENO
,
&
ctrl
)
==
-
1
)
eprintf
(
"tcgetattr failed"
);
ctrl
.
c_lflag
&=
~
ICANON
;
ctrl
.
c_iflag
&=
~
(
PARMRK
|
ISTRIP
|
INLCR
|
IGNCR
|
ICRNL
|
IXON
);
ctrl
.
c_oflag
&=
~
OPOST
;
ctrl
.
c_lflag
&=
~
(
ECHO
|
ICANON
|
IEXTEN
);
ctrl
.
c_cflag
&=
~
(
CSIZE
|
PARENB
);
ctrl
.
c_cflag
|=
CS8
;
if
(
tcsetattr
(
STDIN_FILENO
,
TCSANOW
,
&
ctrl
)
==
-
1
)
eprintf
(
"tcsetattr failed"
);
}
...
...
@@ -138,7 +147,7 @@ int feh_main_iteration(int block)
FD_ZERO
(
&
fdset
);
FD_SET
(
xfd
,
&
fdset
);
if
(
read
_stdin
)
if
(
control_via
_stdin
)
FD_SET
(
STDIN_FILENO
,
&
fdset
);
/* Timers */
...
...
@@ -216,6 +225,10 @@ void feh_clean_exit(void)
if
(
disp
)
XCloseDisplay
(
disp
);
if
(
control_via_stdin
)
if
(
tcsetattr
(
STDIN_FILENO
,
TCSANOW
,
&
old_term_settings
)
==
-
1
)
eprintf
(
"tcsetattr failed"
);
if
(
opt
.
filelistfile
)
feh_write_filelist
(
filelist
,
opt
.
filelistfile
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment