/****************************************************
 * vt100 emulator
 *
 *	     Oct 86 TAW - removed Busy polling, & other bug fixes
 *           860823 DBW - Integrated and rewrote lots of code
 *      v2.0 860809 DBW - Major rewrite
 *      v1.1 860720 DBW - Switches, 80 cols, colors, bug fixes
 *      v1.0 860712 DBW - First version released
 *
 ****************************************************/

#include "vt100.h"

/*************************************************
*  function to get file name
*************************************************/
void filename(name)
char name[];
    {
    char c;
    ULONG class;
    unsigned int code;
    int keepgoing,i;
    keepgoing = TRUE;
    i=0;
    while (keepgoing) {
        cursoron();
    	Wait ( 1<< mywindow->UserPort->mp_SigBit);
        while( NewMessage=(struct IntuiMessage *)GetMsg(mywindow->UserPort)){
            class = NewMessage->Class;
            code = NewMessage->Code;
            ReplyMsg( NewMessage );
            cursoroff();
            if (class==RAWKEY) {
                c = toasc(code,1);
                if (c == 0) ;
                else if (c == 13) {
                     name[i] = 0;
                     keepgoing = FALSE;
                     }
                else if (c == 8 || c == 127) {
                   if (i != 0) {
                      i--;
                      emit(8);
                      emit(32);
                      emit(8);
                      }
                   }
                else {
                  emit(c);
	          name[i++] = c;
                  }

            } /* end of class == */
          } /* end of GetMsg */
    }   /* end of keepgoing loop */
    emit(13);
    emit(10);
    } /* end of function */
