home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega Top 1
/
os2_top1.zip
/
os2_top1
/
DEMO
/
RIM22
/
MACROS
/
SEARCH.RM
< prev
next >
Wrap
Text File
|
1993-11-16
|
3KB
|
114 lines
/*
** Macro module: search.rm - search functions
**
** 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"
/*
** SearchSel - uses the current selection as a search string
** to search for the next/prev occurrence.
*/
void
SearchSel(int dir) {
SELECTION p;
char *string, chr, msg[20];
SHORT rc, type;
LONG offset, column, line, i, len;
type = MarkQuerySel( &p );
if ( type < 1 || type > 4 || ( p.s_line != p.e_line ) ) {
if ( dir )
SearchForward();
else
SearchBackward();
return;
} else {
MarkEndSel();
MarkQuerySel( &p, 1 );
MarkRemoveSel();
PosAbs( p.s_line, p.s_column );
offset = BufQueryOffset();
len = ( p.e_column - p.s_column ) + 1L;
string = malloc(len+1L);
for ( i = 0; i < len; i++, offset++ ) {
chr = BufQueryChar(offset);
string[i] = chr;
}
if ( dir ) {
PosNextChar();
rc = SrchFwd(string, 0, 1, 0);
} else {
PosPrevChar();
rc = SrchBack(string, 0, 1, 0);
}
if ( rc > 0 ) {
BufQueryPosition( &line, &column );
p.type = 1;
p.s_column = column;
p.s_line = p.e_line = line;
p.e_column = column + len - 1L;
MarkCreateSel( &p );
} else {
if ( dir )
PosPrevChar();
else
PosNextChar();
PopupMsgBox("Pattern not found", "Information",
MB_OK | MB_ICONEXCLAMATION );
}
free(string);
}
} /* end SearchSel() */
void
SelWord() {
char *str = ",;:'\t {}[]()\n";
while ( strchr(str, (BufQueryChar())) ) {
if ( PosPrevChar() )
break;
}
while ( !strchr(str, (BufQueryChar())) ) {
if ( PosPrevChar() )
break;
}
PosNextChar();
MarkBeginSel();
while ( !strchr(str, (BufQueryChar())) ) {
if ( PosNextChar() )
break;
}
PosPrevChar();
MarkEndSel();
} /* end SelWord() */
/*
** End macro: Search.rm
*/