add runqs command
This commit is contained in:
parent
3a8f84a3b2
commit
2d9fe80395
2 changed files with 25 additions and 1 deletions
|
@ -12,6 +12,7 @@ pub const CommandType = enum {
|
||||||
Noop,
|
Noop,
|
||||||
Load,
|
Load,
|
||||||
Quicksave,
|
Quicksave,
|
||||||
|
RunQS,
|
||||||
|
|
||||||
Amp,
|
Amp,
|
||||||
RFlanger,
|
RFlanger,
|
||||||
|
@ -125,6 +126,7 @@ pub const Lang = struct {
|
||||||
_ = try self.keywords.put("noop", .Noop);
|
_ = try self.keywords.put("noop", .Noop);
|
||||||
_ = try self.keywords.put("load", .Load);
|
_ = try self.keywords.put("load", .Load);
|
||||||
_ = try self.keywords.put("quicksave", .Quicksave);
|
_ = try self.keywords.put("quicksave", .Quicksave);
|
||||||
|
_ = try self.keywords.put("runqs", .RunQS);
|
||||||
|
|
||||||
_ = try self.keywords.put("amp", .Amp);
|
_ = try self.keywords.put("amp", .Amp);
|
||||||
_ = try self.keywords.put("rflanger", .RFlanger);
|
_ = try self.keywords.put("rflanger", .RFlanger);
|
||||||
|
|
|
@ -91,7 +91,7 @@ pub const Runner = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn quicksaveCmd(self: *Runner) !void {
|
fn makeGlitchedPath(self: *Runner) ![]const u8 {
|
||||||
// we want to transform basename, if it is "x.bmp" to "x_gN.bmp", where
|
// we want to transform basename, if it is "x.bmp" to "x_gN.bmp", where
|
||||||
// N is the maximum non-used integer.
|
// N is the maximum non-used integer.
|
||||||
var image = try self.getImage();
|
var image = try self.getImage();
|
||||||
|
@ -149,9 +149,30 @@ pub const Runner = struct {
|
||||||
extension,
|
extension,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return out_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn quicksaveCmd(self: *Runner) !void {
|
||||||
|
var image = try self.getImage();
|
||||||
|
const out_path = try self.makeGlitchedPath();
|
||||||
try image.saveTo(out_path);
|
try image.saveTo(out_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn runQSCmd(self: *Runner, program: []const u8) !void {
|
||||||
|
var image = try self.getImage();
|
||||||
|
const out_path = try self.makeGlitchedPath();
|
||||||
|
try image.saveTo(out_path);
|
||||||
|
|
||||||
|
var proc = try std.ChildProcess.init(
|
||||||
|
[_][]const u8{ program, out_path },
|
||||||
|
self.allocator,
|
||||||
|
);
|
||||||
|
defer proc.deinit();
|
||||||
|
|
||||||
|
std.debug.warn("running '{} {}'", program, out_path);
|
||||||
|
_ = try proc.spawnAndWait();
|
||||||
|
}
|
||||||
|
|
||||||
/// Run the http://lv2plug.in/plugins/eg-amp plugin over the file.
|
/// Run the http://lv2plug.in/plugins/eg-amp plugin over the file.
|
||||||
fn ampCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
fn ampCmd(self: *Runner, pos: Position, params: ParamList) !void {
|
||||||
var image = try self.getImage();
|
var image = try self.getImage();
|
||||||
|
@ -221,6 +242,7 @@ pub const Runner = struct {
|
||||||
break :blk;
|
break :blk;
|
||||||
},
|
},
|
||||||
.Quicksave => try self.quicksaveCmd(),
|
.Quicksave => try self.quicksaveCmd(),
|
||||||
|
.RunQS => try self.runQSCmd(cmd.args.at(0)),
|
||||||
|
|
||||||
.Amp => blk: {
|
.Amp => blk: {
|
||||||
const pos = try cmd.consumePosition();
|
const pos = try cmd.consumePosition();
|
||||||
|
|
Loading…
Reference in a new issue