Browse Source

Use INS, PGUP etc for help

Serj Kalichev 3 years ago
parent
commit
231bf0732c
1 changed files with 19 additions and 1 deletions
  1. 19 1
      tinyrl/tinyrl.c

+ 19 - 1
tinyrl/tinyrl.c

@@ -526,8 +526,25 @@ static bool_t tinyrl_key_erase_line(tinyrl_t * this, int key)
 	this = this;
 
 	return BOOL_TRUE;
-}/*-------------------------------------------------------- */
+}
+/*-------------------------------------------------------- */
+
+/* It's a dirty hack. The function to print help is external but we need
+ * to show help on some escape sequences. So suppose raw help key is
+ * Ctrl+_ (Control_underscore 0x1f KEY_US) execute external function for this
+ * key here.
+ */
+static bool_t tinyrl_key_help(tinyrl_t *this, int key)
+{
+	if (!this || !this->handlers[KEY_US])
+		return BOOL_FALSE;
+
+	key = key; // Happy compiler
 
+	return this->handlers[KEY_US](this, key);
+}
+
+/*-------------------------------------------------------- */
 static bool_t tinyrl_escape_seq(tinyrl_t *this, const char *esc_seq)
 {
 	int key = 0;
@@ -559,6 +576,7 @@ static bool_t tinyrl_escape_seq(tinyrl_t *this, const char *esc_seq)
 	case tinyrl_vt100_PGDOWN:
 	case tinyrl_vt100_PGUP:
 	case tinyrl_vt100_UNKNOWN:
+		result = tinyrl_key_help(this, key);
 		break;
 	}