diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Framework/Console | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Framework/Console')
-rw-r--r-- | OpenSim/Framework/Console/AssemblyInfo.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Console/CommandConsole.cs | 46 | ||||
-rw-r--r-- | OpenSim/Framework/Console/ConsoleDisplayUtil.cs | 48 | ||||
-rw-r--r-- | OpenSim/Framework/Console/ConsoleUtil.cs | 175 | ||||
-rw-r--r-- | OpenSim/Framework/Console/LocalConsole.cs | 85 | ||||
-rw-r--r-- | OpenSim/Framework/Console/MockConsole.cs | 3 | ||||
-rw-r--r-- | OpenSim/Framework/Console/RemoteConsole.cs | 4 |
7 files changed, 320 insertions, 43 deletions
diff --git a/OpenSim/Framework/Console/AssemblyInfo.cs b/OpenSim/Framework/Console/AssemblyInfo.cs index 37c7304..67af471 100644 --- a/OpenSim/Framework/Console/AssemblyInfo.cs +++ b/OpenSim/Framework/Console/AssemblyInfo.cs | |||
@@ -55,4 +55,4 @@ using System.Runtime.InteropServices; | |||
55 | // You can specify all values by your own or you can build default build and revision | 55 | // You can specify all values by your own or you can build default build and revision |
56 | // numbers with the '*' character (the default): | 56 | // numbers with the '*' character (the default): |
57 | 57 | ||
58 | [assembly : AssemblyVersion("0.7.5.*")] | 58 | [assembly : AssemblyVersion("0.8.2.*")] |
diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index b9f402a..0f68afe 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs | |||
@@ -424,9 +424,9 @@ namespace OpenSim.Framework.Console | |||
424 | return new string[] { new List<string>(current.Keys)[0] }; | 424 | return new string[] { new List<string>(current.Keys)[0] }; |
425 | } | 425 | } |
426 | 426 | ||
427 | public string[] Resolve(string[] cmd) | 427 | private CommandInfo ResolveCommand(string[] cmd, out string[] result) |
428 | { | 428 | { |
429 | string[] result = cmd; | 429 | result = cmd; |
430 | int index = -1; | 430 | int index = -1; |
431 | 431 | ||
432 | Dictionary<string, object> current = tree; | 432 | Dictionary<string, object> current = tree; |
@@ -458,7 +458,7 @@ namespace OpenSim.Framework.Console | |||
458 | } | 458 | } |
459 | else if (found.Count > 0) | 459 | else if (found.Count > 0) |
460 | { | 460 | { |
461 | return new string[0]; | 461 | return null; |
462 | } | 462 | } |
463 | else | 463 | else |
464 | { | 464 | { |
@@ -467,21 +467,37 @@ namespace OpenSim.Framework.Console | |||
467 | } | 467 | } |
468 | 468 | ||
469 | if (current.ContainsKey(String.Empty)) | 469 | if (current.ContainsKey(String.Empty)) |
470 | return (CommandInfo)current[String.Empty]; | ||
471 | |||
472 | return null; | ||
473 | } | ||
474 | |||
475 | public bool HasCommand(string command) | ||
476 | { | ||
477 | string[] result; | ||
478 | return ResolveCommand(Parser.Parse(command), out result) != null; | ||
479 | } | ||
480 | |||
481 | public string[] Resolve(string[] cmd) | ||
482 | { | ||
483 | string[] result; | ||
484 | CommandInfo ci = ResolveCommand(cmd, out result); | ||
485 | |||
486 | if (ci == null) | ||
487 | return new string[0]; | ||
488 | |||
489 | if (ci.fn.Count == 0) | ||
490 | return new string[0]; | ||
491 | |||
492 | foreach (CommandDelegate fn in ci.fn) | ||
470 | { | 493 | { |
471 | CommandInfo ci = (CommandInfo)current[String.Empty]; | 494 | if (fn != null) |
472 | if (ci.fn.Count == 0) | 495 | fn(ci.module, result); |
496 | else | ||
473 | return new string[0]; | 497 | return new string[0]; |
474 | foreach (CommandDelegate fn in ci.fn) | ||
475 | { | ||
476 | if (fn != null) | ||
477 | fn(ci.module, result); | ||
478 | else | ||
479 | return new string[0]; | ||
480 | } | ||
481 | return result; | ||
482 | } | 498 | } |
483 | 499 | ||
484 | return new string[0]; | 500 | return result; |
485 | } | 501 | } |
486 | 502 | ||
487 | public XmlElement GetXml(XmlDocument doc) | 503 | public XmlElement GetXml(XmlDocument doc) |
diff --git a/OpenSim/Framework/Console/ConsoleDisplayUtil.cs b/OpenSim/Framework/Console/ConsoleDisplayUtil.cs new file mode 100644 index 0000000..6417663 --- /dev/null +++ b/OpenSim/Framework/Console/ConsoleDisplayUtil.cs | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | |||
30 | namespace OpenSim.Framework.Console | ||
31 | { | ||
32 | /// <summary> | ||
33 | /// This will be a set of typical column sizes to allow greater consistency between console commands. | ||
34 | /// </summary> | ||
35 | public static class ConsoleDisplayUtil | ||
36 | { | ||
37 | public const int CoordTupleSize = 11; | ||
38 | public const int PortSize = 5; | ||
39 | |||
40 | public const int EstateNameSize = 20; | ||
41 | public const int ParcelNameSize = 40; | ||
42 | public const int RegionNameSize = 20; | ||
43 | public const int UserNameSize = 35; | ||
44 | |||
45 | public const int UuidSize = 36; | ||
46 | public const int VectorSize = 15; | ||
47 | } | ||
48 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index dff956a..44f6dc1 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs | |||
@@ -49,14 +49,14 @@ namespace OpenSim.Framework.Console | |||
49 | = @"Each component of the coord is comma separated. There must be no spaces between the commas. | 49 | = @"Each component of the coord is comma separated. There must be no spaces between the commas. |
50 | If you don't care about the z component you can simply omit it. | 50 | If you don't care about the z component you can simply omit it. |
51 | If you don't care about the x or y components then you can leave them blank (though a comma is still required) | 51 | If you don't care about the x or y components then you can leave them blank (though a comma is still required) |
52 | If you want to specify the maxmimum value of a component then you can use ~ instead of a number | 52 | If you want to specify the maximum value of a component then you can use ~ instead of a number |
53 | If you want to specify the minimum value of a component then you can use -~ instead of a number | 53 | If you want to specify the minimum value of a component then you can use -~ instead of a number |
54 | e.g. | 54 | e.g. |
55 | delete object pos 20,20,20 to 40,40,40 | 55 | show object pos 20,20,20 to 40,40,40 |
56 | delete object pos 20,20 to 40,40 | 56 | delete object pos 20,20 to 40,40 |
57 | delete object pos ,20,20 to ,40,40 | 57 | show object pos ,20,20 to ,40,40 |
58 | delete object pos ,,30 to ,,~ | 58 | delete object pos ,,30 to ,,~ |
59 | delete object pos ,,-~ to ,,30"; | 59 | show object pos ,,-~ to ,,30"; |
60 | 60 | ||
61 | public const string MinRawConsoleVectorValue = "-~"; | 61 | public const string MinRawConsoleVectorValue = "-~"; |
62 | public const string MaxRawConsoleVectorValue = "~"; | 62 | public const string MaxRawConsoleVectorValue = "~"; |
@@ -156,12 +156,32 @@ namespace OpenSim.Framework.Console | |||
156 | } | 156 | } |
157 | 157 | ||
158 | /// <summary> | 158 | /// <summary> |
159 | /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 | 159 | /// Convert a console input to a bool, automatically complaining if a console is given. |
160 | /// </summary> | 160 | /// </summary> |
161 | /// <param name='console'>Can be null if no console is available.</param> | 161 | /// <param name='console'>Can be null if no console is available.</param> |
162 | /// <param name='rawConsoleVector'>/param> | 162 | /// <param name='rawConsoleVector'>/param> |
163 | /// <param name='vector'></param> | 163 | /// <param name='vector'></param> |
164 | /// <returns></returns> | 164 | /// <returns></returns> |
165 | public static bool TryParseConsoleBool(ICommandConsole console, string rawConsoleString, out bool b) | ||
166 | { | ||
167 | if (!bool.TryParse(rawConsoleString, out b)) | ||
168 | { | ||
169 | if (console != null) | ||
170 | console.OutputFormat("ERROR: {0} is not a true or false value", rawConsoleString); | ||
171 | |||
172 | return false; | ||
173 | } | ||
174 | |||
175 | return true; | ||
176 | } | ||
177 | |||
178 | /// <summary> | ||
179 | /// Convert a console input to an int, automatically complaining if a console is given. | ||
180 | /// </summary> | ||
181 | /// <param name='console'>Can be null if no console is available.</param> | ||
182 | /// <param name='rawConsoleInt'>/param> | ||
183 | /// <param name='i'></param> | ||
184 | /// <returns></returns> | ||
165 | public static bool TryParseConsoleInt(ICommandConsole console, string rawConsoleInt, out int i) | 185 | public static bool TryParseConsoleInt(ICommandConsole console, string rawConsoleInt, out int i) |
166 | { | 186 | { |
167 | if (!int.TryParse(rawConsoleInt, out i)) | 187 | if (!int.TryParse(rawConsoleInt, out i)) |
@@ -174,6 +194,71 @@ namespace OpenSim.Framework.Console | |||
174 | 194 | ||
175 | return true; | 195 | return true; |
176 | } | 196 | } |
197 | |||
198 | /// <summary> | ||
199 | /// Convert a console input to a float, automatically complaining if a console is given. | ||
200 | /// </summary> | ||
201 | /// <param name='console'>Can be null if no console is available.</param> | ||
202 | /// <param name='rawConsoleInput'>/param> | ||
203 | /// <param name='i'></param> | ||
204 | /// <returns></returns> | ||
205 | public static bool TryParseConsoleFloat(ICommandConsole console, string rawConsoleInput, out float i) | ||
206 | { | ||
207 | if (!float.TryParse(rawConsoleInput, out i)) | ||
208 | { | ||
209 | if (console != null) | ||
210 | console.OutputFormat("ERROR: {0} is not a valid float", rawConsoleInput); | ||
211 | |||
212 | return false; | ||
213 | } | ||
214 | |||
215 | return true; | ||
216 | } | ||
217 | |||
218 | /// <summary> | ||
219 | /// Convert a console input to a double, automatically complaining if a console is given. | ||
220 | /// </summary> | ||
221 | /// <param name='console'>Can be null if no console is available.</param> | ||
222 | /// <param name='rawConsoleInput'>/param> | ||
223 | /// <param name='i'></param> | ||
224 | /// <returns></returns> | ||
225 | public static bool TryParseConsoleDouble(ICommandConsole console, string rawConsoleInput, out double i) | ||
226 | { | ||
227 | if (!double.TryParse(rawConsoleInput, out i)) | ||
228 | { | ||
229 | if (console != null) | ||
230 | console.OutputFormat("ERROR: {0} is not a valid double", rawConsoleInput); | ||
231 | |||
232 | return false; | ||
233 | } | ||
234 | |||
235 | return true; | ||
236 | } | ||
237 | |||
238 | /// <summary> | ||
239 | /// Convert a console integer to a natural int, automatically complaining if a console is given. | ||
240 | /// </summary> | ||
241 | /// <param name='console'>Can be null if no console is available.</param> | ||
242 | /// <param name='rawConsoleInt'>/param> | ||
243 | /// <param name='i'></param> | ||
244 | /// <returns></returns> | ||
245 | public static bool TryParseConsoleNaturalInt(ICommandConsole console, string rawConsoleInt, out int i) | ||
246 | { | ||
247 | if (TryParseConsoleInt(console, rawConsoleInt, out i)) | ||
248 | { | ||
249 | if (i < 0) | ||
250 | { | ||
251 | if (console != null) | ||
252 | console.OutputFormat("ERROR: {0} is not a positive integer", rawConsoleInt); | ||
253 | |||
254 | return false; | ||
255 | } | ||
256 | |||
257 | return true; | ||
258 | } | ||
259 | |||
260 | return false; | ||
261 | } | ||
177 | 262 | ||
178 | /// <summary> | 263 | /// <summary> |
179 | /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 | 264 | /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 |
@@ -207,24 +292,82 @@ namespace OpenSim.Framework.Console | |||
207 | /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue | 292 | /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue |
208 | /// Other than that, component values must be numeric. | 293 | /// Other than that, component values must be numeric. |
209 | /// </param> | 294 | /// </param> |
210 | /// <param name='blankComponentFunc'></param> | 295 | /// <param name='blankComponentFunc'> |
296 | /// Behaviour if component is blank. If null then conversion fails on a blank component. | ||
297 | /// </param> | ||
211 | /// <param name='vector'></param> | 298 | /// <param name='vector'></param> |
212 | /// <returns></returns> | 299 | /// <returns></returns> |
213 | public static bool TryParseConsoleVector( | 300 | public static bool TryParseConsoleVector( |
214 | string rawConsoleVector, Func<string, string> blankComponentFunc, out Vector3 vector) | 301 | string rawConsoleVector, Func<string, string> blankComponentFunc, out Vector3 vector) |
215 | { | 302 | { |
216 | List<string> components = rawConsoleVector.Split(VectorSeparatorChars).ToList(); | 303 | return Vector3.TryParse(CookVector(rawConsoleVector, 3, blankComponentFunc), out vector); |
217 | 304 | } | |
218 | if (components.Count < 1 || components.Count > 3) | 305 | |
306 | /// <summary> | ||
307 | /// Convert a vector input from the console to an OpenMetaverse.Vector2 | ||
308 | /// </summary> | ||
309 | /// <param name='rawConsoleVector'> | ||
310 | /// A string in the form <x>,<y> where there is no space between values. | ||
311 | /// Any component can be missing (e.g. ,40). blankComponentFunc is invoked to replace the blank with a suitable value | ||
312 | /// Also, if the blank component is at the end, then the comma can be missed off entirely (e.g. 40) | ||
313 | /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue | ||
314 | /// Other than that, component values must be numeric. | ||
315 | /// </param> | ||
316 | /// <param name='blankComponentFunc'> | ||
317 | /// Behaviour if component is blank. If null then conversion fails on a blank component. | ||
318 | /// </param> | ||
319 | /// <param name='vector'></param> | ||
320 | /// <returns></returns> | ||
321 | public static bool TryParseConsole2DVector( | ||
322 | string rawConsoleVector, Func<string, string> blankComponentFunc, out Vector2 vector) | ||
323 | { | ||
324 | // We don't use Vector2.TryParse() for now because for some reason it expects an input with 3 components | ||
325 | // rather than 2. | ||
326 | string cookedVector = CookVector(rawConsoleVector, 2, blankComponentFunc); | ||
327 | |||
328 | if (cookedVector == null) | ||
219 | { | 329 | { |
220 | vector = Vector3.Zero; | 330 | vector = Vector2.Zero; |
331 | |||
221 | return false; | 332 | return false; |
222 | } | 333 | } |
334 | else | ||
335 | { | ||
336 | string[] cookedComponents = cookedVector.Split(VectorSeparatorChars); | ||
337 | |||
338 | vector = new Vector2(float.Parse(cookedComponents[0]), float.Parse(cookedComponents[1])); | ||
339 | |||
340 | return true; | ||
341 | } | ||
342 | |||
343 | //return Vector2.TryParse(CookVector(rawConsoleVector, 2, blankComponentFunc), out vector); | ||
344 | } | ||
345 | |||
346 | /// <summary> | ||
347 | /// Convert a raw console vector into a vector that can be be parsed by the relevant OpenMetaverse.TryParse() | ||
348 | /// </summary> | ||
349 | /// <param name='rawConsoleVector'></param> | ||
350 | /// <param name='dimensions'></param> | ||
351 | /// <param name='blankComponentFunc'></param> | ||
352 | /// <returns>null if conversion was not possible</returns> | ||
353 | private static string CookVector( | ||
354 | string rawConsoleVector, int dimensions, Func<string, string> blankComponentFunc) | ||
355 | { | ||
356 | List<string> components = rawConsoleVector.Split(VectorSeparatorChars).ToList(); | ||
223 | 357 | ||
224 | for (int i = components.Count; i < 3; i++) | 358 | if (components.Count < 1 || components.Count > dimensions) |
225 | components.Add(""); | 359 | return null; |
226 | 360 | ||
227 | List<string> semiDigestedComponents | 361 | if (components.Count < dimensions) |
362 | { | ||
363 | if (blankComponentFunc == null) | ||
364 | return null; | ||
365 | else | ||
366 | for (int i = components.Count; i < dimensions; i++) | ||
367 | components.Add(""); | ||
368 | } | ||
369 | |||
370 | List<string> cookedComponents | ||
228 | = components.ConvertAll<string>( | 371 | = components.ConvertAll<string>( |
229 | c => | 372 | c => |
230 | { | 373 | { |
@@ -238,11 +381,7 @@ namespace OpenSim.Framework.Console | |||
238 | return c; | 381 | return c; |
239 | }); | 382 | }); |
240 | 383 | ||
241 | string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray()); | 384 | return string.Join(VectorSeparator, cookedComponents.ToArray()); |
242 | |||
243 | // m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector); | ||
244 | |||
245 | return Vector3.TryParse(semiDigestedConsoleVector, out vector); | ||
246 | } | 385 | } |
247 | } | 386 | } |
248 | } \ No newline at end of file | 387 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index d41481f..28293c0 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs | |||
@@ -32,6 +32,8 @@ using System.Reflection; | |||
32 | using System.Text; | 32 | using System.Text; |
33 | using System.Text.RegularExpressions; | 33 | using System.Text.RegularExpressions; |
34 | using System.Threading; | 34 | using System.Threading; |
35 | using System.IO; | ||
36 | using Nini.Config; | ||
35 | using log4net; | 37 | using log4net; |
36 | 38 | ||
37 | namespace OpenSim.Framework.Console | 39 | namespace OpenSim.Framework.Console |
@@ -41,11 +43,18 @@ namespace OpenSim.Framework.Console | |||
41 | /// </summary> | 43 | /// </summary> |
42 | public class LocalConsole : CommandConsole | 44 | public class LocalConsole : CommandConsole |
43 | { | 45 | { |
44 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | private string m_historyPath; | ||
48 | private bool m_historyEnable; | ||
45 | 49 | ||
46 | // private readonly object m_syncRoot = new object(); | 50 | // private readonly object m_syncRoot = new object(); |
47 | private const string LOGLEVEL_NONE = "(none)"; | 51 | private const string LOGLEVEL_NONE = "(none)"; |
48 | 52 | ||
53 | // Used to extract categories for colourization. | ||
54 | private Regex m_categoryRegex | ||
55 | = new Regex( | ||
56 | @"^(?<Front>.*?)\[(?<Category>[^\]]+)\]:?(?<End>.*)", RegexOptions.Singleline | RegexOptions.Compiled); | ||
57 | |||
49 | private int m_cursorYPosition = -1; | 58 | private int m_cursorYPosition = -1; |
50 | private int m_cursorXPosition = 0; | 59 | private int m_cursorXPosition = 0; |
51 | private StringBuilder m_commandLine = new StringBuilder(); | 60 | private StringBuilder m_commandLine = new StringBuilder(); |
@@ -74,8 +83,54 @@ namespace OpenSim.Framework.Console | |||
74 | return Colors[(Math.Abs(input.ToUpper().GetHashCode()) % Colors.Length)]; | 83 | return Colors[(Math.Abs(input.ToUpper().GetHashCode()) % Colors.Length)]; |
75 | } | 84 | } |
76 | 85 | ||
77 | public LocalConsole(string defaultPrompt) : base(defaultPrompt) | 86 | public LocalConsole(string defaultPrompt, IConfig startupConfig = null) : base(defaultPrompt) |
78 | { | 87 | { |
88 | |||
89 | if (startupConfig == null) return; | ||
90 | |||
91 | m_historyEnable = startupConfig.GetBoolean("ConsoleHistoryFileEnabled", false); | ||
92 | if (!m_historyEnable) | ||
93 | { | ||
94 | m_log.Info("[LOCAL CONSOLE]: Persistent command line history from file is Disabled"); | ||
95 | return; | ||
96 | } | ||
97 | |||
98 | string m_historyFile = startupConfig.GetString("ConsoleHistoryFile", "OpenSimConsoleHistory.txt"); | ||
99 | int m_historySize = startupConfig.GetInt("ConsoleHistoryFileLines", 100); | ||
100 | m_historyPath = Path.GetFullPath(Path.Combine(Util.configDir(), m_historyFile)); | ||
101 | m_log.InfoFormat("[LOCAL CONSOLE]: Persistent command line history is Enabled, up to {0} lines from file {1}", m_historySize, m_historyPath); | ||
102 | |||
103 | if (File.Exists(m_historyPath)) | ||
104 | { | ||
105 | using (StreamReader history_file = new StreamReader(m_historyPath)) | ||
106 | { | ||
107 | string line; | ||
108 | while ((line = history_file.ReadLine()) != null) | ||
109 | { | ||
110 | m_history.Add(line); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | if (m_history.Count > m_historySize) | ||
115 | { | ||
116 | while (m_history.Count > m_historySize) | ||
117 | m_history.RemoveAt(0); | ||
118 | |||
119 | using (StreamWriter history_file = new StreamWriter(m_historyPath)) | ||
120 | { | ||
121 | foreach (string line in m_history) | ||
122 | { | ||
123 | history_file.WriteLine(line); | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | m_log.InfoFormat("[LOCAL CONSOLE]: Read {0} lines of command line history from file {1}", m_history.Count, m_historyPath); | ||
128 | } | ||
129 | else | ||
130 | { | ||
131 | m_log.InfoFormat("[LOCAL CONSOLE]: Creating new empty command line history file {0}", m_historyPath); | ||
132 | File.Create(m_historyPath).Dispose(); | ||
133 | } | ||
79 | } | 134 | } |
80 | 135 | ||
81 | private void AddToHistory(string text) | 136 | private void AddToHistory(string text) |
@@ -84,6 +139,10 @@ namespace OpenSim.Framework.Console | |||
84 | m_history.RemoveAt(0); | 139 | m_history.RemoveAt(0); |
85 | 140 | ||
86 | m_history.Add(text); | 141 | m_history.Add(text); |
142 | if (m_historyEnable) | ||
143 | { | ||
144 | File.AppendAllText(m_historyPath, text + Environment.NewLine); | ||
145 | } | ||
87 | } | 146 | } |
88 | 147 | ||
89 | /// <summary> | 148 | /// <summary> |
@@ -280,11 +339,8 @@ namespace OpenSim.Framework.Console | |||
280 | string outText = text; | 339 | string outText = text; |
281 | 340 | ||
282 | if (level != LOGLEVEL_NONE) | 341 | if (level != LOGLEVEL_NONE) |
283 | { | 342 | { |
284 | string regex = @"^(?<Front>.*?)\[(?<Category>[^\]]+)\]:?(?<End>.*)"; | 343 | MatchCollection matches = m_categoryRegex.Matches(text); |
285 | |||
286 | Regex RE = new Regex(regex, RegexOptions.Multiline); | ||
287 | MatchCollection matches = RE.Matches(text); | ||
288 | 344 | ||
289 | if (matches.Count == 1) | 345 | if (matches.Count == 1) |
290 | { | 346 | { |
@@ -426,6 +482,21 @@ namespace OpenSim.Framework.Console | |||
426 | System.Console.Write("{0}", prompt); | 482 | System.Console.Write("{0}", prompt); |
427 | 483 | ||
428 | break; | 484 | break; |
485 | case ConsoleKey.Delete: | ||
486 | if (m_cursorXPosition == m_commandLine.Length) | ||
487 | break; | ||
488 | |||
489 | m_commandLine.Remove(m_cursorXPosition, 1); | ||
490 | |||
491 | SetCursorLeft(0); | ||
492 | m_cursorYPosition = SetCursorTop(m_cursorYPosition); | ||
493 | |||
494 | if (m_echo) | ||
495 | System.Console.Write("{0}{1} ", prompt, m_commandLine); | ||
496 | else | ||
497 | System.Console.Write("{0}", prompt); | ||
498 | |||
499 | break; | ||
429 | case ConsoleKey.End: | 500 | case ConsoleKey.End: |
430 | m_cursorXPosition = m_commandLine.Length; | 501 | m_cursorXPosition = m_commandLine.Length; |
431 | break; | 502 | break; |
diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs index 8ba58e4..1a142df 100644 --- a/OpenSim/Framework/Console/MockConsole.cs +++ b/OpenSim/Framework/Console/MockConsole.cs | |||
@@ -40,7 +40,9 @@ namespace OpenSim.Framework.Console | |||
40 | /// </summary> | 40 | /// </summary> |
41 | public class MockConsole : ICommandConsole | 41 | public class MockConsole : ICommandConsole |
42 | { | 42 | { |
43 | #pragma warning disable 0067 | ||
43 | public event OnOutputDelegate OnOutput; | 44 | public event OnOutputDelegate OnOutput; |
45 | #pragma warning restore 0067 | ||
44 | 46 | ||
45 | private MockCommands m_commands = new MockCommands(); | 47 | private MockCommands m_commands = new MockCommands(); |
46 | 48 | ||
@@ -80,6 +82,7 @@ namespace OpenSim.Framework.Console | |||
80 | public void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn) {} | 82 | public void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn) {} |
81 | public void AddCommand(string module, bool shared, string command, string help, string longhelp, string descriptivehelp, CommandDelegate fn) {} | 83 | public void AddCommand(string module, bool shared, string command, string help, string longhelp, string descriptivehelp, CommandDelegate fn) {} |
82 | public string[] FindNextOption(string[] cmd, bool term) { return null; } | 84 | public string[] FindNextOption(string[] cmd, bool term) { return null; } |
85 | public bool HasCommand(string cmd) { return false; } | ||
83 | public string[] Resolve(string[] cmd) { return null; } | 86 | public string[] Resolve(string[] cmd) { return null; } |
84 | public XmlElement GetXml(XmlDocument doc) { return null; } | 87 | public XmlElement GetXml(XmlDocument doc) { return null; } |
85 | } | 88 | } |
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 27edd4b..8ad7b0d 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs | |||
@@ -234,7 +234,7 @@ namespace OpenSim.Framework.Console | |||
234 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; | 234 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; |
235 | 235 | ||
236 | m_Server.AddPollServiceHTTPHandler( | 236 | m_Server.AddPollServiceHTTPHandler( |
237 | uri, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, sessionID)); | 237 | uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout |
238 | 238 | ||
239 | XmlDocument xmldoc = new XmlDocument(); | 239 | XmlDocument xmldoc = new XmlDocument(); |
240 | XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, | 240 | XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, |
@@ -425,7 +425,7 @@ namespace OpenSim.Framework.Console | |||
425 | return false; | 425 | return false; |
426 | } | 426 | } |
427 | 427 | ||
428 | private Hashtable GetEvents(UUID RequestID, UUID sessionID, string request) | 428 | private Hashtable GetEvents(UUID RequestID, UUID sessionID) |
429 | { | 429 | { |
430 | ConsoleConnection c = null; | 430 | ConsoleConnection c = null; |
431 | 431 | ||