From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2528 invoked from network); 3 Sep 2001 09:51:07 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 3 Sep 2001 09:51:07 -0000 Received: (qmail 18084 invoked by alias); 3 Sep 2001 09:50:58 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 15736 Received: (qmail 18073 invoked from network); 3 Sep 2001 09:50:57 -0000 Subject: Re: Tetris In-Reply-To: from Wayne Davison at "Sep 2, 2001 11:08:54 pm" To: zsh-workers@sunsite.dk Date: Mon, 3 Sep 2001 10:50:56 +0100 (BST) X-Mailer: ELM [version 2.4ME+ PL66 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: From: Zefram Wayne Davison wrote: > setopt localoptions unset Ah, I thought I'd written it for zsh native mode, but there I actually wrote it for my interactive setup. Here's the proper fix. --- tetris.zsh Mon Sep 3 01:45:35 2001 +++ tetris.zsh Mon Sep 3 10:46:46 2001 @@ -23,6 +23,7 @@ zle -N tetris function tetris { + emulate -L zsh tetris_save_buffer=$BUFFER tetris_save_cursor=$CURSOR local i @@ -44,6 +45,7 @@ } function tetris-new-block { + emulate -L zsh tetris_block=$tetris_shapes[1+RANDOM%$#tetris_shapes] tetris_block_y=0 tetris_block_x=4 @@ -59,6 +61,7 @@ zle -N tetris-left function tetris-left { + emulate -L zsh tetris-place-block " " (( tetris_block_x-- )) tetris-block-fits || (( tetris_block_x++ )) @@ -68,6 +71,7 @@ zle -N tetris-right function tetris-right { + emulate -L zsh tetris-place-block " " (( tetris_block_x++ )) tetris-block-fits || (( tetris_block_x-- )) @@ -77,6 +81,7 @@ zle -N tetris-rotate function tetris-rotate { + emulate -L zsh tetris-place-block " " local save_block=$tetris_block tetris_block=$tetris_rotations[$tetris_block] @@ -87,6 +92,7 @@ zle -N tetris-drop function tetris-drop { + emulate -L zsh tetris-place-block " " ((tetris_block_y++)) while tetris-block-fits; do @@ -98,6 +104,7 @@ zle -N tetris-timeout function tetris-timeout { + emulate -L zsh tetris-place-block " " ((tetris_block_y++)) if tetris-block-fits; then @@ -110,6 +117,7 @@ } function tetris-block-dropped { + emulate -L zsh tetris-place-block "O" local fl=${tetris_blankline// /O} i=$((tetris_block_y*tetris_hsz)) y for ((y=0; y!=4; y++)); do @@ -124,6 +132,7 @@ } function tetris-block-fits { + emulate -L zsh local y x i=$((1+tetris_block_y*tetris_hsz+tetris_block_x)) b=0x8000 for ((y=0; y!=4; y++)); do for ((x=0; x!=4; x++)); do @@ -143,6 +152,7 @@ } function tetris-place-block { + emulate -L zsh local y x i=$((1+tetris_block_y*tetris_hsz+tetris_block_x)) b=0x8000 for ((y=0; y!=4; y++)); do for ((x=0; x!=4; x++)); do @@ -155,6 +165,7 @@ } function tetris-render-screen { + emulate -L zsh local s i extras extras=( "Score: $tetris_score" @@ -164,7 +175,7 @@ ) for ((i=0; i!=tetris_vsz; i++)); do s="$s|${tetris_board[1+i*tetris_hsz,(i+1)*tetris_hsz]}|" - s=$s" "$extras[1]$'\n' + s=$s${extras[1]+ $extras[1]}$'\n' extras[1]=() done s="$s+${tetris_blankline// /-}+" @@ -172,6 +183,7 @@ } function tetris-timed-move { + emulate -L zsh tetris-render-screen LBUFFER= RBUFFER=$'\n'$tetris_screen @@ -181,6 +193,7 @@ zle -N tetris-quit function tetris-quit { + emulate -L zsh if [[ ! -o always_last_prompt ]]; then BUFFER= zle -M $tetris_screen