/*** Join two lines and strip spaces on the next ***/ void join_strip( Project p ) { LINE *ln; if((ln = p->edited->next) != NULL) { STRPTR data; ULONG i; inv_curs(p, FALSE); p->nbc = p->edited->size; for(i=0, data=ln->stream; TypeChar[*data] == SPACE && i<ln->size; i++, data++); reg_group_by(&p->undo); if(i != ln->size) { /* Do not add a blank if there is already one */ if( p->nbc > 0 && TypeChar[ p->edited->stream[ p->nbc-1 ] ] != SPACE ) add_char(&p->undo, p->edited, p->nbc, ' '); if( insert_str(&p->undo, p->edited, p->edited->size, data, ln->size-i) == 0 ) ThrowError(Wnd, ErrMsg(ERR_NOMEM)); } /* ln can't be the first */ del_line(&p->undo, NULL, ln); p->max_lines--; reg_group_by(&p->undo); prop_adj(p); /* Refresh screen */ p->nbrc = p->nbrwc = x2pos(p->edited, p->nbc); REDRAW_CURLINE( p ); draw_info( p ); scroll_up(p, p->edited->next, p->ycurs, center_horiz(p)); inv_curs(p,TRUE); } }
/*** Reads the next CHRS chunk from clipboard ***/ BOOL CBReadCHRS( void *jbuf, LINE *st, ULONG pos, LONG *nbl ) { struct ContextNode * cn; BOOL ret = FALSE; /* If clipboard not already allocated, makes it now */ if( clip == NULL && !CBOpen(STD_CLIP_UNIT) ) return FALSE; if( !OpenIFF(clip, IFFF_READ) ) { if( !StopChunk(clip, ID_FTXT, ID_CHRS) ) { if( !ParseIFF(clip, IFFPARSE_SCAN) ) { cn = CurrentChunk(clip); if( cn->cn_Type == ID_FTXT && cn->cn_ID == ID_CHRS && cn->cn_Size > 0 ) { STRPTR buf; ULONG size = cn->cn_Size; if( (buf = (STRPTR) AllocVec(size, MEMF_PUBLIC)) ) { UBYTE eol; ReadChunkBytes(clip, buf, size); /* What's kind of paste method shall we used? */ { register STRPTR s; register ULONG n; for(s=buf,n=size; --n && *s!='\n' && *s!='\r'; s++); eol = *s; } /* Add string to the buffer */ reg_group_by(jbuf); if(eol == '\n') add_string(jbuf,st,pos,buf,size,nbl) ; else add_block (jbuf,st,pos,buf,size,nbl) ; reg_group_by(jbuf); FreeVec(buf); ret = TRUE; } else ThrowError(Wnd, ErrMsg(ERR_NOMEM)); } else ThrowError(Wnd, ErrMsg(ERR_NOTXTINCLIP)); } else ThrowError(Wnd, ErrMsg(ERR_NOTXTINCLIP)); } else ThrowError(Wnd, ErrMsg(ERR_NOMEM)); CloseIFF(clip); } /* ThrowError(Wnd, ErrMsg(ERR_READCLIP)); */ return ret; }