home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega Top 1
/
os2_top1.zip
/
os2_top1
/
DEMO
/
RIM22
/
MACROS
/
BUFFER.RM
< prev
next >
Wrap
Text File
|
1994-01-11
|
4KB
|
143 lines
/*
** Macro module: buffer.rm - Misc. routines
**
** Copyright (C) 1993 Brian L. Smith
** Copyright (C) 1993 RimStar Technology, Inc.
** All rights reserved internationally.
** Unlicensed use is a violation of applicable laws.
**
** This source code is provided to licensed users of RimStar's products
** for the purpose of allowing the user to customize and/or enhance RimStar's
** products. The source code remains the property of the copyright holders
** with all rights reserved internationally.
** Any modifications to the source code are considered derivative works and
** all rights thereto are reserved to the copyright holders except
** that the purchaser may use the derivitive work in the same manner
** as permitted by the license governing the unmodified product.
** Distribution in any manner of any part of the original source code,
** whether in source or object form, is expressly prohibited without the
** express written permission of the copyright holders.
**
*/
#include "macro.h"
char *reloadMsg = "This file is already loaded and has been modified. "
"Modifications will be lost if you answer YES. Reload file?";
/*
** EditFile - this macro is called by the DlgOpenFile primitive for each file
** selected to be edited, therefore it is required if you use DlgOpenFile.
** You may modify it of course.
*/
SHORT
EditFile(char *pathname, ULONG flags) {
SHORT rc, reply;
HBUFFER hb;
if ( !(pathname = complete_path(pathname)) )
return 1;
if ( (hb = BufFindBuffer(pathname, 0)) && BufQueryModified(hb) ) {
reply = PopupMsgBox( reloadMsg,
pathname,
MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2 | MB_APPLMODAL);
if ( reply != MBID_YES )
return 1;
rc = BufLoadFile(hb, pathname, flags);
free(pathname);
return rc;
}
rc = BufEditFile(pathname, flags);
free(pathname);
return rc;
} /* end EditFile() */
SHORT
ReloadBuffer(void) {
SHORT reply;
char *pathname;
HBUFFER hbCurrent;
hbCurrent = BufQueryCurrentBuffer();
pathname = BufQueryFilename();
if ( BufQueryModified() ) {
reply = PopupMsgBox( reloadMsg,
pathname,
MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2 | MB_APPLMODAL);
if ( reply != MBID_YES )
return 1;
}
return BufLoadFile(hbCurrent, pathname);
} /* end ReloadBuffer() */
SHORT
SaveBuffer(void) {
if ( MarkQuerySelType() )
return BufWriteSel();
if ( !BufQueryModified() ) {
PopupMsg("File has not been modified. Save request ignored.", BufQueryFilename());
return -1;
}
return BufWrite();
} /* end SaveBuffer() */
void
ReadOnlyBuffer(USHORT event, PVOID pData) {
char *pathname;
SHORT reply;
pathname = BufQueryFilename();
reply = PopupMsgBox("Buffer is read only. Allow modifications?",
pathname,
MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2 | MB_APPLMODAL);
if ( reply == MBID_YES ) {
BufSetFlags(BUFFER_READ_ONLY, 0L);
return 0;
}
return 1;
} /* end ReadOnlyBuffer() */
void
CopyToScrap(void) {
if ( !MarkQuerySelType() ) /* If no current selection */
MarkBeginSel(SELECT_LINE); /* Mark current line */
BufCopyToScrap(0);
MarkRemoveSel();
} /* CopyToScrap() */
void
CutToScrap(void) {
if ( !MarkQuerySelType() ) /* If no current selection */
MarkBeginSel(SELECT_LINE); /* Mark current line */
BufCutToScrap(0);
} /* end CutToScrap() */
void
CopyAppendToScrap(void) {
if ( !MarkQuerySelType() ) /* If no current selection */
MarkBeginSel(SELECT_LINE); /* Mark current line */
BufCopyToScrap(1);
MarkRemoveSel();
} /* CopyToScrap() */
void
CutAppendToScrap(void) {
if ( !MarkQuerySelType() ) /* If no current selection */
MarkBeginSel(SELECT_LINE); /* Mark current line */
BufCutToScrap(1);
} /* end CutToScrap() */
/*
** End macro: buffer.rm
*/