Skip to content

Commit

Permalink
util: support Haiku
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jan 11, 2020
1 parent 90ad15b commit 4417861
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/init-cmap.sh
Expand Up @@ -95,7 +95,7 @@ function ble/init:cmap/initialize {
ble-decode-kbd/generate-keycode end
ble-decode-kbd/generate-keycode next

local kend; ble/util/assign kend 'tput kend'
local kend; ble/util/assign kend 'tput @7 2>/dev/null || tput kend 2>/dev/null'
if [[ $kend == $'\e[5~' ]]; then
# vt100
ble-bind --csi '1~' insert
Expand Down
39 changes: 25 additions & 14 deletions src/util.sh
Expand Up @@ -1159,7 +1159,7 @@ if ((_ble_bash>=40400)) && ble/util/msleep/.check-builtin-sleep; then
_ble_util_msleep_builtin_available=1
_ble_util_msleep_delay=300
function ble/util/msleep/.core { builtin sleep "$1"; }
elif ((_ble_bash>=40000)); then
elif ((_ble_bash>=40000)) && [[ $OSTYPE != haiku* ]]; then
if [[ $OSTYPE == cygwin* ]]; then
_ble_util_msleep_delay1=10000 # short msleep にかかる時間 [usec]
_ble_util_msleep_delay2=50000 # /bin/sleep 0 にかかる時間 [usec]
Expand Down Expand Up @@ -2595,10 +2595,6 @@ function ble/term/visible-bell/cancel-erasure {

#---- stty --------------------------------------------------------------------

## 変数 _ble_term_stty_state
## 現在 stty で制御文字の効果が解除されているかどうかを保持します。
_ble_term_stty_state=

# 改行 (C-m, C-j) の取り扱いについて
# 入力の C-m が C-j に勝手に変換されない様に -icrnl を指定する必要がある。
# (-nl の設定の中に icrnl が含まれているので、これを取り消さなければならない)
Expand All @@ -2610,24 +2606,40 @@ _ble_term_stty_state=
# その場で入力を受信する事ができない。結果として hang した様に見える。
# 従って、enter で -icanon を設定する事にする。

## 変数 _ble_term_stty_state
## 現在 stty で制御文字の効果が解除されているかどうかを保持します。
_ble_term_stty_state=
_ble_term_stty_flags_enter=(kill undef erase undef intr undef quit undef susp undef)
_ble_term_stty_flags_leave=(kill '' erase '' intr '' quit '' susp '')
function ble/term/stty/.initialize-flags {
local stty; ble/util/assign stty 'stty -a'
# lnext, werase は POSIX にはないのでチェックする
if [[ $stty == *' lnext '* ]]; then
ble/array#push _ble_term_stty_flags_enter lnext undef
ble/array#push _ble_term_stty_flags_leave lnext ''
fi
if [[ $stty == *' werase '* ]]; then
ble/array#push _ble_term_stty_flags_enter werase undef
ble/array#push _ble_term_stty_flags_leave werase ''
fi
}
ble/term/stty/.initialize-flags

function ble/term/stty/initialize {
ble/bin/stty -ixon -echo -nl -icrnl -icanon \
kill undef lnext undef werase undef erase undef \
intr undef quit undef susp undef
"${_ble_term_stty_flags_enter[@]}"
_ble_term_stty_state=1
}
function ble/term/stty/leave {
[[ ! $_ble_term_stty_state ]] && return
ble/bin/stty echo -nl icanon \
kill '' lnext '' werase '' erase '' \
intr '' quit '' susp ''
ble/bin/stty echo -nl icanon \
"${_ble_term_stty_flags_leave[@]}"
_ble_term_stty_state=
}
function ble/term/stty/enter {
[[ $_ble_term_stty_state ]] && return
ble/bin/stty -echo -nl -icrnl -icanon \
kill undef lnext undef werase undef erase undef \
intr undef quit undef susp undef
"${_ble_term_stty_flags_enter[@]}"
_ble_term_stty_state=1
}
function ble/term/stty/finalize {
Expand All @@ -2636,8 +2648,7 @@ function ble/term/stty/finalize {
function ble/term/stty/TRAPEXIT {
# exit の場合は echo
ble/bin/stty echo -nl \
kill '' lnext '' werase '' erase '' \
intr '' quit '' susp ''
"${_ble_term_stty_flags_leave[@]}"
}


Expand Down

0 comments on commit 4417861

Please sign in to comment.