File Manager Lite
Dir:
/home/codewavebd/public_html/vendor/psy/psysh/src/Readline/Interactive/Actions
Upload
[..]
AcceptSuggestionAction.php (1.12 KB)
Edit
Rename
Del
AcceptSuggestionWordAction.php (1.43 KB)
Edit
Rename
Del
ActionInterface.php (848 B)
Edit
Rename
Del
ClearBufferAction.php (2.12 KB)
Edit
Rename
Del
ClearScreenAction.php (975 B)
Edit
Rename
Del
DedentLeadingIndentationAction.php (1.99 KB)
Edit
Rename
Del
DeleteBackwardCharAction.php (818 B)
Edit
Rename
Del
DeleteBracketPairAction.php (1016 B)
Edit
Rename
Del
ExitIfEmptyAction.php (965 B)
Edit
Rename
Del
ExpandHistoryOnTabAction.php (1.41 KB)
Edit
Rename
Del
HistoryExpansionAction.php (9.65 KB)
Edit
Rename
Del
InsertCloseBracketAction.php (2.26 KB)
Edit
Rename
Del
InsertIndentOnTabAction.php (1.23 KB)
Edit
Rename
Del
InsertLineBreakOnIncompleteStatementAction.php (1.53 KB)
Edit
Rename
Del
InsertQuoteAction.php (1.3 KB)
Edit
Rename
Del
KillLineAction.php (801 B)
Edit
Rename
Del
KillWholeLineAction.php (816 B)
Edit
Rename
Del
KillWordAction.php (803 B)
Edit
Rename
Del
MoveRightAction.php (793 B)
Edit
Rename
Del
MoveToStartAction.php (1.33 KB)
Edit
Rename
Del
MoveWordLeftAction.php (880 B)
Edit
Rename
Del
MoveWordRightAction.php (875 B)
Edit
Rename
Del
NextHistoryAction.php (1.74 KB)
Edit
Rename
Del
PreviousHistoryAction.php (2.12 KB)
Edit
Rename
Del
RejectSyntaxErrorAction.php (2.23 KB)
Edit
Rename
Del
ReverseSearchAction.php (1.21 KB)
Edit
Rename
Del
TabAction.php (16.99 KB)
Edit
Rename
Del
Edit: InsertCloseBracketAction.php
<?php /* * This file is part of Psy Shell. * * (c) 2012-2026 Justin Hileman * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Psy\Readline\Interactive\Actions; use Psy\Readline\Interactive\Helper\BracketPair; use Psy\Readline\Interactive\Input\Buffer; use Psy\Readline\Interactive\Readline; use Psy\Readline\Interactive\Terminal; /** * Insert a closing bracket with skip-over logic. */ class InsertCloseBracketAction implements ActionInterface { private string $bracket; public function __construct(string $bracket) { $this->bracket = $bracket; } /** * {@inheritdoc} */ public function execute(Buffer $buffer, Terminal $terminal, Readline $readline): bool { if (BracketPair::shouldSkipOver($this->bracket, $buffer)) { if ($this->shouldDedent($buffer)) { $this->dedentAndSkip($buffer); } else { $buffer->moveCursorRight(1); } } else { $buffer->autoDedentIfClosingBracket($this->bracket, $buffer->getBeforeCursor()); $buffer->insert($this->bracket); } return true; } /** * Check if we should dedent when typing a closing bracket. * * Dedent when: * - Cursor is before the closing bracket * - Current line only has whitespace before the cursor * - We're in multi-line mode */ private function shouldDedent(Buffer $buffer): bool { $currentLine = $buffer->getCurrentLineText(); $cursorInLine = $buffer->getCursorPositionInLine(); $textBeforeCursor = \mb_substr($currentLine, 0, $cursorInLine); return \trim($textBeforeCursor) === '' && \strpos($buffer->getText(), "\n") !== false; } /** * Dedent by removing indentation before the closing bracket. * * Keeps the closing bracket on its own line but removes the indentation. */ private function dedentAndSkip(Buffer $buffer): void { $buffer->deleteBackward($buffer->getCursorPositionInLine()); $buffer->moveCursorRight(1); } /** * {@inheritdoc} */ public function getName(): string { return 'insert-close-bracket'; } }
Simpan