summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@lavabit.com>2009-07-02 21:15:39 +0200
committerLars-Dominik Braun <PromyLOPh@lavabit.com>2009-07-02 21:15:39 +0200
commit830ac85aba11ca56f610e3119b7d92a9e9de18ac (patch)
tree8f8ce65176bfa5b1df36bacf0235e6d0a1654c6b /src
parent2c7a776e8882b7896090a24dc09ccd42e6f8a6ca (diff)
downloadpianobar-windows-830ac85aba11ca56f610e3119b7d92a9e9de18ac.tar.gz
pianobar-windows-830ac85aba11ca56f610e3119b7d92a9e9de18ac.tar.bz2
pianobar-windows-830ac85aba11ca56f610e3119b7d92a9e9de18ac.zip
Enable echoing on early return, too
See commit a6c521fecd91867c6e184106f4e63445d1cb158a
Diffstat (limited to 'src')
-rw-r--r--src/main.c7
-rw-r--r--src/terminal.c15
-rw-r--r--src/terminal.h6
3 files changed, 24 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 2802546..e9d0152 100644
--- a/src/main.c
+++ b/src/main.c
@@ -81,7 +81,8 @@ int main (int argc, char **argv) {
BarUiMsg (MSG_NONE, "Welcome to " PACKAGE "!\n");
/* save terminal attributes, before disabling echoing */
- tcgetattr (fileno (stdin), &termOrig);
+ BarTermSave (&termOrig);
+
BarTermSetEcho (0);
/* init some things */
xmlInitParser ();
@@ -139,10 +140,12 @@ int main (int argc, char **argv) {
if (BarUiPrintPianoStatus (PianoConnect (&ph, settings.username,
settings.password)) !=
PIANO_RET_OK) {
+ BarTermRestore (&termOrig);
return 0;
}
BarUiMsg (MSG_INFO, "Get stations... ");
if (BarUiPrintPianoStatus (PianoGetStations (&ph)) != PIANO_RET_OK) {
+ BarTermRestore (&termOrig);
return 0;
}
@@ -311,7 +314,7 @@ int main (int argc, char **argv) {
BarSettingsDestroy (&settings);
/* restore terminal attributes, zsh doesn't need this, bash does... */
- tcsetattr (fileno (stdin), TCSANOW, &termOrig);
+ BarTermRestore (&termOrig);
return 0;
}
diff --git a/src/terminal.c b/src/terminal.c
index 09d0fe8..ab96004 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -56,3 +56,18 @@ void BarTermSetBuffer (char enable) {
}
tcsetattr(fileno (stdin), TCSANOW, &termopts);
}
+
+/* Save old terminal settings
+ * @param save settings here
+ */
+inline void BarTermSave (struct termios *termOrig) {
+ tcgetattr (fileno (stdin), termOrig);
+}
+
+/* Restore terminal settings
+ * @param Old settings
+ */
+inline void BarTermRestore (struct termios *termOrig) {
+ tcsetattr (fileno (stdin), TCSANOW, termOrig);
+}
+
diff --git a/src/terminal.h b/src/terminal.h
index c4fc5cf..13e9d57 100644
--- a/src/terminal.h
+++ b/src/terminal.h
@@ -24,7 +24,9 @@ THE SOFTWARE.
#ifndef _TERMINAL_H
#define _TERMINAL_H
-void BarTermSetEcho (char enable);
-void BarTermSetBuffer (char enable);
+void BarTermSetEcho (char);
+void BarTermSetBuffer (char);
+inline void BarTermSave (struct termios *);
+inline void BarTermRestore (struct termios *termOrig);
#endif /* _TERMINAL_H */