diff --git a/3rdparty/remotery/readme.md b/3rdparty/remotery/readme.md index 99cbdf9ad..143f58247 100644 --- a/3rdparty/remotery/readme.md +++ b/3rdparty/remotery/readme.md @@ -54,14 +54,14 @@ See the sample directory for further examples. A quick example: // Explicit begin/end for C { - rmt_BeginCPUSample(LogText); + rmt_BeginCPUSample(LogText, 0); rmt_LogText("Time me, please!"); rmt_EndCPUSample(); } // Scoped begin/end for C++ { - rmt_ScopedCPUSample(LogText); + rmt_ScopedCPUSample(LogText, 0); rmt_LogText("Time me, too!"); } diff --git a/3rdparty/remotery/sample/sample.c b/3rdparty/remotery/sample/sample.c index 3339fa35f..f579e1c1f 100644 --- a/3rdparty/remotery/sample/sample.c +++ b/3rdparty/remotery/sample/sample.c @@ -1,12 +1,14 @@ #include #include +#include +#include #include "Remotery.h" double delay() { int i, end; double j = 0; - rmt_BeginCPUSample(delay); + rmt_BeginCPUSample(delay, 0); for( i = 0, end = rand()/100; i < end; ++i ) { j += sin(i); } @@ -14,20 +16,30 @@ double delay() { return j; } +int sig = 0; + +/// Allow to close cleanly with ctrl + c +void sigintHandler(int sig_num) { + sig = sig_num; + printf("Interrupted\n"); +} + +int main( ) { + signal(SIGINT, sigintHandler); -int main( int argc, const char **argv ) { Remotery *rmt; if( RMT_ERROR_NONE != rmt_CreateGlobalInstance(&rmt) ) { return -1; } - for(;;) { + while (sig == 0) { rmt_LogText("start profiling"); delay(); rmt_LogText("end profiling"); } rmt_DestroyGlobalInstance(rmt); + printf("Cleaned up and quit\n"); return 0; } diff --git a/3rdparty/remotery/vis/Code/Console.js b/3rdparty/remotery/vis/Code/Console.js index 06f5e55a8..a18f3dce4 100644 --- a/3rdparty/remotery/vis/Code/Console.js +++ b/3rdparty/remotery/vis/Code/Console.js @@ -19,7 +19,16 @@ Console = (function() // This accumulates log text as fast as is required this.PageTextBuffer = ""; + this.LastPageTextBufferLen = 0; this.AppTextBuffer = ""; + this.LastAppTextBufferLen = 0; + + // Setup command history control + this.CommandHistory = LocalStore.Get("App", "Global", "CommandHistory", [ ]); + this.CommandIndex = 0; + this.MaxNbCommands = 200; + DOM.Event.AddHandler(this.UserInput.EditNode, "keydown", Bind(OnKeyPress, this)); + DOM.Event.AddHandler(this.UserInput.EditNode, "focus", Bind(OnFocus, this)); // At a much lower frequency this will update the console window window.setInterval(Bind(UpdateHTML, this), 500); @@ -91,13 +100,21 @@ Console = (function() { // Reset the current text buffer as html - var page_node = self.PageContainer.Node; - page_node.innerHTML = self.PageTextBuffer; - page_node.scrollTop = page_node.scrollHeight; + if (self.LastPageTextBufferLen != self.PageTextBuffer.length) + { + var page_node = self.PageContainer.Node; + page_node.innerHTML = self.PageTextBuffer; + page_node.scrollTop = page_node.scrollHeight; + self.LastPageTextBufferLen = self.PageTextBuffer.length; + } - var app_node = self.AppContainer.Node; - app_node.innerHTML = self.AppTextBuffer; - app_node.scrollTop = app_node.scrollHeight; + if (self.LastAppTextBufferLen != self.AppTextBuffer.length) + { + var app_node = self.AppContainer.Node; + app_node.innerHTML = self.AppTextBuffer; + app_node.scrollTop = app_node.scrollHeight; + self.LastAppTextBufferLen = self.AppTextBuffer.length; + } } @@ -110,6 +127,64 @@ Console = (function() // Emit to console and clear self.Log("> " + msg); self.UserInput.SetValue(""); + + // Keep track of recently issued commands, with an upper bound + self.CommandHistory.push(msg); + var extra_commands = self.CommandHistory.length - self.MaxNbCommands; + if (extra_commands > 0) + self.CommandHistory.splice(0, extra_commands); + + // Set command history index to the most recent command + self.CommandIndex = self.CommandHistory.length; + + // Backup to local store + LocalStore.Set("App", "Global", "CommandHistory", self.CommandHistory); + + // Keep focus with the edit box + return true; + } + + + function OnKeyPress(self, evt) + { + evt = DOM.Event.Get(evt); + + if (evt.keyCode == Keyboard.Codes.UP) + { + if (self.CommandHistory.length > 0) + { + // Cycle backwards through the command history + self.CommandIndex--; + if (self.CommandIndex < 0) + self.CommandIndex = self.CommandHistory.length - 1; + var command = self.CommandHistory[self.CommandIndex]; + self.UserInput.SetValue(command); + } + + // Stops default behaviour of moving cursor to the beginning + DOM.Event.StopDefaultAction(evt); + } + + else if (evt.keyCode == Keyboard.Codes.DOWN) + { + if (self.CommandHistory.length > 0) + { + // Cycle fowards through the command history + self.CommandIndex = (self.CommandIndex + 1) % self.CommandHistory.length; + var command = self.CommandHistory[self.CommandIndex]; + self.UserInput.SetValue(command); + } + + // Stops default behaviour of moving cursor to the end + DOM.Event.StopDefaultAction(evt); + } + } + + + function OnFocus(self) + { + // Reset command index on focus + self.CommandIndex = self.CommandHistory.length; } diff --git a/3rdparty/remotery/vis/Code/Remotery.js b/3rdparty/remotery/vis/Code/Remotery.js index 31fe09dc2..5030f8802 100644 --- a/3rdparty/remotery/vis/Code/Remotery.js +++ b/3rdparty/remotery/vis/Code/Remotery.js @@ -92,6 +92,9 @@ Remotery = (function() // Update and disconnect, relying on auto-connect to reconnect self.ConnectionAddress = node.value; self.Server.Disconnect(); + + // Give input focus away + return false; } diff --git a/3rdparty/remotery/vis/Styles/Remotery.css b/3rdparty/remotery/vis/Styles/Remotery.css index 836dd68d7..995095f41 100644 --- a/3rdparty/remotery/vis/Styles/Remotery.css +++ b/3rdparty/remotery/vis/Styles/Remotery.css @@ -67,6 +67,7 @@ body color: #BBB; font: 9px Verdana; margin: 2px; + white-space: pre; } diff --git a/3rdparty/remotery/vis/extern/BrowserLib/WindowManager/Code/EditBox.js b/3rdparty/remotery/vis/extern/BrowserLib/WindowManager/Code/EditBox.js index b78c9725d..fd0a03945 100644 --- a/3rdparty/remotery/vis/extern/BrowserLib/WindowManager/Code/EditBox.js +++ b/3rdparty/remotery/vis/extern/BrowserLib/WindowManager/Code/EditBox.js @@ -27,11 +27,12 @@ WM.EditBox = (function() this.SetPosition(x, y); this.SetSize(w, h); + this.PreviousValue = ""; + // Hook up the event handlers DOM.Event.AddHandler(this.EditNode, "focus", Bind(OnFocus, this)); DOM.Event.AddHandler(this.EditNode, "keypress", Bind(OnKeyPress, this)); DOM.Event.AddHandler(this.EditNode, "keydown", Bind(OnKeyDown, this)); - DOM.Event.AddHandler(this.EditNode, "change", Bind(OnChange, this)); } @@ -88,9 +89,12 @@ WM.EditBox = (function() function OnKeyPress(self, evt) { // Allow enter to confirm the text only when there's data - if (evt.keyCode == 13 && self.EditNode.value != "") + if (evt.keyCode == 13 && self.EditNode.value != "" && self.ChangeHandler) { - self.EditNode.blur(); + var focus = self.ChangeHandler(self.EditNode); + if (!focus) + self.EditNode.blur(); + self.PreviousValue = ""; } } @@ -100,18 +104,16 @@ WM.EditBox = (function() // Allow escape to cancel any text changes if (evt.keyCode == 27) { - self.EditNode.value = self.PreviousValue; + // On initial edit of the input, escape should NOT replace with the empty string + if (self.PreviousValue != "") + { + self.EditNode.value = self.PreviousValue; + } + self.EditNode.blur(); } } - function OnChange(self, evt) - { - if (self.ChangeHandler) - self.ChangeHandler(self.EditNode); - } - - return EditBox; })(); diff --git a/3rdparty/remotery/vis/index.html b/3rdparty/remotery/vis/index.html index 7d1620d5a..b76129055 100644 --- a/3rdparty/remotery/vis/index.html +++ b/3rdparty/remotery/vis/index.html @@ -17,6 +17,7 @@ +