Inform - Support - Source

Back to List

Inventory
Complete

Backward
Forward

Plain
Coloured
Gaudy

This code
in plain text

Browsing parserm.h

Keyboard (lines 609-729)

0609  [ Keyboard  a_buffer a_table  nw i w w2 x1 x2;
0610   
0611      DisplayStatus();
0612      .FreshInput;
0613   
0614  !  Save the start of the buffer, in case "oops" needs to restore it
0615  !  to the previous time's buffer
0616   
0617      for (i=0:i<64:i++) oops_workspace->i = a_buffer->i;
0618   
0619  !  In case of an array entry corruption that shouldn't happen, but would be
0620  !  disastrous if it did:
0621   
0622     a_buffer->0 = 120;
0623     a_table->0 = 15;  ! Allow to split input into this many words
0624   
0625  !  Print the prompt, and read in the words and dictionary addresses
0626   
0627      L__M(##Prompt);
0628      AfterPrompt();
0629      #IFV5; DrawStatusLine(); #ENDIF;
0630      KeyboardPrimitive(a_buffer, a_table);
0631      nw=a_table->1;
0632   
0633  !  If the line was blank, get a fresh line
0634      if (nw == 0)
0635      { L__M(##Miscellany,10); jump FreshInput; }
0636   
0637  !  Unless the opening word was "oops", return
0638   
0639      w=a_table-->1;
0640      if (w == OOPS1__WD or OOPS2__WD or OOPS3__WD) jump DoOops;
0641   
0642  #IFV5;
0643  !  Undo handling
0644   
0645      if ((w == UNDO1__WD or UNDO2__WD or UNDO3__WD) && (parse->1==1))
0646      {   if (turns==1)
0647          {   L__M(##Miscellany,11); jump FreshInput;
0648          }
0649          if (undo_flag==0)
0650          {   L__M(##Miscellany,6); jump FreshInput;
0651          }
0652          if (undo_flag==1) jump UndoFailed;
0653          if (just_undone==1)
0654          {   L__M(##Miscellany,12); jump FreshInput;
0655          }
0656          @restore_undo i;
0657          if (i==0)
0658          {   .UndoFailed;
0659              L__M(##Miscellany,7);
0660          }
0661          jump FreshInput;
0662      }
0663      @save_undo i;
0664      just_undone=0;
0665      undo_flag=2;
0666      if (i==-1) undo_flag=0;
0667      if (i==0) undo_flag=1;
0668      if (i==2)
0669      {   style bold;
0670          print (name) location, "^";
0671          style roman;
0672          L__M(##Miscellany,13);
0673          just_undone=1;
0674          jump FreshInput;
0675      }
0676  #ENDIF;
0677   
0678      return nw;
0679   
0680      .DoOops;
0681      if (oops_from == 0)
0682      {   L__M(##Miscellany,14); jump FreshInput; }
0683      if (nw == 1)
0684      {   L__M(##Miscellany,15); jump FreshInput; }
0685      if (nw > 2)
0686      {   L__M(##Miscellany,16); jump FreshInput; }
0687   
0688  !  So now we know: there was a previous mistake, and the player has
0689  !  attempted to correct a single word of it.
0690   
0691      for (i=0:i<=120:i++) buffer2->i = a_buffer->i;
0692      x1 = a_table->9; ! Start of word following "oops"
0693      x2 = a_table->8; ! Length of word following "oops"
0694   
0695  !  Repair the buffer to the text that was in it before the "oops"
0696  !  was typed:
0697   
0698      for (i=0:i<64:i++) a_buffer->i = oops_workspace->i;
0699      Tokenise__(a_buffer,a_table);
0700   
0701  !  Work out the position in the buffer of the word to be corrected:
0702   
0703      w = a_table->(4*oops_from + 1); ! Start of word to go
0704      w2 = a_table->(4*oops_from);    ! Length of word to go
0705   
0706  !  Write spaces over the word to be corrected:
0707   
0708      for (i=0:i<w2:i++) a_buffer->(i+w) = ' ';
0709   
0710      if (w2 < x2)
0711      {   ! If the replacement is longer than the original, move up...
0712   
0713          for (i=120:i>=w+x2:i--)
0714              a_buffer->i = a_buffer->(i-x2+w2);
0715   
0716          ! ...increasing buffer size accordingly.
0717   
0718          a_buffer->1 = (a_buffer->1) + (x2-w2);
0719      }
0720   
0721  !  Write the correction in:
0722   
0723      for (i=0:i<x2:i++) a_buffer->(i+w) = buffer2->(i+x1);
0724   
0725      Tokenise__(a_buffer,a_table);
0726      nw=a_table->1;
0727   
0728      return nw;
0729  ];


Last updated 27 February 2004. This web site has not been fully supported since April 2008. Information may be out of date. This page was originally managed by Graham Nelson (graham@gnelson.demon.co.uk) assisted by C Knight.