mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-11-29 10:53:43 +00:00
fix
This commit is contained in:
parent
efa4d07720
commit
4636196448
31
lib/gtk.js
31
lib/gtk.js
|
|
@ -7,6 +7,9 @@ var SHELL = require("lib/shell");
|
||||||
// set binPath
|
// set binPath
|
||||||
var binPath = "bin\\gtk-server.exe";
|
var binPath = "bin\\gtk-server.exe";
|
||||||
|
|
||||||
|
// start GTKServer
|
||||||
|
var GTKServer = SHELL.createExecObject([binPath, "-stdin"]);
|
||||||
|
|
||||||
// Common (Elements)
|
// Common (Elements)
|
||||||
var GTKElements = [];
|
var GTKElements = [];
|
||||||
|
|
||||||
|
|
@ -40,12 +43,10 @@ var GTKElement = function() {
|
||||||
GTKElements.push(this);
|
GTKElements.push(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
// start GTKServer
|
// GTKServer WriteLine
|
||||||
var = function() {
|
var WriteLine = function(line) {
|
||||||
SHELL.run([
|
GTKServer.StdIn.WriteLine(line);
|
||||||
binPath,
|
return GTKServer.StdOut.ReadLine();
|
||||||
"-stdin"
|
|
||||||
]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Window
|
// Window
|
||||||
|
|
@ -54,9 +55,6 @@ var Window = function() {
|
||||||
|
|
||||||
this.type = "Window";
|
this.type = "Window";
|
||||||
this.title = "WelsonJS GTK GUI Application";
|
this.title = "WelsonJS GTK GUI Application";
|
||||||
this.setTitle = function(title) {
|
|
||||||
this.Title = title;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
Window.prototype = new GTKElement();
|
Window.prototype = new GTKElement();
|
||||||
Window.prototype.constructor = Window;
|
Window.prototype.constructor = Window;
|
||||||
|
|
@ -79,9 +77,6 @@ var Button = function() {
|
||||||
|
|
||||||
this.type = "Button";
|
this.type = "Button";
|
||||||
this.text = "New Button";
|
this.text = "New Button";
|
||||||
this.setText = function(text) {
|
|
||||||
this.Text = text;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
Button.prototype = new GTKElement();
|
Button.prototype = new GTKElement();
|
||||||
Button.prototype.constructor = Button;
|
Button.prototype.constructor = Button;
|
||||||
|
|
@ -92,9 +87,6 @@ var Label = function() {
|
||||||
|
|
||||||
this.type = "Label";
|
this.type = "Label";
|
||||||
this.text = "New Label";
|
this.text = "New Label";
|
||||||
this.setText = function(text) {
|
|
||||||
this.text = text;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
Label.prototype = new GTKElement();
|
Label.prototype = new GTKElement();
|
||||||
Label.prototype.constructor = Label;
|
Label.prototype.constructor = Label;
|
||||||
|
|
@ -105,9 +97,6 @@ var RadioBox = function() {
|
||||||
|
|
||||||
this.type = "RadioBox";
|
this.type = "RadioBox";
|
||||||
this.text = "New RadioBox";
|
this.text = "New RadioBox";
|
||||||
this.setText = function(text) {
|
|
||||||
this.Text = text;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
RadioBox.prototype = new GTKElement();
|
RadioBox.prototype = new GTKElement();
|
||||||
RadioBox.prototype.constructor = RadioBox;
|
RadioBox.prototype.constructor = RadioBox;
|
||||||
|
|
@ -118,9 +107,6 @@ var CheckBox = function() {
|
||||||
|
|
||||||
this.type = "CheckBox";
|
this.type = "CheckBox";
|
||||||
this.text = "New CheckBox";
|
this.text = "New CheckBox";
|
||||||
this.setText = function(text) {
|
|
||||||
this.Text = text;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
CheckBox.prototype = new GTKElement();
|
CheckBox.prototype = new GTKElement();
|
||||||
CheckBox.prototype.constructor = CheckBox;
|
CheckBox.prototype.constructor = CheckBox;
|
||||||
|
|
@ -131,9 +117,6 @@ var TextBox = function() {
|
||||||
|
|
||||||
this.type = "TextBox";
|
this.type = "TextBox";
|
||||||
this.text = "New TextBox";
|
this.text = "New TextBox";
|
||||||
this.setText = function(text) {
|
|
||||||
this.Text = text;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
TextBox.prototype = new GTKElement();
|
TextBox.prototype = new GTKElement();
|
||||||
TextBox.prototype.constructor = TextBox;
|
TextBox.prototype.constructor = TextBox;
|
||||||
|
|
|
||||||
15
lib/shell.js
15
lib/shell.js
|
|
@ -8,7 +8,7 @@ exports.VERSIONINFO = "Shell Lib (shell.js) version 0.1";
|
||||||
exports.global = global;
|
exports.global = global;
|
||||||
exports.require = global.require;
|
exports.require = global.require;
|
||||||
|
|
||||||
exports.addslashes = function(s) {
|
var addslashes = function(s) {
|
||||||
return s.toString().replace(/\\/g, '\\\\').
|
return s.toString().replace(/\\/g, '\\\\').
|
||||||
replace(/\u0008/g, '\\b').
|
replace(/\u0008/g, '\\b').
|
||||||
replace(/\t/g, '\\t').
|
replace(/\t/g, '\\t').
|
||||||
|
|
@ -19,7 +19,7 @@ exports.addslashes = function(s) {
|
||||||
replace(/"/g, '\\"');
|
replace(/"/g, '\\"');
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.makeCmdLine = function(cmd) {
|
var makeCommand = function(cmd) {
|
||||||
if (typeof(cmd) === "string") {
|
if (typeof(cmd) === "string") {
|
||||||
return cmd;
|
return cmd;
|
||||||
} else if (typeof(cmd) === "object") {
|
} else if (typeof(cmd) === "object") {
|
||||||
|
|
@ -28,7 +28,7 @@ exports.makeCmdLine = function(cmd) {
|
||||||
if (!regex.test(s)) {
|
if (!regex.test(s)) {
|
||||||
return s;
|
return s;
|
||||||
} else {
|
} else {
|
||||||
return "\"" + exports.addslashes(s) + "\"";
|
return "\"" + addslashes(s) + "\"";
|
||||||
}
|
}
|
||||||
}).join(' ');
|
}).join(' ');
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -41,7 +41,7 @@ exports.exec = function(cmd, stdOutPath) {
|
||||||
if (typeof(stdOutPath) === "undefined") {
|
if (typeof(stdOutPath) === "undefined") {
|
||||||
stdOutPath = "stdout.txt";
|
stdOutPath = "stdout.txt";
|
||||||
}
|
}
|
||||||
var c = "%comspec% /c (" + exports.makeCmdLine(cmd) + ") 1> " + stdOutPath;
|
var c = "%comspec% /c (" + makeCommand(cmd) + ") 1> " + stdOutPath;
|
||||||
c += " 2>&1";
|
c += " 2>&1";
|
||||||
WSH.Run(c, 0, true);
|
WSH.Run(c, 0, true);
|
||||||
console.info("exec() -> " + c);
|
console.info("exec() -> " + c);
|
||||||
|
|
@ -57,11 +57,16 @@ exports.exec = function(cmd, stdOutPath) {
|
||||||
exports.run = function(cmd, fork) {
|
exports.run = function(cmd, fork) {
|
||||||
var WSH = CreateObject("WScript.Shell");
|
var WSH = CreateObject("WScript.Shell");
|
||||||
var fork = (typeof(fork) !== "undefined") ? fork : true;
|
var fork = (typeof(fork) !== "undefined") ? fork : true;
|
||||||
var c = "%comspec% /q /c (" + exports.makeCmdLine(cmd) + ")";
|
var c = "%comspec% /q /c (" + makeCommand(cmd) + ")";
|
||||||
console.info("run() -> " + c);
|
console.info("run() -> " + c);
|
||||||
WSH.Run(c, 0, !fork);
|
WSH.Run(c, 0, !fork);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.createExecObject = function(cmd) {
|
||||||
|
var WSH = CreateObject("WScript.Shell");
|
||||||
|
return WSH.Exec(makeCommand(cmd));
|
||||||
|
};
|
||||||
|
|
||||||
exports.elevatedRun = function(FN, args) {
|
exports.elevatedRun = function(FN, args) {
|
||||||
console.info("elevatedRun() -> " + FN + " " + args.join(' '));
|
console.info("elevatedRun() -> " + FN + " " + args.join(' '));
|
||||||
var oShell = CreateObject("Shell.Application");
|
var oShell = CreateObject("Shell.Application");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user