1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
/************************************************************************/
/* */
/* Ted, main module. */
/* */
/************************************************************************/
# include "tedConfig.h"
# include <stddef.h>
# include <stdlib.h>
# include <stdio.h>
# include <string.h>
# include <ctype.h>
# include "tedApp.h"
# include <appDebugon.h>
/************************************************************************/
/* */
/* Determine application specific default settings. */
/* */
/* 1) Determine default code page. */
/* 2) Determine default for show table grid. */
/* */
/************************************************************************/
void tedDetermineDefaultSettings( TedAppResources * tar )
{
char * past;
int val;
/* 1 */
if ( tar->tarDefaultAnsicpgString &&
tar->tarDefaultAnsicpgInt < 0 )
{
val= strtol( tar->tarDefaultAnsicpgString, &past, 10 );
if ( past != tar->tarDefaultAnsicpgString )
{
while( *past == ' ' )
{ past++; }
}
if ( past != tar->tarDefaultAnsicpgString &&
! *past )
{ tar->tarDefaultAnsicpgInt= val; }
else{ SDEB(tar->tarDefaultAnsicpgString); }
}
/* 2 */
if ( tar->tarShowTableGridString &&
tar->tarShowTableGridInt == 0 )
{
if ( ! strcmp( tar->tarShowTableGridString, "0" ) )
{ tar->tarShowTableGridInt= -1; }
if ( ! strcmp( tar->tarShowTableGridString, "1" ) )
{ tar->tarShowTableGridInt= 1; }
if ( tar->tarShowTableGridInt == 0 )
{ SDEB(tar->tarShowTableGridString); }
}
return;
}
/************************************************************************/
/* */
/* Handle a replace from one of the tools. */
/* */
/************************************************************************/
void tedAppReplace( void * voidea,
const unsigned char * word )
{
EditApplication * ea= (EditApplication *)voidea;
EditDocument * ed= ea->eaCurrentDocument;
TedDocument * td;
if ( ! ed )
{ XDEB(ed); return; }
td= (TedDocument *)ed->edPrivateData;
if ( tedHasSelection( td ) &&
! tedHasIBarSelection( td ) &&
td->tdCanReplaceSelection )
{ tedDocReplaceSelection( ed, word, strlen( (const char *)word ) ); }
return;
}
/************************************************************************/
/* */
/* Callback for the 'Insert File' menu option. */
/* */
/************************************************************************/
static int tedInsertFile( void * voided,
APP_WIDGET relative,
APP_WIDGET option,
const char * filename )
{
EditDocument * ed= (EditDocument *)voided;
EditApplication * ea= ed->edApplication;
int format;
BufferDocument * bd;
if ( tedOpenDocumentFile( ea, &format, &bd, filename, relative, option ) )
{ SDEB(filename); return -1; }
switch( format )
{
case 0:
if ( tedIncludeRtfDocument( ed->edDocumentWidget, ed, bd ) )
{ LDEB(1); docFreeDocument( bd ); return -1; }
break;
case 1:
case 2:
if ( tedIncludePlainDocument( ed->edDocumentWidget, ed, bd ) )
{ LDEB(1); docFreeDocument( bd ); return -1; }
break;
default:
LDEB(format);
docFreeDocument( bd ); return -1;
}
docFreeDocument( bd );
appDocumentChanged( ed, 1 );
return 0;
}
void tedDocInsertFile( APP_WIDGET option,
void * voided,
void * voidpbcs )
{
EditDocument * ed= (EditDocument *)voided;
EditApplication * ea= ed->edApplication;
TedDocument * td= (TedDocument *)ed->edPrivateData;
if ( ! td->tdCanReplaceSelection )
{ LDEB(td->tdCanReplaceSelection); return; }
appRunOpenChooser( option, ed->edToplevel.atTopWidget,
ea->eaFileExtensionCount, ea->eaFileExtensions,
ea->eaDefaultFileFilter,
voided, tedInsertFile, ea );
return;
}
|