sources/interface.cpp

branch
experimental
changeset 38
80b26bc9707a
parent 34
3caf69e7350b
child 39
052393cf9016
--- a/sources/interface.cpp	Mon Dec 15 09:12:50 2014 +0200
+++ b/sources/interface.cpp	Mon Dec 15 10:31:52 2014 +0200
@@ -719,6 +719,19 @@
 		g_needOutputRender = true;
 		break;
 
+	case '\t':
+		{
+			int space = current_input().find (" ");
+
+			if (g_inputState == INPUTSTATE_NORMAL
+				and g_cursor > 0
+				and (space == -1 or space >= g_cursor))
+			{
+				RCONSession::get_session()->request_tab_complete (current_input().mid (0, g_cursor));
+			}
+		}
+		break;
+
 	case '\n':
 	case KEY_ENTER:
 		switch (g_inputState)
@@ -768,6 +781,8 @@
 			safe_disconnect ([]() {set_input_state (INPUTSTATE_ADDRESS);});
 		break;
 	}
+
+	render();
 }
 
 // -------------------------------------------------------------------------------------------------
@@ -926,3 +941,18 @@
 
 	return max (rows, 1);
 }
+
+// -------------------------------------------------------------------------------------------------
+//
+FUNCTION
+Interface::tab_complete (const String& part, const String& complete) -> void
+{
+	String& input = mutable_current_input();
+
+	if (input.starts_with (part))
+	{
+		input.replace (0, part.length(), complete);
+		g_cursor = complete.length();
+		g_needInputRender = true;
+	}
+}

mercurial