+ Windows clipboard for win32

This commit is contained in:
pierre 1999-09-21 17:08:58 +00:00
parent 552b86f85b
commit ee7b714aff
4 changed files with 108 additions and 17 deletions

View File

@ -16,6 +16,8 @@
unit fpide;
interface
{$i globdir.inc}
uses
Objects,Drivers,Views,App,Gadgets,MsgBox,
{$ifdef EDITORS}Editors,{$else}WEditor,{$endif}
@ -135,9 +137,9 @@ uses
{$ifdef linux}
linux,
{$endif}
{$ifdef go32v2}
{$ifdef WinClipSupported}
WinClip,
{$endif go32v2}
{$endif WinClipSupported}
Video,Mouse,Keyboard,
Dos,Memory,Menus,Dialogs,StdDlg,ColorSel,Commands,HelpCtx,
AsciiTab,
@ -211,13 +213,13 @@ var R: TRect;
begin
GetExtent(R); R.B.Y:=R.A.Y+1;
WinPMI:=nil;
{$ifdef go32v2}
{$ifdef WinClipSupported}
if WinClipboardSupported then
WinPMI:=NewLine(
NewItem('Cop~y~ to Windows','', kbNoKey, cmCopyWin, hcCopyWin,
NewItem('Paste from ~W~indows','', kbNoKey, cmPasteWin, hcPasteWin,
nil)));
{$endif go32v2}
{$endif WinClipSupported}
MenuBar:=New(PAdvancedMenuBar, Init(R, NewMenu(
NewSubMenu('~F~ile',hcFileMenu, NewMenu(
NewItem('~N~ew','',kbNoKey,cmNew,hcNew,
@ -842,7 +844,10 @@ end;
END.
{
$Log$
Revision 1.38 1999-09-13 16:24:43 peter
Revision 1.39 1999-09-21 17:09:00 pierre
+ Windows clipboard for win32
Revision 1.38 1999/09/13 16:24:43 peter
+ clock
* backspace unident like tp7

View File

@ -15,6 +15,7 @@
{$ifdef TP}
{$define SUPPORTVESA}
{$define TPUNIXLF}
{$undef WinClipSupported}
{$C FIXED PRELOAD PERMANENT}
{
@ -28,16 +29,19 @@
{$ifdef Go32V2}
{$define SUPPORTVESA}
{$define SUPPORTREDIR}
{$define WinClipSupported}
{$endif}
{$ifdef Linux}
{$undef SUPPORTVESA}
{$define SUPPORTREDIR}
{$undef WinClipSupported}
{$endif}
{$ifdef Win32}
{$undef SUPPORTVESA}
{$define SUPPORTREDIR}
{$define WinClipSupported}
{$endif}
{ --- Exclude debugger support --- }

View File

@ -332,10 +332,10 @@ type
procedure ReadBlock; virtual;
procedure PrintBlock; virtual;
procedure AddChar(C: char); virtual;
{$ifdef go32v2}
{$ifdef WinClipSupported}
function ClipCopyWin: Boolean; virtual;
function ClipPasteWin: Boolean; virtual;
{$endif go32v2}
{$endif WinClipSupported}
function ClipCopy: Boolean; virtual;
procedure ClipCut; virtual;
procedure ClipPaste; virtual;
@ -417,9 +417,9 @@ implementation
uses
MsgBox,Dialogs,App,StdDlg,HistList,Validate,
{$ifdef go32v2}
{$ifdef WinClipSupported}
Strings,WinClip,
{$endif go32v2}
{$endif WinClipSupported}
WUtils,WViews;
{$ifndef NOOBJREG}
@ -1395,10 +1395,10 @@ begin
cmCut : ClipCut;
cmCopy : ClipCopy;
cmPaste : ClipPaste;
{$ifdef go32v2}
{$ifdef WinClipSupported}
cmCopyWin : ClipCopyWin;
cmPasteWin : ClipPasteWin;
{$endif go32v2}
{$endif WinClipSupported}
cmUndo : Undo;
cmRedo : Redo;
cmClear : DelSelect;
@ -2686,7 +2686,7 @@ begin
DontConsiderShiftState:=false;
end;
{$ifdef go32v2}
{$ifdef WinClipSupported}
function TCodeEditor.ClipPasteWin: Boolean;
var OK: boolean;
l,i : longint;
@ -2721,6 +2721,10 @@ begin
s:=strpas(p2);
if first then
begin
{ we need to cut the line in two
if not at end of line PM }
InsertLine;
SetCurPtr(StorePos.X,StorePos.Y);
InsertText(s);
first:=false;
end
@ -2804,7 +2808,7 @@ begin
Freemem(p,PCLength);
UnLock;
end;
{$endif go32v2}
{$endif WinClipSupported}
procedure TCodeEditor.Undo;
begin
@ -4391,7 +4395,10 @@ end;
END.
{
$Log$
Revision 1.46 1999-09-13 16:24:44 peter
Revision 1.47 1999-09-21 17:08:59 pierre
+ Windows clipboard for win32
Revision 1.46 1999/09/13 16:24:44 peter
+ clock
* backspace unident like tp7

View File

@ -18,7 +18,9 @@ unit WinClip;
interface
{$ifdef go32v2}
{$i globdir.inc}
{$ifdef WinClipSupported}
function WinClipboardSupported : boolean;
function OpenWinClipboard : boolean;
@ -26,14 +28,22 @@ function EmptyWinClipboard : boolean;
function GetTextWinClipboardSize : longint;
function GetTextWinClipBoardData(var p : pchar;var l : longint) : boolean;
function SetTextWinClipBoardData(p : pchar;l : longint) : boolean;
{$endif go32v2}
{$endif WinClipSupported}
implementation
{$ifdef WinClipSupported}
{$ifdef go32v2}
uses
strings,go32;
{$endif go32v2}
{$ifdef win32}
uses
strings,windows;
{$endif win32}
{$ifdef go32v2}
function WinClipboardSupported : boolean;
var
r : Registers;
@ -79,6 +89,34 @@ begin
RealIntr($2F,r);
InternGetDataSize:=(r.dx shl 16) + r.ax;
end;
{$endif go32v2}
{$ifdef win32}
function WinClipboardSupported : boolean;
begin
WinClipboardSupported:=true;
end;
function OpenWinClipboard : boolean;
begin
OpenWinClipboard:=OpenClipboard(0);
end;
function EmptyWinClipboard : boolean;
begin
EmptyWinClipboard:=EmptyClipboard;
end;
function CloseWinClipboard : boolean;
begin
CloseWinClipboard:=CloseClipboard;
end;
function InternGetDataSize : longint;
begin
InternGetDataSize:=-1;
end;
{$endif go32v2}
function GetTextWinClipboardSize : longint;
@ -90,14 +128,21 @@ end;
function GetTextWinClipBoardData(var p : pchar;var l : longint) : boolean;
var
{$ifdef go32v2}
r : Registers;
tb_all : longint;
tb_seg,tb_ofs,tb_sel : word;
{$endif go32v2}
{$ifdef win32}
h : HGlobal;
pp : pchar;
{$endif win32}
begin
p:=nil;
GetTextWinClipBoardData:=False;
if not OpenWinClipBoard then
exit;
{$ifdef go32v2}
l:=InternGetDataSize;
if (l=0) or (l>100000) then
begin
@ -133,17 +178,38 @@ begin
r.bx:=tb_ofs;
RealIntr($2F,r);
GetTextWinClipBoardData:=(r.ax<>0);
{$endif go32v2}
{$ifdef win32}
h:=GetClipboardData(CF_TEXT);
if h<>0 then
begin
pp:=pchar(GlobalLock(h));
l:=strlen(pp)+1;
getmem(p,l);
move(pp^,p^,l);
GlobalUnlock(h);
end;
GetTextWinClipBoardData:=h<>0;
{$endif win32}
CloseWinClipBoard;
{$ifdef go32v2}
DosMemGet(tb_seg,tb_ofs,p^,l);
if tb_sel<>0 then
global_dos_free(tb_sel);
{$endif go32v2}
end;
function SetTextWinClipBoardData(p : pchar;l : longint) : boolean;
var
{$ifdef go32v2}
r : Registers;
tb_all : longint;
tb_seg,tb_ofs,tb_sel : word;
{$endif go32v2}
{$ifdef win32}
h : HGlobal;
pp : pchar;
{$endif win32}
begin
SetTextWinClipBoardData:=False;
if (l=0) or (l>100000) then
@ -151,6 +217,7 @@ begin
if not OpenWinClipBoard then
exit;
EmptyWinClipBoard;
{$ifdef go32v2}
if l>tb_size then
begin
tb_all:=global_dos_alloc(l);
@ -180,10 +247,18 @@ begin
SetTextWinClipBoardData:=(r.ax<>0);
if tb_sel<>0 then
global_dos_free(tb_sel);
{$endif go32v2}
{$ifdef win32}
h:=GlobalAlloc(GMEM_MOVEABLE or GMEM_DDESHARE,l);
pp:=pchar(GlobalLock(h));
move(p^,pp^,l);
GlobalUnlock(h);
SetTextWinClipBoardData:=(SetClipboardData(CF_TEXT,h)=h);
{$endif win32}
CloseWinClipBoard;
end;
{$endif go32v2}
{$endif WinClipSupported}
end.