Forráskód Böngészése

Get Video and Keyboard unit working.

* keyboard.pp
   - as Symobi will block when reading more characters than available we must resolve to reading the input bytewise
   - add escape sequences for the cursor keys
* video.pp
   - add a new terminal definition that is based on the vt100 one, but does not include the codes for entering and leaving the alternate charset mode
   - force UTF8Enabled to true for Symobi
   - when initializing set the terminal to UTF8 mode and reset then when deinitializing
   - zero out the structure for the size as that IOCTL isn't implemenet in Symobi and won't adjust WS at all (so the width and height is set to the garbage values that were on the stack)
   - Symobi's default terminal size is 80x24

git-svn-id: branches/svenbarth/symobi@18143 -
svenbarth 14 éve
szülő
commit
f0310769c9
3 módosított fájl, 57 hozzáadás és 12 törlés
  1. 8 6
      rtl/unix/cthreads.pp
  2. 10 1
      rtl/unix/keyboard.pp
  3. 39 5
      rtl/unix/video.pp

+ 8 - 6
rtl/unix/cthreads.pp

@@ -52,12 +52,14 @@ interface
 {$S-}
 
 {$ifndef dynpthreads}   // If you have problems compiling this on FreeBSD 5.x
- {$linklib c}           // try adding -Xf
- {$ifndef Darwin}
-   {$ifndef haiku}
-     {$linklib pthread}
-   {$endif haiku}
- {$endif darwin}
+ {$ifndef symobi} 
+  {$linklib c}           // try adding -Xf
+  {$ifndef Darwin}
+    {$ifndef haiku}
+      {$linklib pthread}
+    {$endif haiku}
+  {$endif darwin}
+ {$endif symobi}
 {$endif}
 
 {$define basicevents_with_pthread_cond}

+ 10 - 1
rtl/unix/keyboard.pp

@@ -387,9 +387,14 @@ begin
   if (InHead=InTail) then
     begin
       {Calc Amount of Chars to Read}
+{$ifdef symobi}
+      { only read bytewise or the application will hang }
+      i:=1;
+{$else}
       i:=InSize-InHead;
       if InTail>InHead then
         i:=InTail-InHead;
+{$endif}
       {Read}
       repeat
         Readed:=fpRead(StdInputHandle,InBuf[InHead],i);
@@ -742,7 +747,7 @@ type  key_sequence=packed record
         st:string[7];
       end;
 
-const key_sequences:array[0..276] of key_sequence=(
+const key_sequences:array[0..280] of key_sequence=(
        (char:0;scan:kbAltA;st:#27'A'),
        (char:0;scan:kbAltA;st:#27'a'),
        (char:0;scan:kbAltB;st:#27'B'),
@@ -873,6 +878,10 @@ const key_sequences:array[0..276] of key_sequence=(
        (char:0;scan:kbDown;st:#27'OB'),          {xterm}
        (char:0;scan:kbRight;st:#27'OC'),         {xterm}
        (char:0;scan:kbLeft;st:#27'OD'),          {xterm}
+       (char:0;scan:kbUp;st:#27'A'),             {symobi}
+       (char:0;scan:kbDown;st:#27'B'),           {symobi}
+       (char:0;scan:kbRight;st:#27'C'),          {symobi}
+       (char:0;scan:kbLeft;st:#27'D'),           {symobi}
 (* Already recognized above as F11!
        (char:0;scan:kbShiftF1;st:#27'[23~'),     {rxvt}
        (char:0;scan:kbShiftF2;st:#27'[24~'),     {rxvt}

+ 39 - 5
rtl/unix/video.pp

@@ -190,7 +190,21 @@ const term_codes_ansi:Ttermcodes=
          nil,//#$1B#$5B#$3F#$37#$6C,                              {exit_am_mode}
          nil);//#$1B#$28#$42#$1B#$29#$30);                         {ena_acs}
 
-const    terminal_names:array[0..11] of string[7]=(
+      term_codes_symobi:Ttermcodes=
+        (nil,                                               {enter_alt_charset_mode}
+         nil,                                               {exit_alt_charset_mode}
+         #$1B#$5B#$48#$1B#$5B#$4A,                          {clear_screen}
+         #$1B#$5B#$48,                                      {cursor_home}
+         nil,                                               {cursor_normal}
+         nil,                                               {cursor visible, underline}
+         nil,                                               {cursor visible, block}
+         nil,                                               {cursor_invisible}
+         nil,                                               {enter_ca_mode}
+         nil,                                               {exit_ca_mode}
+         nil,                                               {exit_am_mode}
+         nil);                                              {ena_acs}
+
+const    terminal_names:array[0..12] of string[7]=(
                         'ansi',
                         'cons',
                         'eterm',
@@ -202,8 +216,9 @@ const    terminal_names:array[0..11] of string[7]=(
                         'vt100',
                         'vt220',
                         'xterm',
-                        'beterm');
-         terminal_data:array[0..11] of Ptermcodes=(
+                        'beterm',
+                        'symobi');
+         terminal_data:array[0..12] of Ptermcodes=(
                         @term_codes_ansi,
                         @term_codes_freebsd,
                         @term_codes_xterm,
@@ -215,7 +230,8 @@ const    terminal_names:array[0..11] of string[7]=(
                         @term_codes_vt100,
                         @term_codes_vt220,
                         @term_codes_xterm,
-                        @term_codes_beos);
+                        @term_codes_beos,
+                        @term_codes_symobi);
 
 const convert:Tconversion=cv_none;
 
@@ -962,7 +978,7 @@ function UTF8Enabled: Boolean;
 var
   lang:string;
 begin
-  {$ifdef BEOS}
+  {$if defined(BEOS) or defined(SYMOBI)}
   UTF8Enabled := true;
   exit;
   {$endif}
@@ -1061,6 +1077,9 @@ var
 
 const font_vga:array[0..11] of char=#15#27'%@'#27'(U'#27'[3h';
       font_lat1:array[0..5] of char=#27'%@'#27'(B';
+{$ifdef symobi}
+	  font_utf8:array[0..2] of char=#27'(U';
+{$endif}
 
 begin
   { check for tty }
@@ -1109,6 +1128,10 @@ begin
          if (ThisTTY[10]>='0') and (ThisTTY[10]<='9') Then
             Console:=ttyFreeBSD;   {TTYFd ?}
        end;
+   {$endif}
+   {$ifdef symobi}
+     { we use the UTF8 output mode on Symobi }
+     fpwrite(stdoutputhandle,font_utf8,sizeof(font_utf8));
    {$endif}
      term:=fpgetenv('TERM');
      for i:=low(terminal_names) to high(terminal_names) do
@@ -1161,11 +1184,16 @@ begin
    {$ifdef linux}
       end;
    {$endif}
+     FillChar(WS, SizeOf(WS), 0);
      fpioctl(stdinputhandle, TIOCGWINSZ, @WS);
      if WS.ws_Col=0 then
       WS.ws_Col:=80;
      if WS.ws_Row=0 then
+{$ifdef symobi}
+      WS.ws_Row:=24;
+{$else}
       WS.ws_Row:=25;
+{$endif}
      ScreenWidth:=WS.ws_Col;
      { TDrawBuffer only has FVMaxWidth elements
        larger values lead to crashes }
@@ -1222,6 +1250,9 @@ end;
 procedure SysDoneVideo;
 
 var font_custom:array[0..2] of char=#27'(K';
+{$ifdef symobi}
+    font_default:array[0..2] of char=#27'(B';
+{$endif}
 
 begin
   prepareDoneVideo;
@@ -1252,6 +1283,9 @@ begin
        end;
 {$ifdef linux}
    end;
+{$endif}
+{$ifdef symobi}
+  fpwrite(stdoutputhandle,font_default,sizeof(font_default));
 {$endif}
   ACSIn:='';
   ACSOut:='';