[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH 2/4] Pascal-RTL: Unit tyndur



+ Pascal-RTL: tyndur: ReadUnicodeChar
---
 src/modules/pas/kedit/kedit.pas         |    4 ++-
 src/modules/pas/lib/tyndur/Makefile.all |    1 +
 src/modules/pas/lib/tyndur/tyndur.pas   |   36 +++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 1 deletions(-)
 create mode 100644 src/modules/pas/lib/tyndur/Makefile.all
 create mode 100644 src/modules/pas/lib/tyndur/tyndur.pas

diff --git a/src/modules/pas/kedit/kedit.pas b/src/modules/pas/kedit/kedit.pas
index 4409f7d..473c218 100644
--- a/src/modules/pas/kedit/kedit.pas
+++ b/src/modules/pas/kedit/kedit.pas
@@ -1,7 +1,9 @@
 program KEdit;
 {$H+}
 
-uses crt, sysutils, kedit_tui, kedit_buf, kedit_input, kedit_main;
+uses
+    crt, sysutils, tyndur,
+    kedit_tui, kedit_buf, kedit_input, kedit_main;
 
 type
     textfile  = text;
diff --git a/src/modules/pas/lib/tyndur/Makefile.all b/src/modules/pas/lib/tyndur/Makefile.all
new file mode 100644
index 0000000..aacb99c
--- /dev/null
+++ b/src/modules/pas/lib/tyndur/Makefile.all
@@ -0,0 +1 @@
+cp libptyndur.a tyndur.ppu ../units
diff --git a/src/modules/pas/lib/tyndur/tyndur.pas b/src/modules/pas/lib/tyndur/tyndur.pas
new file mode 100644
index 0000000..5cffdad
--- /dev/null
+++ b/src/modules/pas/lib/tyndur/tyndur.pas
@@ -0,0 +1,36 @@
+unit tyndur;
+
+interface
+
+    function ReadUnicodeChar: UnicodeChar;
+
+
+implementation
+
+    uses crt;
+
+    function ReadUnicodeChar: UnicodeChar;
+    var
+        keys: Array [1..5] of char;
+        pkeys: PChar;
+
+        res: Array [1..2] of UnicodeChar;
+        pres: PUnicodeChar;
+
+        ret: integer;
+        i: integer;
+    begin
+        pkeys := @keys[1];
+        pres := @res[1];
+        for i := 1 to 4 do begin
+            keys[i] := readkey;
+            keys[i+1] := #0;
+            ret := Utf8ToUnicode(pres, 2, pkeys, i);
+            if ret >= 0 then begin
+                break;
+            end;
+        end;
+        exit(res[1]);
+    end;
+
+end.
-- 
1.6.0.2