Skip to content

Commit

Permalink
Patch #1433 - console running status
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Aug 25, 2018
1 parent 92efebf commit c751e53
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class Messages extends NLS {
public static String ALL_TEST_IN_FOLDER;
public static String LINE;
public static String REPL_WELCOME;
public static String REPL_END;
public static String WVM_ERROR;

// ****************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ALL_TEST_IN_FOLDER=All tests in folder {0}
#
# REPL
REPL_WELCOME=Wollok interactive console (type \"quit\" to quit):
REPL_END=Quitting console. Bye!
LINE=line
WVM_ERROR=Wollok VM Error in line

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ALL_TEST_IN_FOLDER=Todos los tests de la carpeta {0}
#
# REPL
REPL_WELCOME=Consola Interactiva de Wollok (escriba \"quit\" para salir):
REPL_END=Consola terminada. Hasta luego!
LINE=l\u00EDnea
WVM_ERROR=Error de la VM de Wollok en la l\u00EDnea

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ class WollokRepl {
printPrompt
}
}

printEndStructure
}

def synchronized printPrompt() {
print(prompt.messageStyle)
}

def synchronized void printEndStructure() {
println(REPL_END.importantMessageStyle)
}

def String readInput() {
val input = reader.readLine.trim
if (input == "") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import org.eclipse.debug.core.model.IProcess
import org.eclipse.debug.core.model.IStreamsProxy
import org.eclipse.debug.internal.ui.DebugUIPlugin
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants
import org.eclipse.swt.graphics.Color
import org.eclipse.swt.widgets.Display
import org.eclipse.ui.console.IConsoleView
import org.eclipse.ui.console.TextConsole
import org.eclipse.ui.console.TextConsolePage
Expand Down Expand Up @@ -49,10 +51,14 @@ class WollokReplConsole extends TextConsole {
@Accessors(PUBLIC_GETTER)
Long timeStart

public static Color ENABLED = new Color(Display.current, 255, 255, 255)
public static Color DISABLED = new Color(Display.current, 220, 220, 220)

def static getConsoleName() { "Wollok REPL Console" }

new() {
super(consoleName, null, Activator.getDefault.getImageDescriptor("icons/w.png"), true)
background = ENABLED
this.partitioner = new WollokReplConsolePartitioner(this)
this.document.documentPartitioner = this.partitioner
}
Expand Down Expand Up @@ -91,10 +97,17 @@ class WollokReplConsole extends TextConsole {
}

def shutdown() {
background = DISABLED
process.terminate
}

def isRunning() { !process.terminated }
def isRunning() {
val terminated = process.terminated
if (terminated) {
background = DISABLED
}
!terminated
}

def getOutputText() { document.get(0, outputTextEnd) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package org.uqbar.project.wollok.ui.console

import org.eclipse.swt.SWT
import org.eclipse.swt.custom.StyledText
import org.eclipse.swt.events.FocusEvent
import org.eclipse.swt.events.FocusListener
import org.eclipse.swt.events.KeyEvent
import org.eclipse.swt.events.KeyListener
import org.eclipse.swt.events.MouseAdapter
Expand Down Expand Up @@ -55,6 +57,10 @@ class WollokReplConsolePage extends TextConsolePage implements KeyListener {
if(isCursorInTheLastLine && isCursorInReadOnlyZone) setCursorToEnd
}
})
addFocusListener(new FocusListener() {
override focusGained(FocusEvent e) { console.isRunning }
override focusLost(FocusEvent e) { console.isRunning }
})
setFocus
]
}
Expand Down Expand Up @@ -147,7 +153,9 @@ class WollokReplConsolePage extends TextConsolePage implements KeyListener {

def isControlPressed(KeyEvent it) { stateMask.bitwiseAnd(SWT.CTRL) == SWT.CTRL }

override keyReleased(KeyEvent e) {}
override keyReleased(KeyEvent e) {
console.isRunning
}

override createViewer(Composite parent) {
return new WollokReplConsoleViewer(parent, console, view)
Expand Down

0 comments on commit c751e53

Please sign in to comment.