Browse Source

Fix tinyrl busy flag

Serj Kalichev 7 months ago
parent
commit
9ba420b572
2 changed files with 4 additions and 8 deletions
  1. 1 1
      tinyrl/tinyrl/private.h
  2. 3 7
      tinyrl/tinyrl/tinyrl.c

+ 1 - 1
tinyrl/tinyrl/private.h

@@ -60,7 +60,7 @@ struct tinyrl_s {
 	size_t prompt_len; // strlen()
 	size_t prompt_chars; // Symbol positions
 	void *udata; // Arbitrary user data
-	bool_t busy; // Long executed commands set this flag. tinyrl_read() drops it
+	bool_t busy; // Long executed commands set this flag
 
 	// Input processing vars. Input is processed char by char so
 	// the current state of processing is necessary.

+ 3 - 7
tinyrl/tinyrl/tinyrl.c

@@ -419,19 +419,15 @@ int tinyrl_read(tinyrl_t *tinyrl)
 
 	assert(tinyrl);
 
-	tinyrl_set_busy(tinyrl, BOOL_FALSE);
-
-	while ((rc = vt100_getchar(tinyrl->term, &key)) > 0) {
+	while (!tinyrl_busy(tinyrl) &&
+		((rc = vt100_getchar(tinyrl->term, &key)) > 0)) {
 		count++;
 		process_char(tinyrl, key);
 		// Some commands can't be processed immediately by handlers and
 		// need some network exchange for example. In this case we will
 		// not execute redisplay() here.
-		if (!tinyrl->utf8_cont && !tinyrl_busy(tinyrl)) {
+		if (!tinyrl->utf8_cont && !tinyrl_busy(tinyrl))
 			tinyrl_redisplay(tinyrl);
-	//		printf("%s\n", tinyrl->line.str);
-		}
-//printf("key=%u, pos=%lu, len=%lu\n", key, tinyrl->line.pos, tinyrl->line.len);
 	}
 
 	if ((rc < 0) && (EAGAIN == errno))