浏览代码

Updated core, terminal detection

markseu 3 年之前
父节点
当前提交
667248687b
共有 2 个文件被更改,包括 25 次插入3 次删除
  1. 23 1
      system/extensions/core.php
  2. 2 2
      system/extensions/update-current.ini

+ 23 - 1
system/extensions/core.php

@@ -2,7 +2,7 @@
 // Core extension, https://github.com/datenstrom/yellow-extensions/tree/master/source/core
 
 class YellowCore {
-    const VERSION = "0.8.83";
+    const VERSION = "0.8.84";
     const RELEASE = "0.8.20";
     public $page;           // current page
     public $content;        // content files
@@ -3297,6 +3297,28 @@ class YellowToolbox {
         return $languageFound;
     }
     
+    // Detect terminal width and height
+    public function detectTerminalInformation() {
+        $width = $height = 0;
+        if (strtoupperu(substru(PHP_OS, 0, 3))=="WIN") {
+            exec("powershell $Host.UI.RawUI.WindowSize.Width", $outputLines, $returnStatus);
+            if ($returnStatus==0 && !empty($outputLines)) {
+                $width = intval(end($outputLines));
+            }
+            exec("powershell $Host.UI.RawUI.WindowSize.Height", $outputLines, $returnStatus);
+            if ($returnStatus==0 && !empty($outputLines)) {
+                $height = intval(end($outputLines));
+            }
+        } else {
+            exec("stty size", $outputLines, $returnStatus);
+            if ($returnStatus==0 && preg_match("/^(\d+)\s+(\d+)/", implode("\n", $outputLines), $matches)) {
+                $width = intval($matches[2]);
+                $height = intval($matches[1]);
+            }
+        }
+        return array($width, $height);
+    }
+    
     // Detect image width, height, orientation and type for GIF/JPG/PNG/SVG
     public function detectImageInformation($fileName, $fileType = "") {
         $width = $height = $orientation = 0;

+ 2 - 2
system/extensions/update-current.ini

@@ -21,11 +21,11 @@ Tag: feature
 system/extensions/command.php: command.php, create, update
 
 Extension: Core
-Version: 0.8.83
+Version: 0.8.84
 Description: Core functionality of the website.
 DocumentationUrl: https://github.com/datenstrom/yellow-extensions/tree/master/source/core
 DownloadUrl: https://github.com/datenstrom/yellow-extensions/raw/master/zip/core.zip
-Published: 2022-05-26 21:04:47
+Published: 2022-06-03 15:57:48
 Developer: Datenstrom
 Tag: feature
 system/extensions/core.php: core.php, create, update