當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。