Bearsampp 2026.9.23
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 646 of file class.tpl.powershell.php.

647 {
648 global $bearsamppCore;
649 // Icon parameter is ignored as native PowerShell console does not support custom icons
650 // Return tab information as a formatted string
651 return "Title: $title | Shell: $shell | InitDir: $initDir";
652 }
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 217 of file class.tpl.powershell.php.

218 {
219 global $bearsamppRoot, $bearsamppTools;
220
221 return self::getTab(
222 $bearsamppTools->getPowerShell()->getTabTitleDefault(),
223 null, // self::ICON_APP - Icon not supported in native PowerShell console
224 $bearsamppTools->getPowerShell()->getShell(),
226 ) . PHP_EOL;
227 }
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 451 of file class.tpl.powershell.php.

452 {
453 global $bearsamppRoot, $bearsamppTools;
454
455 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppTools->getComposer()->getExe() . '"');
456 if (!file_exists($bearsamppTools->getComposer()->getExe())) {
457 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getComposer()->getExe() . ' not found');
458 }
459
460 return self::getTab(
461 $bearsamppTools->getPowerShell()->getTabTitleComposer(),
462 null, // self::ICON_COMPOSER - Icon not supported in native PowerShell console
463 $shell,
465 ) . PHP_EOL;
466 }
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 581 of file class.tpl.powershell.php.

582 {
583 global $bearsamppRoot, $bearsamppTools;
584
585 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppTools->getGhostscript()->getExeConsole() . '"');
586 if (!file_exists($bearsamppTools->getGhostscript()->getExeConsole())) {
587 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getGhostscript()->getExeConsole() . ' not found');
588 }
589
590 return self::getTab(
591 $bearsamppTools->getPowerShell()->getTabTitleGhostscript(),
592 null, // self::ICON_GHOSTSCRIPT - Icon not supported in native PowerShell console
593 $shell,
595 ) . PHP_EOL;
596 }

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 394 of file class.tpl.powershell.php.

395 {
396 global $bearsamppRoot, $bearsamppTools;
397
398 $shell = $bearsamppTools->getPowerShell()->getShell();
399 if (!file_exists($bearsamppTools->getGit()->getExe())) {
400 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getGit()->getExe() . ' not found');
401 }
402
403 return self::getTab(
404 $bearsamppTools->getPowerShell()->getTabTitleGit(),
405 null, // self::ICON_GIT - Icon not supported in native PowerShell console
406 $shell,
408 ) . PHP_EOL;
409 }

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 328 of file class.tpl.powershell.php.

329 {
330 global $bearsamppBins, $bearsamppTools;
331
332 $shell = $bearsamppTools->getPowerShell()->getShell(
333 '"' . $bearsamppBins->getMariadb()->getCliExe() . '" -u' .
334 $bearsamppBins->getMariadb()->getRootUser() .
335 ($bearsamppBins->getMariadb()->getRootPwd() ? ' -p' : '')
336 );
337 if (!file_exists($bearsamppBins->getMariadb()->getCliExe())) {
338 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppBins->getMariadb()->getCliExe() . ' not found');
339 }
340
341 return self::getTab(
342 $bearsamppTools->getPowerShell()->getTabTitleMariadb(),
343 null, // self::ICON_DB - Icon not supported in native PowerShell console
344 $shell,
346 ) . PHP_EOL;
347 }
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 296 of file class.tpl.powershell.php.

297 {
298 global $bearsamppBins, $bearsamppTools;
299
300 $shell = $bearsamppTools->getPowerShell()->getShell(
301 '"' . $bearsamppBins->getMysql()->getCliExe() . '" -u' .
302 $bearsamppBins->getMysql()->getRootUser() .
303 ($bearsamppBins->getMysql()->getRootPwd() ? ' -p' : '')
304 );
305 if (!file_exists($bearsamppBins->getMysql()->getCliExe())) {
306 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppBins->getMysql()->getCliExe() . ' not found');
307 }
308
309 return self::getTab(
310 $bearsamppTools->getPowerShell()->getTabTitleMysql(),
311 null, // self::ICON_DB - Icon not supported in native PowerShell console
312 $shell,
314 ) . PHP_EOL;
315 }

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 611 of file class.tpl.powershell.php.

612 {
613 global $bearsamppRoot, $bearsamppTools;
614
615 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppTools->getNgrok()->getExe() . '"');
616 if (!file_exists($bearsamppTools->getNgrok()->getExe())) {
617 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getNgrok()->getExe() . ' not found');
618 }
619
620 return self::getTab(
621 $bearsamppTools->getPowerShell()->getTabTitleNgrok(),
622 null, // self::ICON_NGROK - Icon not supported in native PowerShell console
623 $shell,
625 ) . PHP_EOL;
626 }

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 423 of file class.tpl.powershell.php.

424 {
425 global $bearsamppRoot, $bearsamppBins, $bearsamppTools;
426
427 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppBins->getNodejs()->getLaunch() . '"');
428 if (!file_exists($bearsamppBins->getNodejs()->getLaunch())) {
429 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppBins->getNodejs()->getLaunch() . ' not found');
430 }
431
432 return self::getTab(
433 $bearsamppTools->getPowerShell()->getTabTitleNodejs(),
434 null, // self::ICON_NODEJS - Icon not supported in native PowerShell console
435 $shell,
437 ) . PHP_EOL;
438 }

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 268 of file class.tpl.powershell.php.

269 {
270 global $bearsamppBins, $bearsamppTools;
271
272 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppBins->getPhp()->getPearExe() . '"');
273 if (!file_exists($bearsamppBins->getPhp()->getPearExe())) {
274 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppBins->getPhp()->getPearExe() . ' not found');
275 }
276
277 return self::getTab(
278 $bearsamppTools->getPowerShell()->getTabTitlePear(),
279 null, // self::ICON_PEAR - Icon not supported in native PowerShell console
280 $shell,
281 Path::getModuleSymlinkPath($bearsamppBins->getPhp()) . '/pear'
282 ) . PHP_EOL;
283 }

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 551 of file class.tpl.powershell.php.

552 {
553 global $bearsamppRoot, $bearsamppTools;
554
555 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppTools->getPerl()->getExe() . '"');
556 if (!file_exists($bearsamppTools->getPerl()->getExe())) {
557 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getPerl()->getExe() . ' not found');
558 }
559
560 return self::getTab(
561 $bearsamppTools->getPowerShell()->getTabTitlePerl(),
562 null, // self::ICON_PERL - Icon not supported in native PowerShell console
563 $shell,
565 ) . PHP_EOL;
566 }

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 360 of file class.tpl.powershell.php.

361 {
362 global $bearsamppBins, $bearsamppTools;
363
364 $shell = $bearsamppTools->getPowerShell()->getShell(
365 '"' . $bearsamppBins->getPostgresql()->getCliExe() . '"' .
366 ' -h ' . APP_LOCALHOST .
367 ' -p ' . $bearsamppBins->getPostgresql()->getPort() .
368 ' -U ' . $bearsamppBins->getPostgresql()->getRootUser() .
369 ' -d postgres'
370 );
371 if (!file_exists($bearsamppBins->getPostgresql()->getCliExe())) {
372 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppBins->getPostgresql()->getCliExe() . ' not found');
373 }
374
375 return self::getTab(
376 $bearsamppTools->getPowerShell()->getTabTitlePostgresql(),
377 null, // self::ICON_DB - Icon not supported in native PowerShell console
378 $shell,
380 ) . PHP_EOL;
381 }
const APP_LOCALHOST
Definition root.php:21

References $bearsamppBins, APP_LOCALHOST, 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 240 of file class.tpl.powershell.php.

241 {
242 global $bearsamppRoot, $bearsamppTools;
243
244 $powerShellPath = Path::getPowerShellPath();
245 if ($powerShellPath !== false) {
246 return self::getTab(
247 $bearsamppTools->getPowerShell()->getTabTitlePowershell(),
248 null, // self::ICON_POWERSHELL - Icon not supported in native PowerShell console
249 $powerShellPath,
251 ) . PHP_EOL;
252 }
253
254 return "";
255 }
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 479 of file class.tpl.powershell.php.

480 {
481 global $bearsamppRoot, $bearsamppTools;
482
483 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $bearsamppTools->getPython()->getExe() . '"');
484 if (!file_exists($bearsamppTools->getPython()->getExe())) {
485 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getPython()->getExe() . ' not found');
486 }
487
488 return self::getTab(
489 $bearsamppTools->getPowerShell()->getTabTitlePython(),
490 null, // self::ICON_PYTHON - Icon not supported in native PowerShell console
491 $shell,
493 ) . PHP_EOL;
494 }

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 507 of file class.tpl.powershell.php.

508 {
509 global $bearsamppRoot, $bearsamppTools;
510
511 // Check if Ruby exists first
512 if (!file_exists($bearsamppTools->getRuby()->getExe())) {
513 $shell = $bearsamppTools->getPowerShell()->getShell('echo ' . $bearsamppTools->getRuby()->getExe() . ' not found');
514 } else {
515 // Use irb (Interactive Ruby) for an interactive shell
516 $rubyDir = dirname($bearsamppTools->getRuby()->getExe());
517 $irbExe = $rubyDir . '/irb.bat';
518
519 // Check if irb.bat exists, otherwise try irb.cmd or just use ruby with -i flag
520 if (file_exists($irbExe)) {
521 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $irbExe . '"');
522 } elseif (file_exists($rubyDir . '/irb.cmd')) {
523 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $rubyDir . '/irb.cmd' . '"');
524 } elseif (file_exists($rubyDir . '/irb')) {
525 $shell = $bearsamppTools->getPowerShell()->getShell('"' . $rubyDir . '/irb' . '"');
526 } else {
527 // Fallback to just opening a shell in the Ruby directory
528 $shell = $bearsamppTools->getPowerShell()->getShell();
529 }
530 }
531
532 return self::getTab(
533 $bearsamppTools->getPowerShell()->getTabTitleRuby(),
534 null, // self::ICON_RUBY - Icon not supported in native PowerShell console
535 $shell,
537 ) . PHP_EOL;
538 }

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 188 of file class.tpl.powershell.php.

189 {
190 return self::getTabCmdSection() .
204 }
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. It writes the console font settings for the PowerShell window titles to the Windows registry and imports them.

Returns
bool True on success, false on failure.

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

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

Referenced by ActionReload\__construct().

Here is the caller graph for this function:

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