Develop and Download Open Source Software

Browse Subversion Repository

Contents of /charinp.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download) (as text)
Mon Nov 7 12:03:00 2011 UTC (12 years, 4 months ago) by shiraishikazuo
File MIME type: text/x-pascal
File size: 2632 byte(s)


1 unit charinp;
2
3 {$IFDEF FPC}
4 {$MODE DELPHI}{$H+}
5 {$ENDIF}
6
7 (***************************************)
8 (* Copyright (C) 2003, SHIRAISHI Kazuo *)
9 (***************************************)
10
11
12 interface
13
14 uses
15 SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,
16 LResources,
17 myutils,base;
18
19 type
20 TCharInput = class(TForm)
21 Label1: TLabel;
22 procedure FormKeyPress(Sender: TObject; var Key: Char);
23 procedure FormCreate(Sender: TObject);
24 public
25 c:ansistring;
26 TimeLimit:TDateTime;
27 LineNumber:integer;
28 function execute(option:IOoptions):ansistring;
29 procedure init;
30 end;
31
32 var
33 CharInput: TCharInput;
34
35 implementation
36 uses fileutil;
37 {$R *.lfm}
38
39
40 procedure TCharInput.FormKeyPress(Sender: TObject; var Key: Char);
41 begin
42 c:=c+key;
43 end;
44
45
46
47 function TCharInput.execute(option:IOoptions):ansistring;
48 var
49 svCtrlBreakHit:boolean;
50 i:integer;
51 s:ansistring;
52 begin
53 show;
54 svCtrlBreakHit:=CtrlBreakHit;
55 CtrlBreakHit:=false;
56 IdleImmediately;
57
58 if not(ioNoWait in option) then
59 //SelectLine(TextHand.memo,LineNumber);
60 //caption:=TextHand.getMemoLine(LineNumber);
61 Label1.visible:=true;
62
63 if ioClear in option then
64 c:='';
65
66 IdleImmediately;
67 While not((ioNoWait in option) or (Length(c)>0) or CtrlBreakHit or (now>=timelimit)) do
68 begin
69 sleep(10);IdleImmediately;
70 end;
71
72 if Length(c)>0 then
73 begin
74 if ioCharacterByte in option then
75 begin
76 result:=c[1];
77 delete(c,1,1);
78 end
79 else
80 {$IFDEF Windows}
81 begin
82 i:=1;
83 ReadSJIS(i,c); //Shift JIS���������
84 if i<=Length(c) then
85 begin
86 result:=SysToUTF8(copy(c,1,i));
87 delete(c,1,i);
88 end;
89 end;
90 {$ELSE}
91 begin
92 i:=1;
93 ReadMBC(i,c);
94 result:=copy(c,1,i);
95 delete(c,1,i);
96 end;
97 {$ENDIF}
98 end
99 else
100 result:='';
101 CtrlBreakHit:=CtrlBreakHit or svCtrlbreakHit;
102 //texthand.memo.sellength:=0;
103 if not(ioNoWait in option) then
104 begin
105 hide;
106 Label1.visible:=false;
107 end;
108 //caption:='';
109 if (now>=timelimit) then setexception(8401);
110 end;
111
112
113 procedure TCharInput.FormCreate(Sender: TObject);
114 begin
115 init;
116 end;
117
118 procedure TCharInput.Init;
119 begin
120 c:='';
121 Label1.caption:='';
122 end;
123
124 initialization
125
126
127
128 end.
129

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26