当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::getTerminalDimensions方法代码示例

本文整理汇总了PHP中Symfony\Component\Console\Application::getTerminalDimensions方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getTerminalDimensions方法的具体用法?PHP Application::getTerminalDimensions怎么用?PHP Application::getTerminalDimensions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Console\Application的用法示例。


在下文中一共展示了Application::getTerminalDimensions方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

 /**
  * ConsoleApplication constructor.
  *
  * ><p>**Note:** you'll have to configure the IO channels (ex. calling {@see setupStandardIO}) before running the
  * application.
  *
  * @param ConsoleIO         $io
  * @param ConsoleSettings   $settings
  * @param SymfonyConsole    $console
  * @param InjectorInterface $injector
  */
 function __construct(ConsoleIO $io, ConsoleSettings $settings, SymfonyConsole $console, InjectorInterface $injector)
 {
     $this->io = $io;
     $this->console = $console;
     $this->injector = $injector;
     $this->settings = $settings;
     $console->setAutoExit(false);
     $io->terminalSize($console->getTerminalDimensions());
 }
开发者ID:electro-framework,项目名称:framework,代码行数:20,代码来源:ConsoleApplication.php

示例2: getTerminalWidth

 /**
  * Returns the terminal width.
  *
  * @return int
  */
 private function getTerminalWidth()
 {
     $application = new Application();
     $terminalDimensions = $application->getTerminalDimensions();
     $width = 120;
     if (isset($terminalDimensions[0])) {
         $width = $terminalDimensions[0];
     }
     return $width;
 }
开发者ID:deborahvandervegt,项目名称:accompli,代码行数:15,代码来源:TitleBlock.php

示例3: table

 public function table(array $headers, array $rows)
 {
     $application = new Application();
     $dimensions = $application->getTerminalDimensions();
     $terminalWidth = $dimensions[0] ?: self::MAX_LINE_LENGTH;
     $maxHeaderWidth = strlen($headers[0]);
     foreach ($rows as $row) {
         $length = strlen($row[0]);
         if ($maxHeaderWidth === null || $length > $maxHeaderWidth) {
             $maxHeaderWidth = $length;
         }
     }
     $wrap = function ($rows) use($terminalWidth, $maxHeaderWidth) {
         return array_map(function ($row) use($terminalWidth, $maxHeaderWidth) {
             return array_map(function ($s) use($terminalWidth, $maxHeaderWidth) {
                 if ($terminalWidth > $maxHeaderWidth + 5) {
                     return wordwrap($s, $terminalWidth - $maxHeaderWidth - 5, "\n", true);
                 }
                 return $s;
             }, $row);
         }, $rows);
     };
     parent::table($headers, $wrap($rows));
 }
开发者ID:phpstan,项目名称:phpstan,代码行数:24,代码来源:ErrorsConsoleStyle.php

示例4: testTerminalDimensions

 public function testTerminalDimensions()
 {
     $application = new Application();
     $originalDimensions = $application->getTerminalDimensions();
     $this->assertCount(2, $originalDimensions);
     $width = 80;
     if ($originalDimensions[0] == $width) {
         $width = 100;
     }
     $application->setTerminalDimensions($width, 80);
     $this->assertSame(array($width, 80), $application->getTerminalDimensions());
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:12,代码来源:ApplicationTest.php

示例5: getTerminalWidth

 private function getTerminalWidth()
 {
     $application = new Application();
     $dimensions = $application->getTerminalDimensions();
     return $dimensions[0] ?: self::MAX_LINE_LENGTH;
 }
开发者ID:a53ali,项目名称:CakePhP,代码行数:6,代码来源:SymfonyStyle.php

示例6: getTerminalWidth

 /**
  * @param int $default
  *
  * @return int
  */
 protected function getTerminalWidth($default = 80)
 {
     static $dimensions;
     if (!$dimensions) {
         $application = new ConsoleApplication();
         $dimensions = $application->getTerminalDimensions();
     }
     return $dimensions[0] ?: $default;
 }
开发者ID:ratajczak,项目名称:platformsh-cli,代码行数:14,代码来源:CustomTextDescriptor.php

示例7: getDefaultTerminalDimensions

 /**
  * {@inheritdoc}
  */
 protected function getDefaultTerminalDimensions()
 {
     $application = new Application();
     list($width, $height) = $application->getTerminalDimensions();
     return new Rectangle($width ?: 80, $height ?: 20);
 }
开发者ID:webmozart,项目名称:console,代码行数:9,代码来源:ConsoleIO.php


注:本文中的Symfony\Component\Console\Application::getTerminalDimensions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。