Skip to content

Commit

Permalink
edit: work around problems with "mc"
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Dec 2, 2020
1 parent 6bbed24 commit 15111cf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
9 changes: 9 additions & 0 deletions ble-core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,15 @@ function _ble_util_string_prototype.reserve {
_ble_util_string_prototype="$_ble_util_string_prototype$_ble_util_string_prototype"
done
}
## 関数 ble/string#repeat str count
## @param[in] str
## @param[in] count
## @var[out] ret
function ble/string#repeat {
_ble_util_string_prototype.reserve "$2"
ret=${_ble_util_string_prototype::$2}
ret="${ret// /$1}"
}

function ble/string#common-prefix {
local a="$1" b="$2"
Expand Down
20 changes: 19 additions & 1 deletion ble-edit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ function ble-edit/draw/put.dl {
DRAW_BUFF[${#DRAW_BUFF[*]}]=$_ble_term_el2 # Note #D1214: 最終行対策 cygwin, linux
DRAW_BUFF[${#DRAW_BUFF[*]}]="${_ble_term_dl//'%d'/$value}"
}
function ble-edit/draw/put.ind {
local -i count=${1-1}
local ret; ble/string#repeat "${_ble_term_ind}" "$count"
DRAW_BUFF[${#DRAW_BUFF[*]}]=$ret
}
function ble-edit/draw/put.cuu {
local -i value="${1-1}"
DRAW_BUFF[${#DRAW_BUFF[*]}]="${_ble_term_cuu//'%d'/$value}"
Expand Down Expand Up @@ -1796,12 +1801,25 @@ function .ble-edit/edit/detach {
## プロンプト原点が x=0 y=0 に対応します。
function ble-edit/draw/goto {
local -i x="$1" y="$2"

# Note #D1392: mc (midnight commander) は
# sgr0 単体でもプロンプトと勘違いするので、
# プロンプト更新もカーソル移動も不要の時は、
# sgr0 も含めて何も出力しない。
((x==_ble_line_x&&y==_ble_line_y)) && return 0

ble-edit/draw/put "$_ble_term_sgr0"

local -i dy=y-_ble_line_y
if ((dy!=0)); then
if ((dy>0)); then
ble-edit/draw/put "${_ble_term_cud//'%d'/$dy}"
if [[ $MC_SID == $$ ]]; then
# Note #D1392: mc (midnight commander) の中だと layout が破壊されるので、
# 必ずしも CUD で想定した行だけ移動できると限らない。
ble-edit/draw/put.ind "$dy"
else
ble-edit/draw/put "${_ble_term_cud//'%d'/$dy}"
fi
else
ble-edit/draw/put "${_ble_term_cuu//'%d'/$((-dy))}"
fi
Expand Down

0 comments on commit 15111cf

Please sign in to comment.