File: zenity_text_info.m

package info (click to toggle)
octave-zenity 0.5.7-9
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 240 kB
  • sloc: makefile: 65; sh: 4
file content (54 lines) | stat: -rw-r--r-- 1,923 bytes parent folder | download | duplicates (5)
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
## Copyright (C) 2006 S�ren Hauberg
## 
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
## 
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
## 
## You should have received a copy of the GNU General Public License
## along with this program; If not, see <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
## @deftypefn  {Function File} @var{s} = zenity_text_info(@var{title}, @var{text}, @var{editable})
## Display a large amount of text in a graphical display.
## The title of the display window is set with the variable @var{title},
## and the actual text ti display is set with the variable @var{text}.
## If the optional argument @var{editable} is given the displayed text
## is editable. In this case the altered text is returned from the function.
##
## @seealso{zenity_calendar, zenity_list, zenity_progress, zenity_entry, zenity_message,
## zenity_file_selection, zenity_notification}
## @end deftypefn

function s = zenity_text_info(title, text, editable)
  if (nargin < 2 || !ischar(title) || !ischar(text))
    print_usage();
  endif

  if (nargin < 3)
    editable = "--editable";
  else
    editable = "";
  endif
  
  filename = tmpnam();
  fid = fopen(filename, "w");
  fprintf(fid, "%s", text);
  fclose(fid);
  
  cmd = sprintf('zenity --text-info --title="%s" --filename="%s" %s', title, filename, editable);
  [status, output] = system(cmd);
  unlink(filename);
  if (status == 0)
    s = output;
  elseif (status == 1)
    s = "";
  else
    error("zenity_text_info: %s", output);
  endif
endfunction