⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 awemu.pas

📁 测试用例
💻 PAS
📖 第 1 页 / 共 3 页
字号:
           Cmd := eDECSTBM;
           X   := emuParamInt[1];
           Y   := emuParamInt[2];
         end;
      end;
    end;
  end;

  procedure ProcessVT52Emulation(P : PAnsiEmulator; var Command: TEmuCommandLo); 
  begin
    with P^, Command do begin
      case Ch of
       'A' :
         begin
           {Cursor up}
           Cmd := eCUU; {eUp}
           Y := 1;
         end;
       'B' :
         begin
           {Cursor down}
           Cmd := eCUD; {eDown}
           Y := 1;
         end;
       'C' :
         begin
           {Cursor right}
           Cmd := eCUF; {eRight}
           X := 1;
         end;
       'D' :
         begin
           {Cursor left}
           cmd := eCUB; {eLeft}
           X := 1;
         end;
       'F' :
         begin
           {NOT SUPPORTED}
           { Select special graphics character set }
         end;
       'G' :
         begin
           {NOT SUPPORTED}
         end;
       'H' :
         begin
           {Cursor position}
           Cmd := eCUP;{eGotoXY}
           X   := 1;
           Y   := 1;
         end;
       'I' :
         begin
           {NOT SUPPORTED}
         end;
       'J' :
         begin
           {Erase in display}
           X := 2;
           Y := 0;
           Cmd := eED;
         end;
       'K' :
         begin
           {Erase in line}
           X := 2;
           Y := 0;
           Cmd := eEL;
         end;
       'Z' : Cmd := eDA;  {Device Attributes}
       'c' : Cmd := eRIS; {Reset to initial state}
       '=' :
         begin
           {NOT SUPPORTED}
         end;
       '>' :
         begin
           {NOT SUPPORTED}
         end;
       '<' :
         begin
           {NOT SUPPORTED}
         end;
      end;
    end;
  end;

  procedure aeMakeCommand(P : PAnsiEmulator; C : Char; var Command : TEmuCommandLo);
    {-Make a command record}
  begin
    with P^ do begin
      aeConvertParams(P, C);
      Command.emuType := P^.emuType;
      with Command do begin
        Ch := C;
        Cmd := eChar;
        case emuType of
          etANSI,
          etANSIBBS : ProcessANSIEmulation(P, Command);
          etVT100   : ProcessVT100Emulation(P, Command);
          etVT52    : ProcessVT52Emulation(P, Command);
        end;
      end;
    end;
  end;

  procedure aeProcessAnsiChar(P : Pointer; C : Char;
                              var Command : TEmuCommandLo);       
  const
    EqualSign = #61;
    QuestionMark = #63;

    procedure ErrorCondition;
      {-Set error state and reset parser}
    begin
      with PAnsiEmulator(P)^ do begin
        Command.Cmd := eError;
        if emuIndex > MaxOther then
          emuIndex := MaxOther;
        Move(emuQueue, Command.Other, emuIndex);
        aeInitParser(P);
      end;
    end;

  begin
    with PAnsiEmulator(P)^ do begin
      {-saftey check if no emulator type selected}
      if emuType = etNone then begin
        Command.Ch := C;
        Command.Cmd := eChar;
        exit;
      end;
      if emuFirst then begin
        {Handle startups that don't init attributes}
        emuFirst := False;
        Command.FColor := aweDefForeGround;
        Command.BColor := aweDefBackGround;
        Command.ExtAttr:= 0;
        emuAttr        := 0;
      end;

      aePutQueue(P, C);
      with Command do begin
        Ch := C;
        Cmd := eNone;
      end;

      {Evaluate parser state}

      case emuParserState of
        GotNone :
          begin
            case C of
              Escape : emuParserState := GotEscape;
              FormFeed : begin
                           Command.Cmd := eClearScreen;
                           Command.X   := 2;
                         end;
              #9 : Command.Cmd := eHT;
              #14 : Command.Cmd := eNone;
              #15 : Command.Cmd := eNone;
              else begin
                Command.Cmd := eChar;
                emuIndex := 0;
              end;
            end;
          end;
        GotEscape :
          if (C = LeftBracket) and (emuType <> etVT52) then
            emuParserState := GotControlSeqIntro
          else if (C = '(') and (emuType = etVT100) then
            emuParserState := GotLeftBrace
          else if (C = ')') and (emuType = etVT100) then
            emuParserState := GotRightBrace
          else begin
            Command.Cmd := eChar;
            case emuType of
              etANSI, etANSIBBS :
                case C of
                  'D' :
                    begin
                      Command.Cmd := eIND;
                      Command.Y := 1;
                    end;
                  'E' : Command.Cmd := eNEL;
                  'F' : Command.Cmd := eSSA;
                  'G' : Command.Cmd := eESA;
                  'H' : Command.Cmd := eHTS;
                  'I' : Command.Cmd := eHTJ;
                  'J' : Command.Cmd := eVTS;
                  'K' : Command.Cmd := ePLD;
                  'L' : Command.Cmd := ePLU;
                  'M' : Command.Cmd := eRI;
                  'N' : Command.Cmd := eSS2;
                  'O' : Command.Cmd := eSS3;
                  'P' : Command.Cmd := eDCS;
                  'Q' : Command.Cmd := ePU1;
                  'R' : Command.Cmd := ePU2;
                  'S' : Command.Cmd := eSTS;
                  'T' : Command.Cmd := eCCH;
                  'U' : Command.Cmd := eMW;
                  'V' : Command.Cmd := eSPA;
                  'W' : Command.Cmd := eEPA;
                  'a' : Command.Cmd := eINT;
                  'b' : Command.Cmd := eEMI;
                  'c' : Command.Cmd := eRIS;
                  '^' : Command.Cmd := ePM;
                  '\' : Command.Cmd := eST;
                end;
              etVT100 :
                case C of
                  'c' : Command.Cmd := eRIS;
                  'D' :
                    begin
                      Command.Cmd := eIND;
                      Command.Y := 1;
                    end;
                  'E' : Command.Cmd := eNEL;
                  'H' : Command.Cmd := eHTS;
                  'M' : Command.Cmd := eRI;
                  'Z' :
                    begin
                      Command.Cmd := eDA;
                      Command.X := 0;
                      Command.Y := 1;
                    end;
                  '7' : Command.Cmd := eSaveCursorPos;
                  '8' : Command.Cmd := eRestoreCursorPos;
                  '=' : Command.Cmd := eNone;
                  '>' : Command.Cmd := eNone;
                end;
              etVT52  :
                begin
                  if ((C >= 'A') and (C <= 'D')) or ((C >= 'F') and (C <= 'K')) or
                     (C = 'Z') or (C = '=') or (C = '<') or (C = '>') or (C = 'c') then
                    aeMakeCommand(P, C, Command);
                end;
            end;
            aeInitParser(P);
          end;
        GotSemiColon,
        GotParam,
        GotControlSeqIntro :
          begin
            case emuType of
              etAnsi,
              etANSIBBS,
              etVT100 :
                begin
                  case C of
                    #48..#57 :
                      begin
                        aeBuildParam(P, C);
                        emuParserState := GotParam;
                      end;
                    EqualSign : ;
                    QuestionMark :
                      begin
                        emuParserState := GotQuestionMark;
                        Inc(emuParamIndex);
                        if emuParamIndex > MaxParams then
                          ErrorCondition;
                      end;
                    SemiColon :
                      begin
                        emuParserState := GotSemicolon;
                        Inc(emuParamIndex);
                        if emuParamIndex > MaxParams then
                          ErrorCondition;
                      end
                    else begin
                      aeMakeCommand(P, C, Command);
                      aeInitParser(P);
                    end;
                  end;
                end;
            end;
          end;
        GotQuestionParam,
        GotQuestionMark :
          begin
            case emuType of
              etVT100 :
                begin
                  case C of
                    #49..#57 :
                      begin
                        aeBuildParam(P, C);
                        emuParserState := GotQuestionParam;
                      end;
                    'h',
                    'l' :
                      begin
                        Command.Cmd := eNone;
                        aeInitParser(P);
                      end;
                    else begin
                      Command.Cmd := eChar;
                      aeInitParser(P);
                    end;
                  end;
                end;
              else begin
                Command.Cmd := eChar;
                aeInitParser(P);
              end;
            end;
          end;
        GotLeftBrace :
          begin
            if emuType = etVT100 then begin
              Command.Cmd := eNone;
              case C of {NOT SUPPORTED}
                'A' : ;
                'B' : ;  { This is for character set information }
                '0' : ;
                '1' : ;
                '2' : ;
                else Command.Cmd := eChar;
              end;
              aeInitParser(P);
            end;
          end;
        GotRightBrace :
          begin
            if emuType = etVT100 then begin
              Command.Cmd := eNone;
              case C of {NOT SUPPORTED}
                'A' : ;
                'B' : ;  { This is for character set information }
                '0' : ;
                '1' : ;
                '2' : ;
                else Command.Cmd := eChar;
              end;
              aeInitParser(P);
            end;
          end;
        GotSpace :
          begin
            {NOT SUPPORTED}
          end;
        GotCommand :
          begin
            {NOT SUPPORTED}
          end;
      end;
    end;
  end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -