Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add blinking cursor

Refactor guard file
Clear code button clears output
  • Loading branch information...
commit 653f8e965ebae1de6176d2daf379843c297442d4 1 parent 9c6573f
@ldenman ldenman authored
View
12 Guardfile
@@ -12,26 +12,18 @@ guard 'shell' do
def restart_kidsruby
stop_kidsruby
- start_kidsruby
+ store_pid(kidsruby_process)
end
def stop_kidsruby
- kill_kidsruby
+ Process.kill("HUP", pid.to_i) if pid
cleanup_pid_file
end
- def kill_kidsruby
- Process.kill("HUP", pid.to_i)
- end
-
def cleanup_pid_file
File.delete(pid_file) if File.exists?(pid_file)
end
- def start_kidsruby
- store_pid(kidsruby_process)
- end
-
def store_pid(process)
File.open(pid_file, 'w+') { |f| f.puts process.pid }
end
View
9 app/models/frame_writer.rb
@@ -6,12 +6,13 @@ def initialize(frame)
def keyPressEvent(event)
case event.key
when Qt::Key_Return
- @frame.evaluateJavaScript("cutStdInToStdOut()")
- @frame.evaluateJavaScript("updateStdOut('<br/>')")
+ @frame.evaluateJavaScript("cutStdInToStdOut();")
+ @frame.evaluateJavaScript("updateStdOut('<br/>');")
+ @frame.evaluateJavaScript("removeCursor();")
when Qt::Key_Backspace
- @frame.evaluateJavaScript("deleteLastStdIn()")
+ @frame.evaluateJavaScript("deleteLastStdIn();")
else
- @frame.evaluateJavaScript("updateStdIn('#{event.text}')")
+ @frame.evaluateJavaScript("updateStdIn('#{event.text}');")
end
end
end
View
1  app/widgets/main.rb
@@ -55,6 +55,7 @@ def notify_stdin_event_listeners(event)
def acceptStdin
@acceptStdin = true
+ @frame.evaluateJavaScript('acceptStdIn();')
end
def rejectStdin
View
1  public/css/master.css
@@ -94,6 +94,7 @@ iframe h1 {
}
#stdout {
+
}
#stderr {
View
48 public/js/app.js
@@ -3,27 +3,54 @@ function selectTab(id) {
}
function deleteLastStdIn() {
- var str = $("#stdin").html();
+ removeCursor();
+ var str = $("#stdin").text();
var newStr = str.substring(0, str.length-1);
- $("#stdin").html(newStr);
+ $("#stdin").html('');
+ updateStdIn(newStr);
}
function updateStdIn(newHtml) {
- if ( !$("#stdin").length ) {
- updateStdOut("<div id='stdin'></div>");
- }
$("#stdin").append(newHtml);
+ appendCursor($('#stdin'));
}
-function cutStdInToStdOut() {
- copyStdIntoStdOut();
- removeStdIn();
+function removeCursor() {
+ $('.cursor').remove();
+}
+
+function appendCursor() {
+ removeCursor();
+ $('#stdin').append("<span class='cursor'>|</span>");
+ setCursorBlinkInterval();
+}
+
+function setCursorBlinkInterval() {
+ if (blinkInterval!='undefined') {
+ clearInterval(blinkInterval);
+ }
+
+ var blinkInterval = setInterval(function() {
+ $('.cursor').fadeOut('slow');
+ $('.cursor').fadeIn('slow');
+ }, 1000);
}
function removeStdIn() {
$("#stdin").remove();
}
+function acceptStdIn() {
+ if ( !$("#stdin").length ) {
+ updateStdOut("<div id='stdin'></div>");
+ }
+ appendCursor();
+}
+
+function cutStdInToStdOut() {
+ copyStdIntoStdOut();
+ removeStdIn();
+}
function copyStdIntoStdOut() {
$("#stdout").append($("#stdin").html());
}
@@ -69,6 +96,7 @@ function getEditor() {
function clearCode() {
getEditor().getSession().setValue("");
+ clearOutputs();
}
function addCode(code) {
@@ -129,8 +157,8 @@ function initEditor() {
"idle_fingers", "kr_theme", "merbivore", "merbivore_soft",
"mono_industrial", "solarized_dark", "solarized_light", "textmate",
"twilight", "vibrant_ink"
- ]
- window.editor.setTheme("ace/theme/clouds");
+ ]
+ window.editor.setTheme("ace/theme/clouds");
// ruby mode
var RubyMode = require("ace/mode/ruby").Mode;
Please sign in to comment.
Something went wrong with that request. Please try again.