📄 wrestr.c
字号:
}
session->info->parent = WREGetMainWindowHandle();
session->info->inst = WREGetAppInstance ();
session->info->file_name = WREStrDup ( WREGetQueryName ( curr->info ) );
session->info->tables = nodes;
session->info->is32bit = curr->info->is32bit;
session->info->stand_alone = WRENoInterface;
session->info->symbol_table = curr->info->symbol_table;
session->info->symbol_file = curr->info->symbol_file;
session->tnode = curr->type;
session->rinfo = curr->info;
session->hndl = WRStringStartEdit( session->info );
if ( session->hndl ) {
WREInsertObject ( &WREStringSessions, session );
if( nodes ) {
WREFreeStringNode( nodes );
session->info->tables = NULL;
}
} else {
WStrFreeStringInfo ( session->info );
WREMemFree ( session );
session = NULL;
}
return ( session );
}
Bool WREGetStringSessionData( WREStringSession *session, Bool close )
{
WResTypeNode *tnode;
uint_16 type;
Bool ok;
ok = ( session && session->info && session->hndl );
if( ok ) {
if( close ) {
session->info = WStringEndEdit( session->hndl );
} else {
session->info = WStringGetEditInfo( session->hndl );
}
ok = ( session->info != NULL );
}
if( ok ) {
tnode = WREFindTypeNode( session->rinfo->info->dir,
(uint_16)RT_STRING, NULL );
}
if( ok && tnode && session->info->modified ) {
ok = WRRemoveTypeNodeFromDir( session->rinfo->info->dir, tnode );
tnode = NULL;
}
if( ok && session->info->modified ) {
tnode = WREUseStringNodes( session->rinfo->info->dir, session->info->tables );
type = 0;
if( tnode != NULL ) {
type = (uint_16)RT_STRING;
}
session->rinfo->current_type = 0;
ok = WREInitResourceWindow( session->rinfo, type );
session->tnode = tnode;
WREFreeStringNode( session->info->tables );
session->info->tables = NULL;
session->info->modified = FALSE;
session->rinfo->modified = TRUE;
}
return( ok );
}
Bool WREEndAllStringSessions( Bool fatal_exit )
{
WREStringSession *session;
LIST *slist;
Bool ok;
ok = TRUE;
if( WREStringSessions ) {
for( slist = WREStringSessions; slist; slist = ListNext(slist) ) {
session = (WREStringSession *) ListElement(slist);
if( session ) {
ok = WStringCloseSession( session->hndl, fatal_exit );
}
}
if( ok ) {
ListFree( WREStringSessions );
WREStringSessions = NULL;
}
}
return( ok );
}
void WREEndResStringSessions( WREResInfo *rinfo )
{
WREStringSession *session;
session = WREFindResStringSession( rinfo );
while( session ) {
session->info = WStringEndEdit( session->hndl );
WRERemoveStringEditSession( session );
session = WREFindResStringSession( rinfo );
}
}
WREStringSession *WREFindStringSession ( WStringHandle hndl )
{
WREStringSession *session;
LIST *slist;
for ( slist = WREStringSessions; slist; slist = ListNext(slist) ) {
session = (WREStringSession *) ListElement(slist);
if ( session->hndl == hndl ) {
return ( session );
}
}
return ( NULL );
}
WREStringSession *WREFindResStringSession( WREResInfo *rinfo )
{
WREStringSession *session;
LIST *slist;
for( slist = WREStringSessions; slist; slist = ListNext(slist) ) {
session = (WREStringSession *) ListElement(slist);
if( session->rinfo == rinfo ) {
return( session );
}
}
return( NULL );
}
WREStringSession *WREAllocStringSession ( void )
{
WREStringSession *session;
session = (WREStringSession *) WREMemAlloc ( sizeof(WREStringSession) );
if ( session ) {
memset ( session, 0, sizeof(WREStringSession) );
}
return ( session );
}
WStringNode *WREMakeNode( WRECurrentResInfo *curr )
{
WStringNode *node;
if( !curr ) {
return( NULL );
}
node = (WStringNode *)WREMemAlloc( sizeof(WStringNode) );
if( node == NULL ) {
return( NULL );
}
memset( node, 0, sizeof(WStringNode) );
node->lang = curr->lang->Info.lang;
node->MemFlags = curr->lang->Info.MemoryFlags;
node->block_name = WRECopyWResID ( &curr->res->Info.ResName );
node->data_size = curr->lang->Info.Length;
node->data = WREGetCurrentResData( curr );
if( node->data == NULL ) {
WREFreeStringNode( node );
node = NULL;
}
return( node );
}
WStringNode *WRECreateStringNodes( WRECurrentResInfo *curr )
{
WRECurrentResInfo tcurr;
WResResNode *rnode;
WResLangNode *lnode;
WStringNode *nodes;
WStringNode *new;
WResLangType lang;
if( curr == NULL ) {
return( NULL );
}
nodes = NULL;
tcurr = *curr;
rnode = curr->type->Head;
while( rnode ) {
lnode = rnode->Head;
if( lnode ) {
lang = lnode->Info.lang;
}
while( lnode ) {
if( ( lnode->Info.lang.lang == lang.lang ) &&
( lnode->Info.lang.sublang == lang.sublang ) ) {
tcurr.res = rnode;
tcurr.lang = lnode;
new = WREMakeNode( &tcurr );
if( !new ) {
WREFreeStringNode( nodes );
return( NULL );
}
if( nodes ) {
new->next = nodes;
nodes = new;
} else {
nodes = new;
}
}
lnode = lnode->Next;
}
rnode = rnode->Next;
}
return( nodes );
}
void WREFreeStringNode( WStringNode *node )
{
WStringNode *n;
while( node ) {
n = node;
node = node->next;
if( n->block_name ) {
WREMemFree( n->block_name );
}
if( n->data ) {
WREMemFree( n->data );
}
WREMemFree( n );
}
}
WResTypeNode *WREUseStringNodes( WResDir dir, WStringNode *node )
{
WResID *tname;
WResTypeNode *tnode;
Bool ok;
tnode = NULL;
tname = WResIDFromNum( (long)RT_STRING );
ok = ( tname != NULL );
while( ok && node ) {
ok = !WResAddResource( tname, node->block_name, node->MemFlags, 0,
node->data_size, dir, &node->lang, NULL );
if( ok ) {
ok = WRFindAndSetData( dir, tname, node->block_name,
&node->lang, node->data );
node->data = NULL;
}
node = node->next;
}
if( tname ) {
WREMemFree( tname );
}
if( ok ) {
tnode = WREFindTypeNode( dir, (uint_16)RT_STRING, NULL );
}
return( tnode );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -