File: 03_staircase-effect-fix

package info (click to toggle)
netris 0.52-10
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 512 kB
  • ctags: 1,100
  • sloc: ansic: 7,657; makefile: 11
file content (51 lines) | stat: -rw-r--r-- 1,306 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Author: Per von Zweigbergk <pvz@e.kth.se>	vim:ft=diff:
Description: fix staircase effect in error message, BTS #83039

Index: b/util.c
===================================================================
--- a/util.c
+++ b/util.c
@@ -267,6 +267,7 @@ ExtFunc volatile void die(char *msg)
 
 ExtFunc volatile void fatal(char *msg)
 {
+	CleanupScreens ();
 	fprintf(stderr, "%s\n", msg);
 	exit(1);
 }
Index: b/curses.c
===================================================================
--- a/curses.c
+++ b/curses.c
@@ -57,6 +57,7 @@ static EventGenRec keyGen =
 static int boardYPos[MAX_SCREENS], boardXPos[MAX_SCREENS];
 static int statusYPos, statusXPos;
 static int haveColor;
+static int screens_dirty = 0;
 
 static char *term_vi;	/* String to make cursor invisible */
 static char *term_ve;	/* String to make cursor visible */
@@ -98,6 +99,7 @@ ExtFunc void InitScreens(void)
 #endif
 
 	AtExit(CleanupScreens);
+	screens_dirty = 1;
 	RestoreSignals(NULL, &oldMask);
 
 	cbreak();
@@ -116,9 +118,12 @@ ExtFunc void InitScreens(void)
 
 ExtFunc void CleanupScreens(void)
 {
-	RemoveEventGen(&keyGen);
-	endwin();
-	OutputTermStr(term_ve, 1);
+	if (screens_dirty) {
+		RemoveEventGen(&keyGen);
+		endwin();
+		OutputTermStr(term_ve, 1);
+		screens_dirty = 0;
+	}
 }
 
 ExtFunc void GetTermcapInfo(void)