"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/window-size/index.js" (11 Apr 2017, 827 Bytes) of package /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 'use strict';
    2 
    3 /*!
    4  * window-size <https://github.com/jonschlinkert/window-size>
    5  *
    6  * Copyright (c) 2014-2015 Jon Schlinkert
    7  * Licensed under the MIT license.
    8  */
    9 
   10 var tty = require('tty');
   11 
   12 module.exports = (function () {
   13   var width;
   14   var height;
   15 
   16   if (tty.isatty(1) && tty.isatty(2)) {
   17     if (process.stdout.getWindowSize) {
   18       width = process.stdout.getWindowSize(1)[0];
   19       height = process.stdout.getWindowSize(1)[1];
   20     } else if (tty.getWindowSize) {
   21       width = tty.getWindowSize()[1];
   22       height = tty.getWindowSize()[0];
   23     } else if (process.stdout.columns && process.stdout.rows) {
   24       height = process.stdout.columns;
   25       width = process.stdout.rows;
   26     }
   27   } else {
   28     Error('window-size could not get size with tty or process.stdout.');
   29   }
   30 
   31   return {height: height, width: width};
   32 })();