Call the drawing API for the main menu widget with the current known
        terminal size and the terminal.
186281
def _draw(self):
        
        self._window.draw(self._width, self._height, self.terminal)
26205
def update(self):
        
        assert threading.current_thread() == threading.main_thread()
        for axis, line, interface in self.interfaces:
            line.set_xdata(interface.xdata)
            line.set_ydata(interface.ydata)
            axis.set_xlim(0, interface.width or 1, emit=False)
            axis.set_ylim(0, interface.height or 1, emit=False)
        self.figure.canvas.draw()
1318078
def set_widget(self, canvas_w):
        
        self.logger.debug("set widget canvas_w=%s" % canvas_w)
        self.pgcanvas = canvas_w
1282593
def BuildPanel(self):
        
        figsize = (1.0*self.size[0]/self.dpi, 1.0*self.size[1]/self.dpi)
        self.fig   = Figure(figsize, dpi=self.dpi)
        self.axes  = self.fig.add_axes([0.0, 0.0, 1.0, 1.0])

        self.canvas = FigureCanvasWxAgg(self, -1, self.fig)
        self.fig.set_facecolor('#FFFFFD')

        self.conf.axes  = self.axes
        self.conf.fig   = self.fig
        self.conf.canvas= self.canvas

        # self.canvas.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
        # This way of adding to sizer allows resizing
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(self.canvas, 1, wx.ALL|wx.GROW)
        self.SetSizer(sizer)
        self.Fit()
        self.addCanvasEvents()
1226848
def get_terminal_width():
    
    # http://www.brandonrubin.me/2014/03/18/python-snippet-get-terminal-width/
    command = ['tput', 'cols']
    try:
        width = int(subprocess.check_output(command))
    except OSError as e:
        print(
            "Invalid Command '{0}': exit status ({1})".format(
                command[0], e.errno))
    except subprocess.CalledProcessError as e:
        print(
            "'{0}' returned non-zero exit status: ({1})".format(
                command, e.returncode))
    else:
        return width
1374002
def main(opts):
    """"""
    term = Terminal()
    style = Style()

    # if the terminal supports colors, use a Style instance with some
    # standout colors (magenta, cyan).
    if term.number_of_colors:
        style = Style(attr_major=term.magenta,
                      attr_minor=term.bright_cyan,
                      alignment=opts['--alignment'])
    style.name_len = term.width - 15

    screen = Screen(term, style, wide=opts['--wide'])
    pager = Pager(term, screen, opts['character_factory'])

    with term.location(), term.cbreak(), \
            term.fullscreen(), term.hidden_cursor():
        pager.run(writer=echo, reader=term.inkey)
    return 0
746212
def text_ui(self):
        
        self.logger.info("Starting command line interface")
        self.help()
        try:
            self.ipython_ui()
        except ImportError:
            self.fallback_ui()
        self.system.cleanup()
753831
private void updateMenuIcon() {
        List<Image> iconList = null;
        if (rootParent instanceof JFrame) {
            iconList = ((JFrame) rootParent).getIconImages();
        } else if (rootParent instanceof JDialog) {
            iconList = ((JDialog) rootParent).getIconImages();
        }
        
        Image frameIcon = iconList != null && iconList.size() > 0 ? iconList.get(0) : null;

        SeaGlassContext context   = getContext(this);

        if (frameIcon != null) {
            Dimension maxSize   = (Dimension) context.getStyle().get(context, "InternalFrameTitlePane.maxFrameIconSize");
            int       maxWidth  = 16;
            int       maxHeight = 16;

            if (maxSize != null) {
                maxWidth  = maxSize.width;
                maxHeight = maxSize.height;
            }
            menuButton.setIcon(new ImageIcon(frameIcon.getScaledInstance(maxWidth, maxHeight, Image.SCALE_SMOOTH)));
        }

        context.dispose();
    }
238507
def draw(self):
        """"""
        if sys.stdout.isatty():  # pragma: no cover
            from asciimatics.screen import Screen

            Screen.wrapper(self._do_draw)
        else:
            for line in self.canvas:
                print("".join(line))
649568
def main():
    """"""
    WIDTH, HEIGHT = 120, 60
    TITLE = None

    with tcod.console_init_root(WIDTH, HEIGHT, TITLE, order="F",
                                renderer=tcod.RENDERER_SDL) as console:
        tcod.sys_set_fps(24)
        while True:
            tcod.console_flush()
            for event in tcod.event.wait():
                print(event)
                if event.type == "QUIT":
                    raise SystemExit()
                elif event.type == "MOUSEMOTION":
                    console.ch[:, -1] = 0
                    console.print_(0, HEIGHT - 1, str(event))
                else:
                    console.blit(console, 0, 0, 0, 1, WIDTH, HEIGHT - 2)
                    console.ch[:, -3] = 0
                    console.print_(0, HEIGHT - 3, str(event))
915017
protected void layout ()
    {
        Graphics2D gfx = (Graphics2D)_host.getComponent().getGraphics();
        Font font = gfx.getFont();
        _bounds = new Rectangle();

        // figure out which items are included
        int icount = _items.size();
        ArrayList<RadialMenuItem> items = new ArrayList<RadialMenuItem>();
        for (int i = 0; i < icount; i++) {
            RadialMenuItem item = _items.get(i);
            if (item.isIncluded(this)) {
                items.add(item);
            }
        }

        // lay out all of our menu items
        int maxwid = 0, maxhei = 0;
        icount = items.size();
        for (int i = 0; i < icount; i++) {
            RadialMenuItem item = items.get(i);
            item.layout(gfx, font);

            // track maximum menu item size
            if (item.closedBounds.width > maxwid) {
                maxwid = item.closedBounds.width;
            }
            if (item.closedBounds.height > maxhei) {
                maxhei = item.closedBounds.height;
            }
        }
        gfx.dispose();

        // use the maximum of either width or height and make a circle around that
        double radius = Math.max(_tbounds.height, _tbounds.width) / 2;

        // be sure to add a gap and space for the menu item itself
        radius += (5 + maxwid/2);

        // compute the angle between menu items (we use the diameter of the menu items as an
        // approximate measure of the distance along the circumference)
        double theta = (maxwid + 10) / radius ;

        // now position each item accordingly
        double angle = -Math.PI/2;
        for (int i = 0; i < icount; i++) {
            RadialMenuItem item = items.get(i);
            int ix = (int)(radius * Math.cos(angle));
            int iy = (int)(radius * Math.sin(angle));
            item.openBounds.x = item.closedBounds.x = ix - maxwid/2;
            item.openBounds.y = item.closedBounds.y = iy - maxhei/2;

            // move along the circle
            angle += theta;
        }

        // create and position the centerpiece label
        if (_centerIcon != null) {
            _centerLabel = new RadialLabelSausage("", _centerIcon);
            _centerLabel.layout(gfx, font);
            _centerLabel.openBounds.x = _centerLabel.closedBounds.x =
                -(_centerLabel.closedBounds.width / 2);
            _centerLabel.openBounds.y = _centerLabel.closedBounds.y =
                -(_centerLabel.closedBounds.height / 2);
        }

        // now compute the rectangle that encloses the entire menu

        // include the bounds for the centerpiece label
        if (_centerLabel != null) {
            _bounds.add(_centerLabel.openBounds);
        }

        // include the bounds for all menu items
        for (int i = 0; i < icount; i++) {
            RadialMenuItem item = items.get(i);
            // we need the open bounds rather than the closed ones
            _bounds.add(item.openBounds);
        }

        // now translate everything from the center of the target bounds to the upper left of the
        // menu bounds
        if (_centerLabel != null) {
            _centerLabel.openBounds.translate(-_bounds.x, -_bounds.y);
            _centerLabel.closedBounds.translate(-_bounds.x, -_bounds.y);
        }
        for (int i = 0; i < icount; i++) {
            RadialMenuItem item = items.get(i);
            item.openBounds.translate(-_bounds.x, -_bounds.y);
            item.closedBounds.translate(-_bounds.x, -_bounds.y);
        }

        // the origin was at the center of the encircled rectangle; we need to translate it such
        // that the origin of our bounds are in screen coordinates and at the upper left rather
        // than the center
        _bounds.x += (_tbounds.x + _tbounds.width/2);
        _bounds.y += (_tbounds.y + _tbounds.height/2);

        // now make sure the whole shebang is fully visible within the host component
        Rectangle hbounds = _host.getViewBounds();
        Point pos = SwingUtil.fitRectInRect(_bounds, hbounds);
        _bounds.setLocation(pos);
    }
110581
def _repaint(self, drawing_context):
        """"""

        # canvas size
        canvas_width = self.canvas_size[1]
        canvas_height = self.canvas_size[0]

        left = self.display_limits[0]
        right = self.display_limits[1]

        # draw left display limit
        if left > 0.0:
            with drawing_context.saver():
                drawing_context.begin_path()
                drawing_context.move_to(left * canvas_width, 1)
                drawing_context.line_to(left * canvas_width, canvas_height-1)
                drawing_context.line_width = 2
                drawing_context.stroke_style = "#000"
                drawing_context.stroke()

        # draw right display limit
        if right < 1.0:
            with drawing_context.saver():
                drawing_context.begin_path()
                drawing_context.move_to(right * canvas_width, 1)
                drawing_context.line_to(right * canvas_width, canvas_height-1)
                drawing_context.line_width = 2
                drawing_context.stroke_style = "#FFF"
                drawing_context.stroke()

        # draw border
        with drawing_context.saver():
            drawing_context.begin_path()
            drawing_context.move_to(0,canvas_height)
            drawing_context.line_to(canvas_width,canvas_height)
            drawing_context.line_width = 1
            drawing_context.stroke_style = "#444"
            drawing_context.stroke()
280759
def resize(self, width, height):
        ''
        self.canvas.SetInitialSize(wx.Size(width, height))
        self.window.GetSizer().Fit(self.window)
1141072
def get_console_size():
    
    from pandas import get_option

    display_width = get_option('display.width')
    # deprecated.
    display_height = get_option('display.max_rows')

    # Consider
    # interactive shell terminal, can detect term size
    # interactive non-shell terminal (ipnb/ipqtconsole), cannot detect term
    # size non-interactive script, should disregard term size

    # in addition
    # width,height have default values, but setting to 'None' signals
    # should use Auto-Detection, But only in interactive shell-terminal.
    # Simple. yeah.

    if in_interactive_session():
        if in_ipython_frontend():
            # sane defaults for interactive non-shell terminal
            # match default for width,height in config_init
            from pandas._config.config import get_default_val
            terminal_width = get_default_val('display.width')
            terminal_height = get_default_val('display.max_rows')
        else:
            # pure terminal
            terminal_width, terminal_height = get_terminal_size()
    else:
        terminal_width, terminal_height = None, None

    # Note if the User sets width/Height to None (auto-detection)
    # and we're in a script (non-inter), this will return (None,None)
    # caller needs to deal.
    return (display_width or terminal_width, display_height or terminal_height)
257044
function setupAddonBarWidget() {
  var panel = panels.Panel({
    width: 200,
    height: 128,
    contentURL: self.data.url('widget-panel.html'),
    contentScriptFile: self.data.url('widget-panel.js')
  });
  panel.on('show', function() {
    var url = getCanonicalUrl(tabs.activeTab.url);
    if (!url.length) {
      panel.port.emit('show', null);
    } else {
      panel.port.emit('show', {
        'enabled': isInjectionEnabledForUrl(url)
      });
    }
  });
  panel.port.on('perform', function(action) {
    switch (action) {
      case 'toggle':
        toggleInjectionForActiveTab();
        panel.hide();
        break;
      case 'reset':
        resetOptionsForActiveTab();
        panel.hide();
        break;
      case 'show_ui':
        showUi();
        panel.hide();
        break;
    }
  });

  var widget = widgets.Widget({
    id: 'wtf-toggle',
    label: 'Toggle Web Tracing Framework',
    contentURL: self.data.url('widget.html'),
    contentScriptFile: self.data.url('widget.js'),
    panel: panel
  });

  // Update the widget icon when the URL changes.
  function tabChanged() {
    var url = getCanonicalUrl(tabs.activeTab.url);
    widget.port.emit('update', {
      'enabled': url.length ? isInjectionEnabledForUrl(url) : false
    });
  };
  tabs.on('open', tabChanged);
  tabs.on('close', tabChanged);
  tabs.on('ready', tabChanged);
  tabs.on('activate', tabChanged);
  tabs.on('deactivate', tabChanged);
}
1204341
function snapToTerminal(terminal)
		{
			if (terminal != null)
			{
				snapToPoint.call(this, new mxPoint(view.getRoutingCenterX(terminal),
						view.getRoutingCenterY(terminal)));
			}
		}
925684
def SetSize(self, rect):
        

        grid = self.main_window.grid
        key = grid.actions.cursor

        drawn_rect = grid.grid_renderer._get_drawn_rect(grid, key, rect)

        self._tc.SetDimensions(drawn_rect.x, drawn_rect.y,
                               drawn_rect.width+2, drawn_rect.height+2,
                               wx.SIZE_ALLOW_MINUS_ONE)
        self._tc.Layout()