console.c
changeset 1046 f1d46abf7d35
parent 1026 02cc18821508
child 1095 b59632d9df1b
equal deleted inserted replaced
1045:01edb6b0cbd6 1046:f1d46abf7d35
   190 					break;
   190 					break;
   191 				case WKC_RETURN:
   191 				case WKC_RETURN:
   192 					IConsolePrintF(_iconsole_color_commands, "] %s", _iconsole_cmdline);
   192 					IConsolePrintF(_iconsole_color_commands, "] %s", _iconsole_cmdline);
   193 					_iconsole_cmdbufferpos = 19;
   193 					_iconsole_cmdbufferpos = 19;
   194 					IConsoleCmdBufferAdd(_iconsole_cmdline);
   194 					IConsoleCmdBufferAdd(_iconsole_cmdline);
   195 					if (strlen(_iconsole_cmdline) != 0) // only execute if there is something typed obviously
   195 
   196 						IConsoleCmdExec(_iconsole_cmdline);
   196 					IConsoleCmdExec(_iconsole_cmdline);
   197 
       
   198 					IConsoleClearCommand();
   197 					IConsoleClearCommand();
   199 					break;
   198 					break;
   200 				case WKC_CTRL | WKC_RETURN:
   199 				case WKC_CTRL | WKC_RETURN:
   201 					if (_iconsole_mode == ICONSOLE_FULL) {
   200 					if (_iconsole_mode == ICONSOLE_FULL) {
   202 						_iconsole_mode = ICONSOLE_OPENED;
   201 						_iconsole_mode = ICONSOLE_OPENED;
   269 	uint i;
   268 	uint i;
   270 	for (i = 0; i <= ICON_BUFFER; i++)
   269 	for (i = 0; i <= ICON_BUFFER; i++)
   271 		free(_iconsole_buffer[i]);
   270 		free(_iconsole_buffer[i]);
   272 }
   271 }
   273 
   272 
       
   273 static void IConsoleWriteToLogFile(const char* string)
       
   274 {
       
   275 	if (_iconsole_output_file != NULL) {
       
   276 		// if there is an console output file ... also print it there
       
   277 		fwrite(string, strlen(string), 1, _iconsole_output_file);
       
   278 		fwrite("\n", 1, 1, _iconsole_output_file);
       
   279 	}
       
   280 }
       
   281 
       
   282 bool CloseConsoleLogIfActive(void)
       
   283 {
       
   284 	if (_iconsole_output_file != NULL) {
       
   285 		IConsolePrintF(_iconsole_color_default, "file output complete");
       
   286 		fclose(_iconsole_output_file);
       
   287 		return true;
       
   288 	}
       
   289 
       
   290 	return false;
       
   291 }
       
   292 
   274 void IConsoleFree(void)
   293 void IConsoleFree(void)
   275 {
   294 {
   276 	_iconsole_inited = false;
   295 	_iconsole_inited = false;
   277 	IConsoleClear();
   296 	IConsoleClear();
   278 	if (_iconsole_output_file != NULL) fclose(_iconsole_output_file);
   297 	CloseConsoleLogIfActive();
   279 }
   298 }
   280 
   299 
   281 void IConsoleResize(void)
   300 void IConsoleResize(void)
   282 {
   301 {
   283 
   302 
   380 		return;
   399 		return;
   381 	}
   400 	}
   382 
   401 
   383 	if (_network_dedicated) {
   402 	if (_network_dedicated) {
   384 		printf("%s\n", string);
   403 		printf("%s\n", string);
       
   404 		IConsoleWriteToLogFile(string);
   385 		return;
   405 		return;
   386 	}
   406 	}
   387 
   407 
   388 	if (!_iconsole_inited) return;
   408 	if (!_iconsole_inited) return;
   389 
   409 
   401 		_new = _ex;
   421 		_new = _ex;
   402 		_newc = _exc;
   422 		_newc = _exc;
   403 	}
   423 	}
   404 	free(_ex);
   424 	free(_ex);
   405 
   425 
   406 	if (_iconsole_output_file != NULL) {
   426 	IConsoleWriteToLogFile(string);
   407 		// if there is an console output file ... also print it there
       
   408 		fwrite(string, strlen(string), 1, _iconsole_output_file);
       
   409 		fwrite("\n", 1, 1, _iconsole_output_file);
       
   410 	}
       
   411 
   427 
   412 	if (_iconsole_win != NULL) SetWindowDirty(_iconsole_win);
   428 	if (_iconsole_win != NULL) SetWindowDirty(_iconsole_win);
   413 }
   429 }
   414 
   430 
   415 
   431 
  1070 	bool skip_lt_change;
  1086 	bool skip_lt_change;
  1071 
  1087 
  1072 	uint c;
  1088 	uint c;
  1073 	uint i;
  1089 	uint i;
  1074 	uint l;
  1090 	uint l;
       
  1091 	
       
  1092 	if (strlen(cmdstr) == 0) // only execute if there is something typed obviously
       
  1093 		return;
  1075 
  1094 
  1076 	if (_stdlib_con_developer)
  1095 	if (_stdlib_con_developer)
  1077 		IConsolePrintF(_iconsole_color_debug, "CONDEBUG: execution_cmdline: %s", cmdstr);
  1096 		IConsolePrintF(_iconsole_color_debug, "CONDEBUG: execution_cmdline: %s", cmdstr);
  1078 
  1097 
  1079 	//** clearing buffer **//
  1098 	//** clearing buffer **//