home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
cca_110.zip
/
PMCLIP.CB
< prev
next >
Wrap
Text File
|
1997-09-20
|
6KB
|
171 lines
/*
** BRIEF version 3.x -- Basic Reconfigurable Interactive Editing Facility
**
** PmClip.cb 1.24 97/09/14
** modified by Don Hawkinson
** for use with my command line clipboard access programs
** my programs return 0 for success 1 for failure
**
** My keyboard is not a 101 key keyboard, so the
** original key assignments did not work. I changed
** the key assignments to alt+> for paste from clipboard
** and alt+< to copy to clipboard. I did not make an assignment
** for cut to clipboard.
**
**
** PmClip.cb 1.22 94/08/23
**
** By Rafal Kopicki, August 23, 1993.
** Owned by John N. Currier.
**
** === A BRIEF Users Underground project ===
**
** pmclip.cb : The macro package enables you to copy/cut to
** and paste from the OS/2 PM Clipboard.
**
** Use : load_macro( "pmclip" );
**
** Keys : set #1 - if the ALT compiler directive disabled
** <Ctrl-Keypad-Plus> - copy to the OS/2 PM Clipboard
** <Ctrl-Keypad-Minus> - cut to the OS/2 PM Clipboard
** <Ctrl-Ins> - paste from the OS/2 PM Clipboard
** set #2 - if the ALT compiler directive enabled
** <Alt-Keypad-Plus> - copy to the OS/2 PM Clipboard
** <Alt-Keypad-Minus> - cut to the OS/2 PM Clipboard
** <Alt-Ins> - paste from the OS/2 PM Clipboard
**
** Notice : Based on Jim Fowler's CLIPAPI PACKAGE Version 1.1 (IBM IUO)
** (available on OS2TOOLS).
** Requires CLIPAPI.DLL and CLIPAPI.EXE.
**
** * * * IBM Internal Use Only * * *
*/
#define BRIEF2PM_CMD "toclip"
#define PM2BRIEF_CMD "fclip2"
#define NULL_STRING ""
#define SYSTEM 1
void Brief2Pm(int);
void Pm2Brief(void);
int DosRc(int);
global string pmclip_file;
void _init(void)
{
/*
#ifdef ALT
assign_to_key( "<Alt-Keypad-Plus>", "Brief2Pm 0" ); // Copy
assign_to_key( "<Alt-Keypad-Minus>", "Brief2Pm 1" ); // Cut
assign_to_key( "<Alt-Ins>", "Pm2Brief" ); // Paste
#else
assign_to_key( "<Ctrl-Keypad-Plus>", "Brief2Pm 0" ); // Copy
assign_to_key( "<Ctrl-Keypad-Minus>", "Brief2Pm 1" ); // Cut
assign_to_key( "<Ctrl-Ins>", "Pm2Brief" ); // Paste
#endif
*/
assign_to_key( "#13056", "Brief2Pm 0" ); // Copy
assign_to_key( "#13312", "Pm2Brief" ); // Paste
// Search env vars for the temp directory : BTMP, TEMP, TMP.
if ((pmclip_file = inq_environment("BTMP")) == NULL_STRING)
if ((pmclip_file = inq_environment("TMP")) == NULL_STRING)
pmclip_file = inq_environment("TEMP");
pmclip_file += "\\PMCLIP.TMP";
}
// *------------------------------ Brief2Pm -------------------------------*
void Brief2Pm(int Cut)
{
int BufferId, MsgLevel, PmClipId, NewLine;
string DosCmdString;
set_calling_name(NULL_STRING); // Fix the copy/cut column bug
if ((Cut ? cut() : copy())) // Do the copy/cut
{
message((Cut ? "Cutting" : "Copying") + " to PM Clipboard ...");
MsgLevel = set_msg_level(3); // Suppress messages
set_calling_name("_"); // ... required !!!
set_scrap_info(1);
inq_scrap(NewLine); // NewLine is !0 if last \n is
// considered part of the scrap
PmClipId = create_buffer("PMClip", pmclip_file, SYSTEM);
BufferId = set_buffer(PmClipId);
paste(); // Paste the Scrap contents
write_buffer(); // Put the Scrap into a temp file
sprintf(DosCmdString, "%s <%s >&nul",
BRIEF2PM_CMD, pmclip_file);
set_msg_level(MsgLevel);
if (DosRc(dos(DosCmdString, 0)) == 0)
message("Block " + (Cut ? "cut" : "copied") + " to Clipboard.");
else
error((Cut ? "Cut" : "Copy") + " to Clipboard failed.");
set_buffer(BufferId); // Switch back to the initial buffer
delete_buffer(PmClipId); // Get rid of the temp buffer & file
del(pmclip_file); // The buffer then the file !!!
}
}
// *------------------------------ Pm2Brief -------------------------------*
void Pm2Brief(void)
{
int MarkType, BufferId, PmClipId;
string DosCmdString;
message("Pasting from PM Clipboard ...");
// Dump the PM Clipboard to a temp file
sprintf(DosCmdString, "%s >&%s", PM2BRIEF_CMD, pmclip_file);
if ((DosRc(MarkType = dos(DosCmdString, 0)) == 0)
&& (PmClipId = create_buffer("PMClip", pmclip_file, SYSTEM)))
{
BufferId = set_buffer(PmClipId);
drop_anchor(1);
end_of_buffer();
prev_char();
copy(); // Fill in the Scrap
set_buffer(BufferId); // Switch back to the initial buffer
delete_buffer(PmClipId); // Get rid of the temp buffer & file
del(pmclip_file); // The buffer then the file !!!
set_calling_name(NULL_STRING);
paste(); // Paste the contents into the buffer
message("Clipboard copied to Scrap.");
}
else
error("Paste from Clipboard failed.");
}
// *------------------------------- DosRc --------------------------------*
int DosRc(int rc) // Convert DOS return code (byte) to int
{
return((rc & 128) ? (rc | (-128)) : rc);
}