Fix scrolling in MessageBox, file overwrite confirmation
This commit is contained in:
parent
7a37ebe234
commit
29d070c305
@ -402,6 +402,16 @@ class Editor
|
||||
if (!$saveTo) {
|
||||
return false;
|
||||
}
|
||||
if (file_exists($saveTo)) {
|
||||
$overwrite = (new Menu($this->term, [
|
||||
'overwrite' => "Overwrite the file",
|
||||
'abort' => "Abort"
|
||||
], "The file exists"))->display(0, 0, 30, 0, '');
|
||||
if ($overwrite == 'abort') {
|
||||
$this->redrawEditor();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$doc = $this->document->save();
|
||||
|
||||
@ -958,7 +968,7 @@ Welcome to JSONEdit! The editor you never knew you were missing!
|
||||
|
||||
# QuickStart
|
||||
|
||||
To get started, press I (shift-i) and add something to the document. Use the arrow keys to get around. To cancel a prompt, close a menu or close a dialog, press ctrl-C. When you are happy with your work, press ctrl-W and enter a filename to write. You can also press ctrl-R and read in a new file, overwriting your masterpiece.
|
||||
To get started, press I (shift-i) and add something to the document. Use the arrow keys to get around. To cancel a prompt, close a menu or close a dialog, press ctrl-C. When you are happy with your work, press ctrl-W and enter a filename to write. You can also press ctrl-O to browse for a file to open.
|
||||
|
||||
# Useful keys
|
||||
|
||||
|
@ -20,7 +20,7 @@ class MessageBox
|
||||
const U_EDGE_HORIZONTAL = "\u{2500}";
|
||||
|
||||
const U_EDGE_VERTICAL = "\u{2502}";
|
||||
const U_EDGE_VERTICAL_SCROLL = "\u{2591}";
|
||||
const U_EDGE_VERTICAL_SCROLL = "\u{2593}";
|
||||
const U_EDGE_VERTICAL_THUMB = "\u{2593}";
|
||||
const U_EDGE_VERTICAL_LEFT = "\u{2524}";
|
||||
const U_EDGE_VERTICAL_RIGHT = "\u{251c}";
|
||||
@ -76,14 +76,36 @@ class MessageBox
|
||||
$showing = false;
|
||||
}
|
||||
} else {
|
||||
if ($ch == "k{UP}") {
|
||||
switch ($ch) {
|
||||
case "k{UP}":
|
||||
$this->scroll--;
|
||||
if ($this->scroll < 0) $this->scroll = 0;
|
||||
$this->redraw($left, $top, $width, $height, $wrapped, $this->title, $maxScroll);
|
||||
} elseif ($ch == "k{DOWN}") {
|
||||
break;
|
||||
case "k{DOWN}":
|
||||
$this->scroll++;
|
||||
if ($this->scroll > $maxScroll) $this->scroll = $maxScroll;
|
||||
$this->redraw($left, $top, $width, $height, $wrapped, $this->title, $maxScroll);
|
||||
break;
|
||||
case "k{PGUP}":
|
||||
$this->scroll -= $height - 2;
|
||||
if ($this->scroll < 0) $this->scroll = 0;
|
||||
$this->redraw($left, $top, $width, $height, $wrapped, $this->title, $maxScroll);
|
||||
break;
|
||||
case "k{PGDN}":
|
||||
$this->scroll += $height - 2;
|
||||
if ($this->scroll >= $maxScroll) $this->scroll = $maxScroll;
|
||||
$this->redraw($left, $top, $width, $height, $wrapped, $this->title, $maxScroll);
|
||||
break;
|
||||
case "k{HOME}":
|
||||
$this->scroll = 0;
|
||||
if ($this->scroll >= count($wrapped)) $this->scroll = 0;
|
||||
$this->redraw($left, $top, $width, $height, $wrapped, $this->title, $maxScroll);
|
||||
break;
|
||||
case "k{END}":
|
||||
$this->scroll = $maxScroll;
|
||||
$this->redraw($left, $top, $width, $height, $wrapped, $this->title, $maxScroll);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -154,7 +176,7 @@ class MessageBox
|
||||
if ($n >= $thumbTop && $n <= $thumbBottom) {
|
||||
$scrollbar = "\e[97;1m".self::U_EDGE_VERTICAL_THUMB."\e[40;37;22m";
|
||||
} else {
|
||||
$scrollbar = "\e[37;2m".self::U_EDGE_VERTICAL_SCROLL."\e[40;37;22m";
|
||||
$scrollbar = "\e[30;2m".self::U_EDGE_VERTICAL_SCROLL."\e[40;37;22m";
|
||||
}
|
||||
$this->terminal
|
||||
->writeAt($left, $top + 3 + $n, self::U_EDGE_VERTICAL.$item.$scrollbar);
|
||||
|
Loading…
Reference in New Issue
Block a user