Bearsampp 2026.7.11
Loading...
Searching...
No Matches
TplPowerShell Class Reference

Static Public Member Functions

static process ()

Private Member Functions

 __construct ()

Static Private Member Functions

static getTab ($title, $icon, $shell, $initDir)
static getTabCmdSection ()
static getTabComposerSection ()
static getTabGhostscriptSection ()
static getTabGitSection ()
static getTabMariadbSection ()
static getTabMysqlSection ()
static getTabNgrokSection ()
static getTabNodejsSection ()
static getTabPearSection ()
static getTabPerlSection ()
static getTabPostgresqlSection ()
static getTabPowerShellSection ()
static getTabPythonSection ()
static getTabRubySection ()
static getTabsSection ()

Detailed Description

Class TplPowerShell

This class is responsible for managing PowerShell configuration. It includes methods to define various sections such as tabs for different tools.

Definition at line 16 of file class.tpl.powershell.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )
private

Private constructor to prevent instantiation.

Definition at line 40 of file class.tpl.powershell.php.

41 {
42 }

Member Function Documentation

◆ getTab()

getTab ( $title,
$icon,
$shell,
$initDir )
staticprivate

Generates the structure for a tab.

This function constructs the structure for a tab, including the title, shell command, and initial directory.

Note: Icon parameter is currently unused as native PowerShell consoles do not support custom icons in tab titles. This was a feature of ConsoleZ which is no longer used. To use icons, consider using a terminal emulator like ConEmu, Cmder, or Windows Terminal.

Parameters
string$titleThe title of the tab.
string | null$iconThe icon for the tab (currently unused).
string$shellThe shell command to be executed in the tab.
string$initDirThe initial directory for the tab.
Returns
string The structure for the tab. @global Core $bearsamppCore The core object of the application.

Definition at line 597 of file class.tpl.powershell.php.

598 {
599 global $bearsamppCore;
600 // Icon parameter is ignored as native PowerShell console does not support custom icons
601 // Return tab information as a formatted string
602 return "Title: $title | Shell: $shell | InitDir: $initDir";
603 }
global $bearsamppCore

References $bearsamppCore.

Referenced by getTabCmdSection(), getTabComposerSection(), getTabGhostscriptSection(), getTabGitSection(), getTabMariadbSection(), getTabMysqlSection(), getTabNgrokSection(), getTabNodejsSection(), getTabPearSection(), getTabPerlSection(), getTabPostgresqlSection(), getTabPowerShellSection(), getTabPythonSection(), and getTabRubySection().

Here is the caller graph for this function:

◆ getTabCmdSection()

getTabCmdSection ( )
staticprivate

Generates the structure for the command tab section.

This function creates a structure defining the command tab and its configuration. It retrieves the tab title and shell command from the PowerShell tool and sets the root path.

Returns
string The formatted string for the command tab section. @global Tools $bearsamppTools The tools object of the application.

@global Root $bearsamppRoot The root object of the application.

Definition at line 175 of file class.tpl.powershell.php.

176 {
177 global $bearsamppRoot, $bearsamppTools;
178
179 return self::getTab(
180 $bearsamppTools->getPowerShell()->getTabTitleDefault(),
181 null, // self::ICON_APP - Icon not supported in native PowerShell console
182 $bearsamppTools->getPowerShell()->getShell(),
184 ) . PHP_EOL;
185 }
global $bearsamppRoot
static getRootPath($aetrayPath=false)
static getTab($title, $icon, $shell, $initDir)

References $bearsamppRoot, Path\getRootPath(), and getTab().

Referenced by getTabsSection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTabComposerSection()

getTabComposerSection ( )
staticprivate

Generates the structure for the Composer tab section.

This function creates a structure defining the Composer tab and its configuration. It retrieves the Composer executable path and sets the WWW path.

Returns
string The formatted string for the Composer tab section. @global Tools $bearsamppTools The tools object of the application.

@global Root $bearsamppRoot The root object of the application.

Definition at line 403 of file class.tpl.powershell.php.

404 {
405 global $bearsamppRoot, $bearsamppTools;
406
407 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppTools->getComposer()->getExe() . '"');
408 if (!file_exists($bearsamppTools->getComposer()->getExe())) {
409 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getComposer()->getExe() . ' not found');
410 }
411
412 return self::getTab(
413 $bearsamppTools->getPowerShell()->getTabTitleComposer(),
414 null, // self::ICON_COMPOSER - Icon not supported in native PowerShell console
415 $shell,
417 ) . PHP_EOL;
418 }
static getWwwPath($aetrayPath=false)

References $bearsamppRoot, getTab(), and Path\getWwwPath().

Referenced by getTabsSection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTabGhostscriptSection()

getTabGhostscriptSection ( )
staticprivate

Generates the tab section for Ghostscript in the console.

This function constructs a shell command to check the version of Ghostscript and verifies if the executable exists. If the executable is not found, it returns a message indicating the absence of the executable. It then creates a tab section with the appropriate title, icon, shell command, and initial directory.

Returns
string The structure for the Ghostscript tab section. @global Tools $bearsamppTools The tools object of the application. @global Root $bearsamppRoot The root object of the application.

Definition at line 533 of file class.tpl.powershell.php.

534 {
535 global $bearsamppRoot, $bearsamppTools;
536
537 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppTools->getGhostscript()->getExeConsole() . '"');
538 if (!file_exists($bearsamppTools->getGhostscript()->getExeConsole())) {
539 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getGhostscript()->getExeConsole() . ' not found');
540 }
541
542 return self::getTab(
543 $bearsamppTools->getPowerShell()->getTabTitleGhostscript(),
544 null, // self::ICON_GHOSTSCRIPT - Icon not supported in native PowerShell console
545 $shell,
547 ) . PHP_EOL;
548 }

References $bearsamppRoot, getTab(), and Path\getWwwPath().

Referenced by getTabsSection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTabGitSection()

getTabGitSection ( )
staticprivate

Generates the structure for the Git tab section.

This function creates a structure defining the Git tab and its configuration. It retrieves the Git executable path and sets the WWW path.

Returns
string The formatted string for the Git tab section. @global Tools $bearsamppTools The tools object of the application.

@global Root $bearsamppRoot The root object of the application.

Definition at line 346 of file class.tpl.powershell.php.

347 {
348 global $bearsamppRoot, $bearsamppTools;
349
350 $shell = $bearsamppTools->getPowerShell()->getShell();
351 if (!file_exists($bearsamppTools->getGit()->getExe())) {
352 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getGit()->getExe() . ' not found');
353 }
354
355 return self::getTab(
356 $bearsamppTools->getPowerShell()->getTabTitleGit(),
357 null, // self::ICON_GIT - Icon not supported in native PowerShell console
358 $shell,
360 ) . PHP_EOL;
361 }

References $bearsamppRoot, getTab(), and Path\getWwwPath().

Referenced by getTabsSection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTabMariadbSection()

getTabMariadbSection ( )
staticprivate

Generates the structure for the MariaDB tab section.

This function creates a structure defining the MariaDB tab and its configuration. It retrieves the MariaDB CLI executable path and sets the symlink path.

Returns
string The formatted string for the MariaDB tab section. @global Tools $bearsamppTools The tools object of the application.

@global Bins $bearsamppBins The bins object of the application.

Definition at line 284 of file class.tpl.powershell.php.

285 {
286 global $bearsamppBins, $bearsamppTools;
287
288 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppBins->getMariadb()->getCliExe() . '" -u' .
289 $bearsamppBins->getMariadb()->getRootUser() .
290 ($bearsamppBins->getMariadb()->getRootPwd() ? ' -p' : ''));
291 if (!file_exists($bearsamppBins->getMariadb()->getCliExe())) {
292 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppBins->getMariadb()->getCliExe() . ' not found');
293 }
294
295 return self::getTab(
296 $bearsamppTools->getPowerShell()->getTabTitleMariadb(),
297 null, // self::ICON_DB - Icon not supported in native PowerShell console
298 $shell,
300 ) . PHP_EOL;
301 }
global $bearsamppBins
static getModuleSymlinkPath($module)

References $bearsamppBins, Path\getModuleSymlinkPath(), and getTab().

Referenced by getTabsSection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTabMysqlSection()

getTabMysqlSection ( )
staticprivate

Generates the structure for the MySQL tab section.

This function creates a structure defining the MySQL tab and its configuration. It retrieves the MySQL CLI executable path and sets the symlink path.

Returns
string The formatted string for the MySQL tab section. @global Tools $bearsamppTools The tools object of the application.

@global Bins $bearsamppBins The bins object of the application.

Definition at line 254 of file class.tpl.powershell.php.

255 {
256 global $bearsamppBins, $bearsamppTools;
257
258 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppBins->getMysql()->getCliExe() . '" -u' .
259 $bearsamppBins->getMysql()->getRootUser() .
260 ($bearsamppBins->getMysql()->getRootPwd() ? ' -p' : ''));
261 if (!file_exists($bearsamppBins->getMysql()->getCliExe())) {
262 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppBins->getMysql()->getCliExe() . ' not found');
263 }
264
265 return self::getTab(
266 $bearsamppTools->getPowerShell()->getTabTitleMysql(),
267 null, // self::ICON_DB - Icon not supported in native PowerShell console
268 $shell,
270 ) . PHP_EOL;
271 }

References $bearsamppBins, Path\getModuleSymlinkPath(), and getTab().

Referenced by getTabsSection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTabNgrokSection()

getTabNgrokSection ( )
staticprivate

Generates the tab section for Ngrok in the console.

This function constructs a shell command to check the version of Ngrok and verifies if the executable exists. If the executable is not found, it returns a message indicating the absence of the executable. It then creates a tab section with the appropriate title, icon, shell command, and initial directory.

Returns
string The structure for the Ngrok tab section. @global Tools $bearsamppTools The tools object of the application. @global Root $bearsamppRoot The root object of the application.

Definition at line 563 of file class.tpl.powershell.php.

564 {
565 global $bearsamppRoot, $bearsamppTools;
566
567 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppTools->getNgrok()->getExe() . '"');
568 if (!file_exists($bearsamppTools->getNgrok()->getExe())) {
569 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getNgrok()->getExe() . ' not found');
570 }
571
572 return self::getTab(
573 $bearsamppTools->getPowerShell()->getTabTitleNgrok(),
574 null, // self::ICON_NGROK - Icon not supported in native PowerShell console
575 $shell,
577 ) . PHP_EOL;
578 }

References $bearsamppRoot, getTab(), and Path\getWwwPath().

Referenced by getTabsSection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTabNodejsSection()

getTabNodejsSection ( )
staticprivate

Generates the structure for the Node.js tab section.

This function creates a structure defining the Node.js tab and its configuration. It retrieves the Node.js launch path and sets the WWW path.

Returns
string The formatted string for the Node.js tab section. @global Bins $bearsamppBins The bins object of the application. @global Tools $bearsamppTools The tools object of the application.

@global Root $bearsamppRoot The root object of the application.

Definition at line 375 of file class.tpl.powershell.php.

376 {
377 global $bearsamppRoot, $bearsamppBins, $bearsamppTools;
378
379 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppBins->getNodejs()->getLaunch() . '"');
380 if (!file_exists($bearsamppBins->getNodejs()->getLaunch())) {
381 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppBins->getNodejs()->getLaunch() . ' not found');
382 }
383
384 return self::getTab(
385 $bearsamppTools->getPowerShell()->getTabTitleNodejs(),
386 null, // self::ICON_NODEJS - Icon not supported in native PowerShell console
387 $shell,
389 ) . PHP_EOL;
390 }

References $bearsamppBins, $bearsamppRoot, getTab(), and Path\getWwwPath().

Referenced by getTabsSection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTabPearSection()

getTabPearSection ( )
staticprivate

Generates the structure for the PEAR tab section.

This function creates a structure defining the PEAR tab and its configuration. It retrieves the PEAR executable path and sets the symlink path.

Returns
string The formatted string for the PEAR tab section. @global Tools $bearsamppTools The tools object of the application.

@global Bins $bearsamppBins The bins object of the application.

Definition at line 226 of file class.tpl.powershell.php.

227 {
228 global $bearsamppBins, $bearsamppTools;
229
230 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppBins->getPhp()->getPearExe() . '"');
231 if (!file_exists($bearsamppBins->getPhp()->getPearExe())) {
232 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppBins->getPhp()->getPearExe() . ' not found');
233 }
234
235 return self::getTab(
236 $bearsamppTools->getPowerShell()->getTabTitlePear(),
237 null, // self::ICON_PEAR - Icon not supported in native PowerShell console
238 $shell,
239 Path::getModuleSymlinkPath($bearsamppBins->getPhp()) . '/pear'
240 ) . PHP_EOL;
241 }

References $bearsamppBins, Path\getModuleSymlinkPath(), and getTab().

Referenced by getTabsSection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTabPerlSection()

getTabPerlSection ( )
staticprivate

Generates the structure for the Perl tab section.

This function creates a structure defining the Perl tab and its configuration. It retrieves the Perl executable path and sets the WWW path.

Returns
string The formatted string for the Perl tab section. @global Tools $bearsamppTools The tools object of the application.

@global Root $bearsamppRoot The root object of the application.

Definition at line 503 of file class.tpl.powershell.php.

504 {
505 global $bearsamppRoot, $bearsamppTools;
506
507 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppTools->getPerl()->getExe() . '"');
508 if (!file_exists($bearsamppTools->getPerl()->getExe())) {
509 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getPerl()->getExe() . ' not found');
510 }
511
512 return self::getTab(
513 $bearsamppTools->getPowerShell()->getTabTitlePerl(),
514 null, // self::ICON_PERL - Icon not supported in native PowerShell console
515 $shell,
517 ) . PHP_EOL;
518 }

References $bearsamppRoot, getTab(), and Path\getWwwPath().

Referenced by getTabsSection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTabPostgresqlSection()

getTabPostgresqlSection ( )
staticprivate

Generates the structure for the PostgreSQL tab section.

This function creates a structure defining the PostgreSQL tab and its configuration. It retrieves the PostgreSQL CLI executable path and sets the symlink path.

Returns
string The formatted string for the PostgreSQL tab section. @global Tools $bearsamppTools The tools object of the application.

@global Bins $bearsamppBins The bins object of the application.

Definition at line 314 of file class.tpl.powershell.php.

315 {
316 global $bearsamppBins, $bearsamppTools;
317
318 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppBins->getPostgresql()->getCliExe() . '"' .
319 ' -h 127.0.0.1' .
320 ' -p ' . $bearsamppBins->getPostgresql()->getPort() .
321 ' -U ' . $bearsamppBins->getPostgresql()->getRootUser() .
322 ' -d postgres');
323 if (!file_exists($bearsamppBins->getPostgresql()->getCliExe())) {
324 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppBins->getPostgresql()->getCliExe() . ' not found');
325 }
326
327 return self::getTab(
328 $bearsamppTools->getPowerShell()->getTabTitlePostgresql(),
329 null, // self::ICON_DB - Icon not supported in native PowerShell console
330 $shell,
332 ) . PHP_EOL;
333 }

References $bearsamppBins, Path\getModuleSymlinkPath(), and getTab().

Referenced by getTabsSection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTabPowerShellSection()

getTabPowerShellSection ( )
staticprivate

Generates the structure for the PowerShell tab section.

This function creates a structure defining the PowerShell tab and its configuration. It retrieves the PowerShell path and sets the root path.

Returns
string The formatted string for the PowerShell tab section. @global Tools $bearsamppTools The tools object of the application.

@global Root $bearsamppRoot The root object of the application.

Definition at line 198 of file class.tpl.powershell.php.

199 {
200 global $bearsamppRoot, $bearsamppTools;
201
202 $powerShellPath = Path::getPowerShellPath();
203 if ($powerShellPath !== false) {
204 return self::getTab(
205 $bearsamppTools->getPowerShell()->getTabTitlePowershell(),
206 null, // self::ICON_POWERSHELL - Icon not supported in native PowerShell console
207 $powerShellPath,
209 ) . PHP_EOL;
210 }
211
212 return "";
213 }
static getPowerShellPath()

References $bearsamppRoot, Path\getPowerShellPath(), Path\getRootPath(), and getTab().

Referenced by getTabsSection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTabPythonSection()

getTabPythonSection ( )
staticprivate

Generates the structure for the Python tab section.

This function creates a structure defining the Python tab and its configuration. It retrieves the Python executable path and sets the WWW path.

Returns
string The formatted string for the Python tab section. @global Tools $bearsamppTools The tools object of the application.

@global Root $bearsamppRoot The root object of the application.

Definition at line 431 of file class.tpl.powershell.php.

432 {
433 global $bearsamppRoot, $bearsamppTools;
434
435 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppTools->getPython()->getExe() . '"');
436 if (!file_exists($bearsamppTools->getPython()->getExe())) {
437 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getPython()->getExe() . ' not found');
438 }
439
440 return self::getTab(
441 $bearsamppTools->getPowerShell()->getTabTitlePython(),
442 null, // self::ICON_PYTHON - Icon not supported in native PowerShell console
443 $shell,
445 ) . PHP_EOL;
446 }

References $bearsamppRoot, getTab(), and Path\getWwwPath().

Referenced by getTabsSection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTabRubySection()

getTabRubySection ( )
staticprivate

Generates the structure for the Ruby tab section.

This function creates a structure defining the Ruby tab and its configuration. It retrieves the Ruby executable path and sets the WWW path.

Returns
string The formatted string for the Ruby tab section. @global Tools $bearsamppTools The tools object of the application.

@global Root $bearsamppRoot The root object of the application.

Definition at line 459 of file class.tpl.powershell.php.

460 {
461 global $bearsamppRoot, $bearsamppTools;
462
463 // Check if Ruby exists first
464 if (!file_exists($bearsamppTools->getRuby()->getExe())) {
465 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getRuby()->getExe() . ' not found');
466 } else {
467 // Use irb (Interactive Ruby) for an interactive shell
468 $rubyDir = dirname($bearsamppTools->getRuby()->getExe());
469 $irbExe = $rubyDir . '/irb.bat';
470
471 // Check if irb.bat exists, otherwise try irb.cmd or just use ruby with -i flag
472 if (file_exists($irbExe)) {
473 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $irbExe . '"');
474 } elseif (file_exists($rubyDir . '/irb.cmd')) {
475 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $rubyDir . '/irb.cmd' . '"');
476 } elseif (file_exists($rubyDir . '/irb')) {
477 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $rubyDir . '/irb' . '"');
478 } else {
479 // Fallback to just opening a shell in the Ruby directory
480 $shell = $bearsamppTools->getPowerShell()->getShell();
481 }
482 }
483
484 return self::getTab(
485 $bearsamppTools->getPowerShell()->getTabTitleRuby(),
486 null, // self::ICON_RUBY - Icon not supported in native PowerShell console
487 $shell,
489 ) . PHP_EOL;
490 }

References $bearsamppRoot, getTab(), and Path\getWwwPath().

Referenced by getTabsSection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTabsSection()

getTabsSection ( )
staticprivate

Generates the tabs section.

This function creates a structure defining various tabs and their configurations. It includes multiple tab sections such as command, PowerShell, PEAR, MySQL, MariaDB, PostgreSQL, Ghostscript, Git, Node.js, Composer, Perl, Python, Ruby and Ngrok.

Returns
string The formatted string for the tabs section.

Definition at line 146 of file class.tpl.powershell.php.

147 {
148 return self::getTabCmdSection() .
162 }
static getTabGhostscriptSection()

References getTabCmdSection(), getTabComposerSection(), getTabGhostscriptSection(), getTabGitSection(), getTabMariadbSection(), getTabMysqlSection(), getTabNgrokSection(), getTabNodejsSection(), getTabPearSection(), getTabPerlSection(), getTabPostgresqlSection(), getTabPowerShellSection(), getTabPythonSection(), and getTabRubySection().

Here is the call graph for this function:

◆ process()

process ( )
static

Process PowerShell configuration.

PowerShell 7+ uses profile scripts and Oh My Posh for configuration, not XML like ConsoleZ. This method is maintained for compatibility.

Definition at line 50 of file class.tpl.powershell.php.

51 {
52 global $bearsamppTools;
53
54 $fontName = 'CaskaydiaMono NF'; // Default Nerd Font
55
56 // Collect all console window titles that need font configuration
57 $titles = [];
58 $titles[] = $bearsamppTools->getPowerShell()->getTabTitleDefault();
59 $titles[] = $bearsamppTools->getPowerShell()->getTabTitlePowershell();
60 $titles[] = 'Console';
61 $titles[] = 'Bearsampp Powershell Console'; // Fallback casing
62
63 try { $titles[] = $bearsamppTools->getPowerShell()->getTabTitlePear(); } catch (Exception $e) {}
64 try { $titles[] = $bearsamppTools->getPowerShell()->getTabTitleMysql(); } catch (Exception $e) {}
65 try { $titles[] = $bearsamppTools->getPowerShell()->getTabTitleMariadb(); } catch (Exception $e) {}
66 try { $titles[] = $bearsamppTools->getPowerShell()->getTabTitlePostgresql(); } catch (Exception $e) {}
67 try { $titles[] = $bearsamppTools->getPowerShell()->getTabTitleGit(); } catch (Exception $e) {}
68 try { $titles[] = $bearsamppTools->getPowerShell()->getTabTitleNodejs(); } catch (Exception $e) {}
69 try { $titles[] = $bearsamppTools->getPowerShell()->getTabTitleComposer(); } catch (Exception $e) {}
70 try { $titles[] = $bearsamppTools->getPowerShell()->getTabTitlePython(); } catch (Exception $e) {}
71 try { $titles[] = $bearsamppTools->getPowerShell()->getTabTitleRuby(); } catch (Exception $e) {}
72 try { $titles[] = $bearsamppTools->getPowerShell()->getTabTitlePerl(); } catch (Exception $e) {}
73 try { $titles[] = $bearsamppTools->getPowerShell()->getTabTitleGhostscript(); } catch (Exception $e) {}
74 try { $titles[] = $bearsamppTools->getPowerShell()->getTabTitleNgrok(); } catch (Exception $e) {}
75
76 // Also include generic/short titles
77 $shortTitles = ["Composer", "Ghostscript", "ngrok", "PEAR", "Perl", "Ruby", "Git", "Python", "MariaDB", "MySQL", "PostgreSQL", "Node.js"];
78 $allTitles = array_unique(array_merge($titles, $shortTitles));
79
80 // Build a single .reg file with all HKCU Console font settings.
81 // This replaces ~140 individual exec("reg add ...") calls, each of which
82 // would spawn a separate process and potentially flash a console window.
83 $regContent = "Windows Registry Editor Version 5.00\r\n";
84
85 // Global HKCU\Console defaults
86 $regContent .= "\r\n[HKEY_CURRENT_USER\\Console]\r\n";
87 $regContent .= '"FaceName"="' . $fontName . '"' . "\r\n";
88 $regContent .= '"FontFamily"=dword:00000036' . "\r\n";
89 $regContent .= '"CodePage"=dword:0000fde9' . "\r\n";
90
91 // Per-title settings
92 foreach ($allTitles as $title) {
93 if (empty($title)) continue;
94 $regContent .= "\r\n[HKEY_CURRENT_USER\\Console\\" . $title . "]\r\n";
95 $regContent .= '"FaceName"="' . $fontName . '"' . "\r\n";
96 $regContent .= '"FontFamily"=dword:00000036' . "\r\n";
97 $regContent .= '"FontSize"=dword:00100000' . "\r\n";
98 $regContent .= '"FontWeight"=dword:00000190' . "\r\n";
99 $regContent .= '"CodePage"=dword:0000fde9' . "\r\n";
100 $regContent .= '"ScreenBufferSize"=dword:0bb8006e' . "\r\n";
101 $regContent .= '"WindowSize"=dword:001e006e' . "\r\n";
102 }
103
104 // Register as a valid TrueType console font (HKCU only — no elevation needed)
105 $regContent .= "\r\n[HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Console\\TrueTypeFont]\r\n";
106 $regContent .= '"0"="' . $fontName . '"' . "\r\n";
107 $regContent .= '"00"="' . $fontName . '"' . "\r\n";
108 $regContent .= '"000"="' . $fontName . '"' . "\r\n";
109
110 // Write and import the .reg file in a single process — zero flashing windows
111 $tmpReg = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'bearsampp_console_font.reg';
112
113 $bytes = file_put_contents($tmpReg, $regContent);
114 if ($bytes === false || $bytes === 0) {
115 return false;
116 }
117
118 $cmd = 'reg import "' . $tmpReg . '"';
119 $exitCode = 1;
120 try {
121 $wsh = new COM('WScript.Shell');
122 $exitCode = $wsh->Run($cmd, 0, true);
123 } catch (Throwable $e) {
124 $output = [];
125 exec($cmd, $output, $exitCode);
126 }
127
128 @unlink($tmpReg);
129
130 if ($exitCode !== 0) {
131 return false;
132 }
133
134 return true;
135 }

Referenced by ActionReload\__construct().

Here is the caller graph for this function:

The documentation for this class was generated from the following file: