From 80832caedaef9a44c3d88ba8744a19e1d0962d57 Mon Sep 17 00:00:00 2001 From: "Robert D. Blanchet Jr" Date: Tue, 22 Oct 2013 19:17:35 -0700 Subject: [PATCH 1/4] Add unlimited console buffer. --- CUDLR/Scripts/Console.cs | 22 ++++++++++------------ StreamingAssets/CUDLR/console.css | 9 ++++++--- StreamingAssets/CUDLR/index.html | 11 +++++++++-- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/CUDLR/Scripts/Console.cs b/CUDLR/Scripts/Console.cs index fb98cff..608ccd7 100644 --- a/CUDLR/Scripts/Console.cs +++ b/CUDLR/Scripts/Console.cs @@ -15,7 +15,7 @@ struct QueuedCommand { public class Console { - // Max number of lines in the console output + // Max number of lines in the buffer const int MAX_LINES = 100; // Maximum number of commands stored in the history @@ -71,12 +71,6 @@ public static void Run(string str) { } } - /* Clear all output from console */ - [Command("clear", "clears console output", false)] - public static void Clear() { - Instance.m_output.Clear(); - } - /* Print a list of all console commands */ [Command("help", "prints commands", false)] public static void Help() { @@ -96,7 +90,7 @@ public static void LogCommand(string cmd) { /* Logs string to output */ public static void Log(string str) { Instance.m_output.Add(str); - if (Instance.m_output.Count > MAX_LINES) + if (Instance.m_output.Count > MAX_LINES) Instance.m_output.RemoveAt(0); } @@ -110,7 +104,11 @@ public static void LogCallback (string logString, string stackTrace, LogType typ /* Returns the output */ public static string Output() { - return string.Join("\n", Instance.m_output.ToArray()); + string output = string.Join("\n", Instance.m_output.ToArray()); + if (!string.IsNullOrEmpty(output)) + output += "\n"; + Instance.m_output.Clear(); + return output; } /* Register a new console command */ @@ -157,7 +155,7 @@ private void RegisterAttributes() { Debug.LogError(string.Format("Method {0}.{1} needs a valid command name.", type, method.Name)); continue; } - + cmd.m_callback = cb; m_commands.Add(cmd); m_help += string.Format("\n{0} : {1}", cmd.m_command, cmd.m_help); @@ -174,7 +172,7 @@ public static string PreviousCommand(int index) { /* Update history with a new command */ private void RecordCommand(string command) { m_history.Insert(0, command); - if (m_history.Count > MAX_HISTORY) + if (m_history.Count > MAX_HISTORY) m_history.RemoveAt(m_history.Count - 1); } @@ -334,4 +332,4 @@ private void RunCommand(string[] args) { } } } -} \ No newline at end of file +} diff --git a/StreamingAssets/CUDLR/console.css b/StreamingAssets/CUDLR/console.css index b3f7e92..02d8dc5 100644 --- a/StreamingAssets/CUDLR/console.css +++ b/StreamingAssets/CUDLR/console.css @@ -1,16 +1,19 @@ -textarea {resize:none;} +textarea { + resize:none; +} body.console { background-color:black; } + textarea.console { width:100%; background-color:#383838; color:#F0F0F0; font-size:14px; - font-family:;"Courier New", Courier, monospace; - + font-family:"Courier New", Courier, monospace; } + #output { height:500px; } diff --git a/StreamingAssets/CUDLR/index.html b/StreamingAssets/CUDLR/index.html index 235b764..7768e08 100644 --- a/StreamingAssets/CUDLR/index.html +++ b/StreamingAssets/CUDLR/index.html @@ -32,12 +32,18 @@ // Check if we are scrolled to the bottom to force scrolling on update var output = $('#output'); shouldScroll = (output[0].scrollHeight - output.scrollTop()) == output.innerHeight(); - output.val(String(data)); + var current = output.val(); + output.val(current + String(data)); if (callback) callback(); if (shouldScroll) scrollBottom(); }); } + function resetOutput() { + $('#output').val(""); + scrollBottom(); + } + function resetInput() { commandIndex = -1; $("#input").val(""); @@ -52,7 +58,7 @@ } function updateCommand(index) { - // Check if we are at the defualt index and clear the input + // Check if we are at the default index and clear the input if (index < 0) { resetInput(); return; @@ -82,6 +88,7 @@ +