Beispiel #1
0
VOID Main( VOID )
	{
	BYTE AnzGerichte;
	BYTE Counter;
	WORD Code;

	ScrSetMode();
	ScrClr( SCRBACKGROUND );
	ScrSetCursor( 0, 25 );

	ScrWriteCenter( 0, 79, 2, Firma );
	ScrBoxChgColor( (BYTE)((78 - StdStrLen( Titel[0] )) / 2), 4,
			(BYTE)(79 - (78 - StdStrLen( Titel[0] )) / 2), 4,
			MARKTEXT );
    ScrWriteCenter( 0, 79, 4, Titel[0] );
    ScrWriteCenter( 0, 79, 5, Titel[1] );


    ScrWrite( XPATIENTENTITEL, YPATIENT, Patiententitel[0] );
	ScrWrite( XPATIENTENTITEL, (BYTE)(YPATIENT + 1), Patiententitel[1] );

    ScrWrite( 4, YGERICHT, Gerichtetitel[0] );
	ScrWrite( 4, (BYTE)(YGERICHT + 1), Gerichtetitel[1] );

	ScrBoxChgColor( (BYTE)(XPATIENTENTITEL - 1), YPATIENT, (BYTE)(XPATIENTENTITEL + StdStrLen( Patiententitel[0] )), YPATIENT, MARKTEXT );
    ScrSetCursor( XPATIENT, YPATIENT );
    Code = GetBarCode();

    while( Code != BEENDEN )
	{
	Code -= PATIENTENOFFSET;
	if( Code < ANZPATIENTEN )
	    {
	    ScrWrite( XPATIENT, YPATIENT, Patienten[Code] );
		ScrBoxChgColor( (BYTE)(XPATIENTENTITEL - 1), YPATIENT, (BYTE)(XPATIENTENTITEL + StdStrLen( Patiententitel[0] )), YPATIENT, SCRBACKGROUND );

	    AnzGerichte = 0;
		ScrBoxChgColor( (BYTE)(XGERICHTETITEL - 1), YGERICHT, (BYTE)(XGERICHTETITEL + StdStrLen( Gerichtetitel[0] )), YGERICHT, MARKTEXT );
	    ScrSetCursor( XGERICHT, YGERICHT );
	    Code = GetBarCode();

	    while( Code != BEENDEN )
		{
		Code -= GERICHTEOFFSET;
		if( Code < ANZGERICHTE )
		    if( AnzGerichte < ANZANZGERICHTE )
			{
			ScrWrite( XGERICHT, (BYTE)(YGERICHT + AnzGerichte), Gerichte[Code] );
			AnzGerichte++;
			ScrSetCursor( XGERICHT, (BYTE)(YGERICHT + AnzGerichte) );
			}

		Code = GetBarCode();
		}

		ScrBoxChgColor( (BYTE)(XGERICHTETITEL - 1), YGERICHT, (BYTE)(XGERICHTETITEL + StdStrLen( Gerichtetitel[0] )), YGERICHT, SCRBACKGROUND );

	    for( Counter = 0; Counter < ANZANZGERICHTE; Counter++ )
		ScrCharFill( XGERICHT, (BYTE)(YGERICHT + Counter), 40, SPACECHAR );

		ScrCharFill( XPATIENT, YPATIENT, 40, SPACECHAR );
		ScrBoxChgColor( (BYTE)(XPATIENTENTITEL - 1), YPATIENT, (BYTE)(XPATIENTENTITEL + StdStrLen( Patiententitel[0] )), YPATIENT, MARKTEXT );
	    ScrSetCursor( XPATIENT, YPATIENT );
	    }

	Code = GetBarCode();
	}

    ScrRestoreMode();
    }
Beispiel #2
0
/* At last: THE FUNCTION */
int ScrEnter(char *Prompt_Text, int Prompt_Attr, int Row, int Column,
              int Box_Attr, char *Text, char *Default_Text, int *Text_Length,
              int Text_Attr, int *Exit_Keys)
{
  int
    ch,                                  /* character just input            */
    Pos,                                 /* position in Text                */
    Index,                               /* index for shuffling elements    */
    Buffer_Size,                         /* size of the screen saving buffer*/
    Prompt_Length = strlen(Prompt_Text), /* length of the prompt            */
    Text_Start = Column+Prompt_Length+1, /* column text input starts at     */
    Text_Max = *Text_Length,             /* local variable for Text_Length  */
    Cur_Row, Cur_Col,                    /* old cursor coordinates          */
    Tmp = (Text_Max<0) ? 0 : 1,         /* for people who just want a key  */
    No_Prompt = Text_Max == 0;           /* for people who just want a box  */
  char
    *Save_Buffer;                        /* area for storing the space used */
  enum Ins_Mode
    Mode = Insert;                       /* what mode the user is in        */

  if (!Tmp) Text_Max = 0;
  if (!Text_Max) Text_Start -= 1;

  /* Store the current cursor position */
  ScrGetCursorPos (&Cur_Row, &Cur_Col);

  if (Box_Attr == NO_BOX) {
    /* Only save area used by prompt and text */
    Buffer_Size = Prompt_Length+Text_Max+2;
    Buffer_Size *= 2;
    Save_Buffer = (char *) malloc (Buffer_Size*sizeof(char));
    ScrRead (Row, Column, Prompt_Length+Text_Max+2, 1, Save_Buffer);
  }
  else {
    /* save whole area */
    Buffer_Size = (Prompt_Length+Text_Max+4) * 3;
    Buffer_Size *= 2;
    Save_Buffer = (char *) malloc (Buffer_Size*sizeof(char));
    ScrRead (Row-1, Column-1, Prompt_Length+Text_Max+4, 3, Save_Buffer);
    /* Draw the box if requested */
    ScrBox (Row-1, Column-1, Row+1, Column + Prompt_Length + Text_Max +
           1 - 2*No_Prompt + Tmp, Box_Attr);
  }

  /* Put the prompt where it belongs */
  ScrPrint (Row, Column, Prompt_Length, Prompt_Attr, Prompt_Text);

  /* Put up the default text */
  if (Text_Max) {
    ScrClear (Row, Text_Start - 1, Text_Max + Tmp + 1, 1, Text_Attr);
    ScrPrintText (Row, Text_Start, Text_Max, Default_Text);
  }

  /* Put the cursor at the end of the default text */
  Pos = strlen (Default_Text);
  if (Pos > Text_Max)
    Pos = Text_Max;
  ScrSetCursorPos(Row, Text_Start+Pos);

  if (!No_Prompt) {
  /* Initialize the array to 0's */
  for (Pos = 0; Pos <= Text_Max; Text[Pos++] = '\000');
  Pos = -1;

  /* Do the actual input of the string */
//  if (Mode == Replace)
//    ScrSetCursorSize (1,8);
//  else
//    ScrSetCursorSize (7,8);
//
// ScrSetCursorSize() is no longer supported in portscr, but it may be added
//   again before too long.

  do {
    ch = ScrKey();
    if (Pos == -1) {
      Pos = 0;
    }
    switch (ch) {
      case K_RETURN: case K_UP: case K_DOWN:
        /* Ignore these keys */
        break;
      case K_LEFT:
        if (Pos > 0)
          Pos--;
        break;
      case K_RIGHT:
        if (Pos < strlen(Text))
          Pos++;
        break;
      case K_CRIGHT:
        while ((!isspace(Text[Pos])) && (Pos < strlen(Text)))
          Pos++;
        while ((isspace(Text[Pos])) && (Pos < strlen(Text)))
          Pos++;
        break;
      case K_CLEFT:
        if (Pos > 0)
          Pos--;
        while ((isspace(Text[Pos])) && (Pos > 0))
          Pos--;
        while ((!isspace(Text[Pos])) && (Pos > 0))
          Pos--;
        if (Pos > 0)
          Pos++;
        break;
      case K_HOME:
        Pos = 0;
        break;
      case K_END:
        Pos = strlen(Text);
        break;
      case K_INS:
        if (Mode == Insert) {
          Mode = Replace;
          // ScrSetCursorSize (1,8);
        }
        else {
          Mode = Insert;
          // ScrSetCursorSize (7,8);
        }
        break;
      case K_BACKSPACE:
        if (Pos == 0)
          break;
        Pos--;
      case K_DEL:
        for (Index = Pos; Index < Text_Max; Text[Index++] = Text[Index+1]);
        Text[Text_Max] = '\000';
        break;
      default:
        if ((!isprint(ch)) || (In (ch,Exit_Keys)))
          break;
        if (Mode == Insert) {
          if (strlen(Text) == Text_Max)
            break;
          for (Index = Text_Max-1; Index > Pos; Index--)
            Text[Index] = Text[Index-1];
        }
        if (Pos < Text_Max)
          Text[Pos++] = ch;
        break;
    }

    /* Clear entry area, show current text, and put the cursor at its end */
    ScrClear (Row, Text_Start-1, Text_Max + Tmp + 1, 1, Text_Attr);
    ScrPrintText (Row, Text_Start, strlen(Text), Text);
    ScrSetCursorPos(Row, Text_Start+Pos);
  } while ((ch != K_RETURN) && (!In (ch, Exit_Keys)));


  /* Put back onto the screen what was there before */
  if (Box_Attr == NO_BOX)
    ScrWrite (Row, Column, Prompt_Length+Text_Max+2, 1, Save_Buffer);
  else
    ScrWrite (Row-1, Column-1, Prompt_Length+Text_Max+4, 3, Save_Buffer);

  free (Save_Buffer);

  /* Clean up the string by truncating trailing spaces */
  if (Tmp) while (Text[--Text_Max] == ' ')
    Text[Text_Max] = '\000';
  if (strlen(Text) == 0)
    strcpy (Text, Default_Text);
  *Text_Length = strlen(Text);

  }

  /* Restore the original cursor position */
  ScrSetCursorPos (Cur_Row, Cur_Col);
//  ScrSetCursorSize (7,8);
  return ch;
}