Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Added run shortcut (ctrl + r)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart Zaalberg committed Oct 16, 2017
1 parent afc31b3 commit 65f1794
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 20 deletions.
1 change: 1 addition & 0 deletions data/com.github.bartzaalberg.php-tester.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<ul>
<li>Code without having to start a whole project!</li>
<li>Copy your snippet with a simple click on a button!</li>
<li>Run your code with a simple shortcut! (ctrl + r)</li>
</ul>
</description>
<screenshots>
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
com.github.bartzaalberg.php-tester (1.1.4) UNSTABLE; urgency=low

* Added run shortcut (ctrl + r)

-- Bart Zaalberg <bartzaalberg@gmail.com> Mon, 16 Oct 2017 10:36:00 +0200

com.github.bartzaalberg.php-tester (1.1.3) UNSTABLE; urgency=low

* Added a button to copy the text
Expand Down
21 changes: 1 addition & 20 deletions src/Components/HeaderBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,7 @@ public class HeaderBar : Gtk.HeaderBar {
var start_button = new Gtk.Button.with_label ("Run");
start_button.margin_end = 12;
start_button.clicked.connect (() => {
fileManager.writeToFile();

string result;
string error;
int status;

try {
Process.spawn_command_line_sync ("php phptest.php",
out result,
out error,
out status);

sourceViewManager.setResult(result);
if(error != null && error != ""){
new Alert("PHP error",error);
}

} catch (SpawnError e) {
new Alert("An error occured", e.message);
}
fileManager.runCode();
});

var copy_button = new Gtk.Button.with_label ("Copy");
Expand Down
22 changes: 22 additions & 0 deletions src/FileManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,27 @@ public class FileManager : Object {
}
return file;
}

public void runCode(){
writeToFile();
string result;
string error;
int status;

try {
Process.spawn_command_line_sync ("php phptest.php",
out result,
out error,
out status);

sourceViewManager.setResult(result);
if(error != null && error != ""){
new Alert("PHP error",error);
}

} catch (SpawnError e) {
new Alert("An error occured", e.message);
}
}
}
}
13 changes: 13 additions & 0 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace RepositoriesManager {
public class MainWindow : Gtk.Window{

private SourceViewManager sourceViewManager = SourceViewManager.get_instance();
private FileManager fileManager = FileManager.get_instance();

Gtk.TextView view;
Gtk.Label resultLabel;
Expand All @@ -29,6 +30,18 @@ public class MainWindow : Gtk.Window{
pane.pack2 (result_box, false, false);

add (pane);

key_press_event.connect ((e) => {
switch (e.keyval) {
case Gdk.Key.r:
if ((e.state & Gdk.ModifierType.CONTROL_MASK) != 0) {
fileManager.runCode();
}
break;
}

return false;
});
}
}
}

0 comments on commit 65f1794

Please sign in to comment.