diff --git a/src/canvas.sh b/src/canvas.sh index 6848b385..301fcfe4 100644 --- a/src/canvas.sh +++ b/src/canvas.sh @@ -655,7 +655,7 @@ function ble/canvas/trace/.process-csi-sequence { return ;; ([ABCDEFGIZ\`ade]) local arg=0 - [[ $param =~ ^[0-9]+$ ]] && arg=$param + [[ $param =~ ^[0-9]+$ ]] && ((arg=10#$param)) ((arg==0&&(arg=1))) local x0=$x y0=$y @@ -730,6 +730,7 @@ function ble/canvas/trace/.process-csi-sequence { # HVP "CSI f" local -a params ble/string#split-words params "${param//[^0-9]/ }" + params=("${params[@]/#/10#}") local x1 y1 ((x1=params[1]-1)) ((y1=params[0]-1)) diff --git a/src/decode.sh b/src/decode.sh index e487dac4..bb3d84b4 100644 --- a/src/decode.sh +++ b/src/decode.sh @@ -560,19 +560,23 @@ function ble-decode-char/csi/.modify-key { function ble-decode-char/csi/.decode { local char=$1 rex key if ((char==126)); then - if rex='^27;([1-9][0-9]*);?([1-9][0-9]*)$' && [[ $_ble_decode_csi_args =~ $rex ]]; then + if rex='^>?27;([0-9]+);?([0-9]+)$' && [[ $_ble_decode_csi_args =~ $rex ]]; then # xterm "CSI 2 7 ; ; ~" sequences - local key=$((BASH_REMATCH[2]&_ble_decode_MaskChar)) - ble-decode-char/csi/.modify-key "${BASH_REMATCH[1]}" + local param1=$((10#${BASH_REMATCH[1]})) + local param2=$((10#${BASH_REMATCH[2]})) + local key=$((param2&_ble_decode_MaskChar)) + ble-decode-char/csi/.modify-key "$param1" csistat=$key return fi - if rex='^([1-9][0-9]*)(;([1-9][0-9]*))?$' && [[ $_ble_decode_csi_args =~ $rex ]]; then + if rex='^>?([0-9]+)(;([0-9]+))?$' && [[ $_ble_decode_csi_args =~ $rex ]]; then # "CSI ; ~" sequences - key=${_ble_decode_csimap_tilde[BASH_REMATCH[1]]} + local param1=$((10#${BASH_REMATCH[1]})) + local param3=$((10#${BASH_REMATCH[3]})) + key=${_ble_decode_csimap_tilde[param1]} if [[ $key ]]; then - ble-decode-char/csi/.modify-key "${BASH_REMATCH[3]}" + ble-decode-char/csi/.modify-key "$param3" csistat=$key return fi @@ -583,20 +587,22 @@ function ble-decode-char/csi/.decode { # Note: 実は "CSI 1 ; mod u" が kp5 とする端末がある事に注意する。 local rematch1=${BASH_REMATCH[1]} if [[ $rematch1 != 1 ]]; then - local key=$rematch1 mods=${BASH_REMATCH:${#rematch1}+1} + local key=$((10#$rematch1)) mods=$((10#${BASH_REMATCH:${#rematch1}+1})) ble-decode-char/csi/.modify-key "$mods" csistat=$key fi return fi - elif ((char==94||char==64)); then - if rex='^[1-9][0-9]*$' && [[ $_ble_decode_csi_args =~ $rex ]]; then + elif ((char==94||char==64)); then # ^, @ + if rex='^[0-9]+$' && [[ $_ble_decode_csi_args =~ $rex ]]; then # rxvt "CSI ^", "CSI @" sequences - key=${_ble_decode_csimap_tilde[BASH_REMATCH[1]]} + local param1=$((10#${BASH_REMATCH[1]})) + local param3=$((10#${BASH_REMATCH[3]})) + key=${_ble_decode_csimap_tilde[param1]} if [[ $key ]]; then ((key|=_ble_decode_Ctrl, char==64&&(key|=_ble_decode_Shft))) - ble-decode-char/csi/.modify-key "${BASH_REMATCH[3]}" + ble-decode-char/csi/.modify-key "$param3" csistat=$key return fi @@ -617,19 +623,22 @@ function ble-decode-char/csi/.decode { if rex='^([0-9]+);([0-9]+)$'; [[ $_ble_decode_csi_args =~ $rex ]]; then # DSR(6) に対する応答 CPR "CSI Pn ; Pn R" # Note: Poderosa は DSR(Pn;Pn) "CSI Pn ; Pn n" で返す。 - ble/term/CPR/notify $((10#${BASH_REMATCH[1]})) $((10#${BASH_REMATCH[2]})) + local param1=$((10#${BASH_REMATCH[1]})) + local param2=$((10#${BASH_REMATCH[2]})) + ble/term/CPR/notify "$param1" "$param2" csistat=$_ble_decode_KCODE_IGNORE - return + return 0 fi fi # pc-style "CSI 1; A" sequences key=${_ble_decode_csimap_alpha[char]} if [[ $key ]]; then - if rex='^(1?|1;([1-9][0-9]*))$' && [[ $_ble_decode_csi_args =~ $rex ]]; then - ble-decode-char/csi/.modify-key "${BASH_REMATCH[2]}" + if rex='^(1?|>?1;([0-9]+))$' && [[ $_ble_decode_csi_args =~ $rex ]]; then + local param2=$((10#${BASH_REMATCH[2]})) + ble-decode-char/csi/.modify-key "$param2" csistat=$key - return + return 0 fi fi