GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
display.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2009-2018 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include "singleton-cleanup.h"
28 
29 #include "cdisplay.h"
30 #include "defun.h"
31 #include "display.h"
32 #include "error.h"
33 #include "ov.h"
34 #include "ovl.h"
35 
36 namespace octave
37 {
38  display_info *display_info::instance = nullptr;
39 
40  void
41  display_info::init (const std::string& dpy_name, bool query)
42  {
43  if (query)
44  {
45  int avail = 0;
46 
47  const char *display_name
48  = dpy_name.empty () ? nullptr : dpy_name.c_str ();
49 
50  const char *msg
51  = octave_get_display_info (display_name, &m_ht, &m_wd, &m_dp,
52  &m_rx, &m_ry, &avail);
53 
54  m_dpy_avail = avail;
55 
56  if (msg)
57  m_err_msg = msg;
58  }
59  }
60 
61  bool
63  {
64  bool retval = true;
65 
66  if (! instance)
67  {
68  instance = new display_info (query);
69 
70  if (instance)
72  }
73 
74  if (! instance)
75  error ("unable to create display_info object!");
76 
77  return retval;
78  }
79 }
80 
81 DEFUN (have_window_system, , ,
82  doc: /* -*- texinfo -*-
83 @deftypefn {} {} have_window_system ()
84 Return true if a window system is available (X11, Windows, or Apple OS X)
85 and false otherwise.
86 @seealso{isguirunning}
87 @end deftypefn */)
88 {
90 }
static display_info * instance
Definition: display.h:115
static bool display_available(void)
Definition: display.h:95
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
Definition: defun.h:53
void error(const char *fmt,...)
Definition: error.cc:578
const char * octave_get_display_info(const char *dpy_name, int *ht, int *wd, int *dp, double *rx, double *ry, int *dpy_avail)
Definition: cdisplay.c:51
static void add(fptr f)
static bool instance_ok(bool query=true)
Definition: display.cc:62
octave_value retval
Definition: data.cc:6246
std::string m_err_msg
Definition: display.h:130
static void cleanup_instance(void)
Definition: display.h:117
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
void init(const std::string &dpy_name="", bool query=true)
Definition: display.cc:41
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888