mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-17 23:06:25 -05:00
Quick Mac Hack: add Mac mode for CR only EOL.
This commit is contained in:
parent
22e26fc885
commit
d60640af0f
12
buffer.c
12
buffer.c
@ -28,7 +28,7 @@ buffer_p blistp ; /* Buffer for C-X C-B */
|
|||||||
const char *modename[ NUMMODES] = { /* name of modes */
|
const char *modename[ NUMMODES] = { /* name of modes */
|
||||||
"Wrap", "Cmode", "Exact", "View", "Over",
|
"Wrap", "Cmode", "Exact", "View", "Over",
|
||||||
"Magic",
|
"Magic",
|
||||||
"Asave", "Utf-8", "Dos"
|
"Asave", "Utf-8", "Dos", "Mac"
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
int gmode = 0 ; /* global editor mode */
|
int gmode = 0 ; /* global editor mode */
|
||||||
@ -294,8 +294,8 @@ BINDABLE( listbuffers) {
|
|||||||
int iflag; list hidden buffer flag
|
int iflag; list hidden buffer flag
|
||||||
*/
|
*/
|
||||||
/* Layout: "ACT MODES Size Buffer File"
|
/* Layout: "ACT MODES Size Buffer File"
|
||||||
AAA MMMMMMMMMSSSSSSSSSS BBBBBBBBBBBBBBB FFF...
|
AAA MMMMMMMMMMSSSSSSSSSS BBBBBBBBBBBBBBB FFF...
|
||||||
FNAMSTART ---------------------------------------^
|
FNAMSTART ----------------------------------------^
|
||||||
*/
|
*/
|
||||||
#define FNAMSTART (3 + 1 + NUMMODES + 10 + 1 + (sizeof( bname_t) - 1) + 1)
|
#define FNAMSTART (3 + 1 + NUMMODES + 10 + 1 + (sizeof( bname_t) - 1) + 1)
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ static void do_layout( char *line, int mode) {
|
|||||||
int i ;
|
int i ;
|
||||||
|
|
||||||
/* build line to report global mode settings */
|
/* build line to report global mode settings */
|
||||||
strcpy( line, " WCEVOMAUD Global Modes") ;
|
strcpy( line, " WCEVOmAUDM Global Modes") ;
|
||||||
|
|
||||||
/* output the mode codes */
|
/* output the mode codes */
|
||||||
for( i = 0 ; i < NUMMODES ; i++)
|
for( i = 0 ; i < NUMMODES ; i++)
|
||||||
@ -377,8 +377,8 @@ static int makelist( int iflag) {
|
|||||||
if( bp->b_mode & MDDOS)
|
if( bp->b_mode & MDDOS)
|
||||||
nbytes += nlines ;
|
nbytes += nlines ;
|
||||||
|
|
||||||
l_to_a( &line[ 13], 10 + 1, nbytes) ; /* "%10d" formatted numbers */
|
l_to_a( &line[ 14], 10 + 1, nbytes) ; /* "%10d" formatted numbers */
|
||||||
cp1 = &line[ 23] ;
|
cp1 = &line[ 24] ;
|
||||||
*cp1++ = ' ' ;
|
*cp1++ = ' ' ;
|
||||||
|
|
||||||
/* Display buffer name */
|
/* Display buffer name */
|
||||||
|
3
buffer.h
3
buffer.h
@ -44,7 +44,7 @@ extern buffer_p blistp ; /* Buffer for C-X C-B */
|
|||||||
#define BFTRUNC 0x04 /* buffer was truncated when read */
|
#define BFTRUNC 0x04 /* buffer was truncated when read */
|
||||||
|
|
||||||
/* mode flags */
|
/* mode flags */
|
||||||
#define NUMMODES 9 /* # of defined modes */
|
#define NUMMODES 10 /* # of defined modes */
|
||||||
|
|
||||||
#define MDWRAP 0x0001 /* word wrap */
|
#define MDWRAP 0x0001 /* word wrap */
|
||||||
#define MDCMOD 0x0002 /* C indentation and fence match */
|
#define MDCMOD 0x0002 /* C indentation and fence match */
|
||||||
@ -55,6 +55,7 @@ extern buffer_p blistp ; /* Buffer for C-X C-B */
|
|||||||
#define MDASAVE 0x0040 /* auto-save mode */
|
#define MDASAVE 0x0040 /* auto-save mode */
|
||||||
#define MDUTF8 0x0080 /* utf8 mode */
|
#define MDUTF8 0x0080 /* utf8 mode */
|
||||||
#define MDDOS 0x0100 /* CRLF eol mode */
|
#define MDDOS 0x0100 /* CRLF eol mode */
|
||||||
|
#define MDMAC 0x0200 /* CR eol mode */
|
||||||
|
|
||||||
extern const char *modename[ NUMMODES] ; /* text names of modes */
|
extern const char *modename[ NUMMODES] ; /* text names of modes */
|
||||||
extern int gmode ; /* global editor mode */
|
extern int gmode ; /* global editor mode */
|
||||||
|
3
file.c
3
file.c
@ -310,6 +310,7 @@ int readin( const char *fname, boolean lockfl) {
|
|||||||
break ;
|
break ;
|
||||||
case FTYPE_MAC:
|
case FTYPE_MAC:
|
||||||
found_eol = EOL_MAC ;
|
found_eol = EOL_MAC ;
|
||||||
|
curbp->b_mode |= MDMAC ;
|
||||||
break ;
|
break ;
|
||||||
case FTYPE_NONE:
|
case FTYPE_NONE:
|
||||||
found_eol = EOL_NONE ;
|
found_eol = EOL_NONE ;
|
||||||
@ -474,7 +475,7 @@ int writeout( const char *fn) {
|
|||||||
|
|
||||||
mloutstr( "(Writing...)") ; /* tell us we are writing */
|
mloutstr( "(Writing...)") ; /* tell us we are writing */
|
||||||
for( lp = lforw( curbp->b_linep) ; lp != curbp->b_linep ; lp = lforw( lp)) {
|
for( lp = lforw( curbp->b_linep) ; lp != curbp->b_linep ; lp = lforw( lp)) {
|
||||||
s = ffputline( lp->l_text, llength( lp), curbp->b_mode & MDDOS) ;
|
s = ffputline( lp->l_text, llength( lp), curbp->b_mode >> 8) ; // Mack Hack
|
||||||
if( s != FIOSUC)
|
if( s != FIOSUC)
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
|
5
fileio.c
5
fileio.c
@ -66,12 +66,13 @@ fio_code ffclose( void) {
|
|||||||
buffer, and the "nbuf" is its length, less the free newline. Return the
|
buffer, and the "nbuf" is its length, less the free newline. Return the
|
||||||
status. Check only at the newline.
|
status. Check only at the newline.
|
||||||
*/
|
*/
|
||||||
fio_code ffputline( char *buf, int nbuf, int dosflag) {
|
fio_code ffputline( char *buf, int nbuf, int eolflag) {
|
||||||
fwrite( buf, 1, nbuf, ffp) ;
|
fwrite( buf, 1, nbuf, ffp) ;
|
||||||
|
|
||||||
if( dosflag)
|
if( eolflag) // DOS and Mac
|
||||||
fputc( '\r', ffp) ;
|
fputc( '\r', ffp) ;
|
||||||
|
|
||||||
|
if( eolflag != 2) // Not Mac
|
||||||
fputc( '\n', ffp) ;
|
fputc( '\n', ffp) ;
|
||||||
|
|
||||||
if( ferror( ffp))
|
if( ferror( ffp))
|
||||||
|
2
fileio.h
2
fileio.h
@ -28,7 +28,7 @@ extern int fpayload ; /* actual length of fline content */
|
|||||||
|
|
||||||
fio_code ffclose( void) ;
|
fio_code ffclose( void) ;
|
||||||
fio_code ffgetline( void) ;
|
fio_code ffgetline( void) ;
|
||||||
fio_code ffputline( char *buf, int nbuf, int dosflag) ;
|
fio_code ffputline( char *buf, int nbuf, int eolflag) ;
|
||||||
fio_code ffropen( const char *fn) ;
|
fio_code ffropen( const char *fn) ;
|
||||||
fio_code ffwopen( const char *fn) ;
|
fio_code ffwopen( const char *fn) ;
|
||||||
|
|
||||||
|
2
line.c
2
line.c
@ -517,7 +517,7 @@ boolean lnewline( void) {
|
|||||||
*/
|
*/
|
||||||
int lgetchar( unicode_t *cp) {
|
int lgetchar( unicode_t *cp) {
|
||||||
if( curwp->w_dotp->l_used == curwp->w_doto) { /* at EOL? */
|
if( curwp->w_dotp->l_used == curwp->w_doto) { /* at EOL? */
|
||||||
*cp = (curbp->b_mode & MDDOS) ? '\r' : '\n' ;
|
*cp = (curbp->b_mode & (MDDOS | MDMAC)) ? '\r' : '\n' ;
|
||||||
return 1 ;
|
return 1 ;
|
||||||
} else
|
} else
|
||||||
return utf8_to_unicode( curwp->w_dotp->l_text, curwp->w_doto,
|
return utf8_to_unicode( curwp->w_dotp->l_text, curwp->w_doto,
|
||||||
|
11
random.c
11
random.c
@ -814,10 +814,17 @@ static int adjustmode( int kind, int global) {
|
|||||||
if( strcasecmp( cbuf, modename[ i]) == 0) {
|
if( strcasecmp( cbuf, modename[ i]) == 0) {
|
||||||
/* finding a match, we process it */
|
/* finding a match, we process it */
|
||||||
if (kind == TRUE)
|
if (kind == TRUE)
|
||||||
if (global)
|
if (global) {
|
||||||
|
if( i > 7) // Mac Hack
|
||||||
|
gmode &= 0xFF ;
|
||||||
|
|
||||||
gmode |= (1 << i);
|
gmode |= (1 << i);
|
||||||
else
|
} else {
|
||||||
|
if( i > 7) //Mac Hack
|
||||||
|
curbp->b_mode &= 0xFF ;
|
||||||
|
|
||||||
curbp->b_mode |= (1 << i);
|
curbp->b_mode |= (1 << i);
|
||||||
|
}
|
||||||
else if (global)
|
else if (global)
|
||||||
gmode &= ~(1 << i);
|
gmode &= ~(1 << i);
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user