Changeset 301 for trunk/dll/mle.c


Ignore:
Timestamp:
Jun 27, 2006, 2:19:38 AM (19 years ago)
Author:
root
Message:

MLEexportfile: rework to avoid wrap problems

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/mle.c

    r123 r301  
    99  Copyright (c) 2004 Steven H.Levine
    1010
    11   Revisions     01 Aug 04 SHL - Rework lstrip/rstrip usage
     11  01 Aug 04 SHL Rework lstrip/rstrip usage
     12  16 Apr 06 SHL MLEexportfile: rework to avoid wrap problems
    1213
    1314***********************************************************************/
     
    3940
    4041
    41 LONG MLEgetlinetext (HWND h,LONG l,CHAR *buf,INT maxlen) {
    42 
     42LONG MLEgetlinetext (HWND h,LONG l,CHAR *buf,INT maxlen)
     43{
    4344  /* get text of line l from MLE */
    4445
     
    5152
    5253
    53 LONG MLEdeleteline (HWND h,LONG l) {
    54 
     54LONG MLEdeleteline (HWND h,LONG l)
     55{
    5556  /* delete line l from MLE */
    5657
     
    6364
    6465
    65 LONG MLEdeletecurline (HWND h) {
    66 
     66LONG MLEdeletecurline (HWND h)
     67{
    6768  /* delete current line from MLE */
    6869
     
    7475
    7576
    76 LONG MLEdeletetoeol (HWND h) {
    77 
     77LONG MLEdeletetoeol (HWND h)
     78{
    7879  /* delete from cursor pos to end of line */
    7980
     
    8889
    8990
    90 VOID MLEclearall (HWND h) {
    91 
     91VOID MLEclearall (HWND h)
     92{
    9293  /* remove all text from MLE */
    9394  LONG len;
     
    99100
    100101
    101 LONG MLEtextatcursor (HWND h,CHAR *buffer,INT buflen) {
    102 
     102LONG MLEtextatcursor (HWND h,CHAR *buffer,INT buflen)
     103{
    103104  /* place up to buflen chars of text from cursor pos into buffer
    104105   * return # of chars imported
     
    112113
    113114
    114 LONG MLEtextatpos (HWND h,IPT i,CHAR *buffer,INT buflen) {
    115 
     115LONG MLEtextatpos (HWND h,IPT i,CHAR *buffer,INT buflen)
     116{
    116117  /* place up to buflen chars of text from pos i in buffer
    117118   * return # of chars imported
     
    126127
    127128
    128 LONG MLEsizeofsel (HWND h) {
    129 
     129LONG MLEsizeofsel (HWND h)
     130{
    130131  /* return length of selected text */
    131132
     
    146147#pragma alloc_text(FMMLE3,MLEdoblock,MLEquotepara,MLEinternet)
    147148
    148 VOID MLEinternet (HWND h,BOOL ftp) {
    149 
     149VOID MLEinternet (HWND h,BOOL ftp)
     150{
    150151  CHAR *temp = NULL;
    151152  IPT   ancpos,curpos,here;
     
    196197
    197198
    198 BOOL MLEdoblock (HWND h,INT action,CHAR *filename) {
    199 
     199BOOL MLEdoblock (HWND h,INT action,CHAR *filename)
     200{
    200201  /* perform action on text in selection */
    201202
     
    385386
    386387
    387 BOOL MLEquotepara (HWND h,CHAR *initials,BOOL fQuoteOld) {
    388 
     388BOOL MLEquotepara (HWND h,CHAR *initials,BOOL fQuoteOld)
     389{
    389390  LONG num;
    390391  CHAR lineend[2],line[8],*p;
     
    422423
    423424
    424 BOOL MLEAutoLoad (HWND h,CHAR *filename) {
    425 
     425BOOL MLEAutoLoad (HWND h,CHAR *filename)
     426{
    426427  XMLEWNDPTR *vw;
    427428
     
    440441
    441442
    442 BOOL MLEHexLoad (HWND h,CHAR *filename) {
    443 
     443BOOL MLEHexLoad (HWND h,CHAR *filename)
     444{
    444445  /* insert a file into the current position in the MLE */
    445446
     
    581582
    582583
    583 BOOL MLEinsertfile (HWND h,CHAR *filename) {
    584 
     584BOOL MLEinsertfile (HWND h,CHAR *filename)
     585{
    585586  /* insert a file into the current position in the MLE */
    586587
     
    755756
    756757
    757 VOID LoadThread (VOID *arg) {
    758 
     758VOID LoadThread (VOID *arg)
     759{
    759760  BKGLOAD *bkg;
    760761  BOOL     fSuccess;
     
    819820#pragma alloc_text(FMMLE5,MLEloadfile,MLEexportfile)
    820821
    821 BOOL MLEloadfile (HWND h,CHAR *filename) {
    822 
     822BOOL MLEloadfile (HWND h,CHAR *filename)
     823{
    823824  /* load a file into the MLE, getting rid of whatever was already
    824825   * there.  Note this returns without erasing existing text if the
     
    841842
    842843BOOL MLEexportfile (HWND h,CHAR *filename,INT tabspaces,
    843                     BOOL striptraillines,BOOL striptrailspaces) {
    844 
     844                    BOOL striptraillines,BOOL striptrailspaces)
     845{
    845846  /* save the MLE contents as a file.  Format the output so that
    846847   * the file is CR/LF terminated as presented in the MLE.
    847848   */
    848849
    849   FILE *fp;
    850   CHAR *buffer = NULL,*p;
    851   BOOL retn = TRUE;
     850  FILE *fp = NULL;
     851  CHAR *buffer = NULL;
     852  CHAR *p;
     853  BOOL ok = TRUE;
    852854  INT  blanklines = 0;
    853 
    854 // saymsg(MB_ENTER,h,DEBUG_STRING,"len = %ld",MLEgetlen(h));
     855  BOOL fWrap = MLEgetwrap(h);
     856
     857  // saymsg(MB_ENTER,h,DEBUG_STRING,"len = %ld",MLEgetlen(h));
    855858  if(!MLEgetlen(h))   /* nothing to save; forget it */
    856859    return TRUE;
     860
     861  MLEsetwrap(h, FALSE);         // Need wrap off to export MLFIE_NOTRANS
    857862
    858863  if(striptraillines) {
     
    868873        break;
    869874    }
    870     if(!MLEgetlen(h))   /* nothing to save; forget it */
     875    if(!MLEgetlen(h))
     876    {
     877      /* nothing to save; forget it */
     878      MLEsetwrap(h, fWrap);             // Restore
    871879      return TRUE;
     880    }
    872881  }
    873882
     
    935944        }
    936945        strcat(buffer,"\n");
    937 //        buffer = translate_out(buffer,4095,h,filename);
     946        // buffer = translate_out(buffer,4095,h,filename);
    938947        if(fwrite(buffer,1,strlen(buffer),fp) < 1) {
    939948          saymsg(MB_ENTER,
     
    943952          break;
    944953        }
    945       }
    946       fclose(fp);
     954      } // for lines
    947955    }
    948956    else
    949       retn = FALSE;
     957      ok = FALSE;
     958  }
     959  else
     960    ok = FALSE;
     961
     962  MLEsetwrap(h, fWrap);         // Restore
     963
     964  if (fp)
     965    fclose(fp);
     966  if (buffer)
    950967    DosFreeMem(buffer);
    951   }
    952   else
    953     retn = FALSE;
    954   return retn;
     968
     969  return ok;
    955970}
    956971
     
    958973#pragma alloc_text(FMMLE3,MLEfindfirst,MLEfindnext,SandRDlgProc)
    959974
    960 MRESULT EXPENTRY SandRDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2) {
    961 
     975MRESULT EXPENTRY SandRDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
     976{
    962977  /* initiate search(/replace)s in edit mode */
    963978
     
    10961111
    10971112
    1098 BOOL MLEfindfirst (HWND hwnd,SRCHPTR *vw) {
    1099 
     1113BOOL MLEfindfirst (HWND hwnd,SRCHPTR *vw)
     1114{
    11001115  if(MLEsizeofsel(vw->hwndmle) < 256L) {
    11011116    MLEgetseltext(vw->hwndmle,vw->search);
     
    11091124
    11101125
    1111 INT MLEfindnext (HWND hwnd,SRCHPTR *vw) {
    1112 
     1126INT MLEfindnext (HWND hwnd,SRCHPTR *vw)
     1127{
    11131128  if(!*vw->search)
    11141129    return -1;
     
    11421157  return 0;
    11431158}
    1144 
Note: See TracChangeset for help on using the changeset viewer.