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

593 {
594 global $bearsamppCore;
595 // Icon parameter is ignored as native PowerShell console does not support custom icons
596 // Return tab information as a formatted string
597 return "Title: $title | Shell: $shell | InitDir: $initDir";
598 }
global $bearsamppCore

References $bearsamppCore.

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

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

171 {
172 global $bearsamppRoot, $bearsamppTools;
173
174 return self::getTab(
175 $bearsamppTools->getPowerShell()->getTabTitleDefault(),
176 null, // self::ICON_APP - Icon not supported in native PowerShell console
177 $bearsamppTools->getPowerShell()->getShell(),
178 $bearsamppRoot->getRootPath()
179 ) . PHP_EOL;
180 }
global $bearsamppRoot
static getTab($title, $icon, $shell, $initDir)

References $bearsamppRoot, and getTab().

Referenced by getTabsSection().

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

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

References $bearsamppRoot, and getTab().

Referenced by getTabsSection().

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

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

References $bearsamppRoot, and getTab().

Referenced by getTabsSection().

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

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

References $bearsamppRoot, and getTab().

Referenced by getTabsSection().

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

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

References $bearsamppBins, and getTab().

Referenced by getTabsSection().

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

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

References $bearsamppBins, and getTab().

Referenced by getTabsSection().

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

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

References $bearsamppRoot, and getTab().

Referenced by getTabsSection().

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

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

References $bearsamppBins, $bearsamppRoot, and getTab().

Referenced by getTabsSection().

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

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

References $bearsamppBins, and getTab().

Referenced by getTabsSection().

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

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

References $bearsamppRoot, and getTab().

Referenced by getTabsSection().

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

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

References $bearsamppBins, and getTab().

Referenced by getTabsSection().

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

194 {
195 global $bearsamppRoot, $bearsamppTools;
196
197 $powerShellPath = Util::getPowerShellPath();
198 if ($powerShellPath !== false) {
199 return self::getTab(
200 $bearsamppTools->getPowerShell()->getTabTitlePowershell(),
201 null, // self::ICON_POWERSHELL - Icon not supported in native PowerShell console
202 $powerShellPath,
203 $bearsamppRoot->getRootPath()
204 ) . PHP_EOL;
205 }
206
207 return "";
208 }
static getPowerShellPath()

References $bearsamppRoot, Util\getPowerShellPath(), and getTab().

Referenced by getTabsSection().

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

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

References $bearsamppRoot, and getTab().

Referenced by getTabsSection().

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

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

References $bearsamppRoot, and getTab().

Referenced by getTabsSection().

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

142 {
143 return self::getTabCmdSection() .
157 }
static getTabGhostscriptSection()

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

◆ 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 $output = [];
120 $exitCode = 0;
121 exec($cmd, $output, $exitCode);
122
123 @unlink($tmpReg);
124
125 if ($exitCode !== 0) {
126 return false;
127 }
128
129 return true;
130 }

Referenced by ActionReload\__construct().


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