diff --git a/examples/timertool.s b/examples/timertool.s index 013a3eaa..303d0dac 100644 --- a/examples/timertool.s +++ b/examples/timertool.s @@ -26,7 +26,13 @@ loop: ecall li a7, 4 la a0, newLine - ecall + ecall + + # Sleep for 10 ms + li a0, 10 + li a7, 32 + ecall + j loop diff --git a/src/rars/util/SystemIO.java b/src/rars/util/SystemIO.java index ae10205e..0f12e239 100644 --- a/src/rars/util/SystemIO.java +++ b/src/rars/util/SystemIO.java @@ -144,7 +144,7 @@ public static void printString(String string) { if (Globals.getGui() == null) { System.out.print(string); } else { - Globals.getGui().getMessagesPane().postRunMessage(string); + print2Gui(string); } } @@ -211,7 +211,7 @@ public static int writeToFile(int fd, byte[] myBuffer, int lengthRequested) { /// Write to STDOUT or STDERR file descriptor while using IDE - write to Messages pane. if ((fd == STDOUT || fd == STDERR) && Globals.getGui() != null) { String data = new String(myBuffer, StandardCharsets.UTF_8); //decode the bytes using UTF-8 charset - Globals.getGui().getMessagesPane().postRunMessage(data); + print2Gui(data); return myBuffer.length; // data.length would not count multi-byte characters } /////////////////////////////////////////////////////////////////////////////////// @@ -441,6 +441,19 @@ private static BufferedReader getInputReader() { return inputReader; } + private static String buffer = ""; + private static long lasttime = 0; + private static void print2Gui(String output){ + long time = System.currentTimeMillis(); + if (time > lasttime) { + Globals.getGui().getMessagesPane().postRunMessage(buffer+output); + buffer = ""; + lasttime = time + 100; + } else { + buffer += output; + } + } + public static Data swapData(Data in){ Data temp = new Data(false); temp.fileNames = FileIOData.fileNames;