blob: 07da1236d18033093009af616717197bb26ddc19 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
// This function is designed to call the godd "editor" according the values in
// the preferences file.
// This function can take any type of arguments.
function editor(varargin)
if ~isfile(SCIHOME + "/XConfiguration.xml") then
cmd = makeCommand("scinotes", varargin);
execstr(cmd);
return;
end
doc = xmlRead(SCIHOME + "/XConfiguration.xml");
prefsNode = xmlXPath(doc, "//scinotes/body/scinotes-preferences");
prefsNode = prefsNode(1);
if prefsNode.attributes.scinotes == "true" then
xmlDelete(doc);
cmd = makeCommand("scinotes", varargin);
execstr(cmd);
elseif prefsNode.attributes("external-cmd") == "true" then
cmd = prefsNode.attributes.cmd;
xmlDelete(doc);
if ~isempty(varargin) then
cmd = cmd + " """ + string(varargin(1)) + """";
end
unix_w(cmd);
else
cmd = makeCommand(prefsNode.attributes.macro, varargin);
xmlDelete(doc);
execstr(cmd);
end
endfunction
// Private function
// Params:
// - name: the command name
// - args: a list of arguments
// Return:
// - cmd: the complete command to call with execstr
//
function cmd = makeCommand(name, args)
cmd = name + "(";
N = size(args);
if N ~= 0 then
for i=1:(N-1)
arg = string(args(i));
if type(args(i)) == 10 then
arg = """" + arg + """";
end
cmd = cmd + arg + ",";
end
arg = string(args(N));
if type(args(N)) == 10 then
arg = """" + arg + """";
end
cmd = cmd + arg
end
cmd = cmd + ")";
endfunction
|