Mercurial > hg > RemoteEditor > vim7
changeset 37:2820e371ab4b ack-mode-protocol
ack-mode protocol
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 26 Nov 2008 18:19:53 +0900 |
parents | 767b24658df0 |
children | e06a1cd7230d |
files | src/auto/config.h src/reditor.c src/reditor.h |
diffstat | 3 files changed, 20 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/src/auto/config.h Wed Nov 26 15:02:37 2008 +0900 +++ b/src/auto/config.h Wed Nov 26 18:19:53 2008 +0900 @@ -318,7 +318,7 @@ /* #undef FEAT_CSCOPE */ /* Define if you want to include multibyte support. */ -/* #undef FEAT_MBYTE */ +#define FEAT_MBYTE 1 /* Define if you want to include fontset support. */ /* #undef FEAT_XFONTSET */
--- a/src/reditor.c Wed Nov 26 15:02:37 2008 +0900 +++ b/src/reditor.c Wed Nov 26 18:19:53 2008 +0900 @@ -869,7 +869,7 @@ // ml_delete case char *text = get_memline_wrp(cursn->buf, lnum); unsigned int length = strlen(text); - cmd = make_cmd(REPCMD_DELETE, cursn->sid, rep->eid, rep->seqno++, + cmd = make_cmd(REPCMD_DELETE_USER, cursn->sid, rep->eid, rep->seqno++, cursn->prevline-1, length, text); rep_send_cmd(rep->smfd,cmd); rep_free(cmd); @@ -884,7 +884,7 @@ return; // already line saved do nothing char *text = get_memline_wrp(cursn->buf, lnum); unsigned int length = strlen(text); - cursn->del_cmd = make_cmd(REPCMD_DELETE, cursn->sid, rep->eid, + cursn->del_cmd = make_cmd(REPCMD_DELETE_USER, cursn->sid, rep->eid, rep->seqno++, cursn->prevline-1, length, text); } else { @@ -928,7 +928,7 @@ char *text = get_memline_wrp(cursn->buf, i); unsigned int length = strlen(text); // make INSERT_CMD for insert or changed lines if any - cmd = make_cmd(REPCMD_INSERT, cursn->sid, rep->eid, rep->seqno++, + cmd = make_cmd(REPCMD_INSERT_USER, cursn->sid, rep->eid, rep->seqno++, i-1, length, text); rep_send_cmd(rep->smfd,cmd); free_cmd(cmd); @@ -951,12 +951,12 @@ // send saved new line as INSERT command char *text = get_memline_wrp(cursn->buf, lnum); unsigned int length = strlen(text); - cmd = make_cmd(REPCMD_INSERT, cursn->sid, rep->eid, rep->seqno++, + cmd = make_cmd(REPCMD_INSERT_USER, cursn->sid, rep->eid, rep->seqno++, cursn->prevline-1, length,text); rep_send_cmd(rep->smfd,cmd); // reuse cmd // save current line for next replace - set_cmd_seq(cmd,REPCMD_DELETE,rep->seqno++); + set_cmd_seq(cmd,REPCMD_DELETE_USER,rep->seqno++); cursn->del_cmd = cmd; } @@ -971,13 +971,13 @@ if (rep->syncMode!=0) { char *text = get_memline_wrp(cursn->buf, rep->syncMode); unsigned int length = strlen(text); - rep_cmd *cmd = make_cmd(REPCMD_DELETE, cursn->sid, rep->eid, + rep_cmd *cmd = make_cmd(REPCMD_DELETE_USER, cursn->sid, rep->eid, rep->seqno++, rep->syncMode, length,text); rep_send_cmd(rep->smfd,cmd); // reuse cmd // save current line for next replace - set_cmd_seq(cmd,REPCMD_INSERT,rep->seqno++); + set_cmd_seq(cmd,REPCMD_INSERT_USER,rep->seqno++); rep_send_cmd(rep->smfd,cmd); free_cmd(cmd); if (rep->syncMode < get_bufmaxline_wrp(cursn->buf)) { @@ -1053,21 +1053,6 @@ rep->seqno++; } -static void -addNop(int sid, rep_T *rep) -{ - int fd = rep->smfd; - char *packet = &rep->nop->pkt[0]; - - if (rep->prevSeq==rep->seqno) { - set_header(sid, packet, REP_SID_OFFSET); - set_header(rep->eid, packet, REP_EID_OFFSET); - set_header(rep->seqno, packet, REP_SEQNUM_OFFSET); - rep->prevSeq = rep->seqno; - incrementSeq(rep); - writen(fd,rep->nop->pkt,rep->nop->len+REP_HEADER_SIZE); - } -} static int rep_exe_cmd(command) @@ -1115,16 +1100,18 @@ break; case REPCMD_INSERT: - append_memline_wrp(command->lnum, text); - if (eid!=MERGE_EID) addNop(command->sid, rep); + if (command->eid!=rep->eid) append_memline_wrp(command->lnum, text); forwardCommand(rep,command); - if (eid!=MERGE_EID) update_screen_now_wrp(); + if (eid!=MERGE_EID && command->eid!=rep->eid) update_screen_now_wrp(); break; case REPCMD_DELETE: - delete_memline_wrp(command->lnum); - if (eid!=MERGE_EID) update_screen_now_wrp(); + if (command->eid!=rep->eid) { + delete_memline_wrp(command->lnum); + if (eid!=MERGE_EID) update_screen_now_wrp(); + } case REPCMD_NOP: - if (eid!=MERGE_EID) addNop(command->sid, rep); + case REPCMD_INSERT_ACK: + case REPCMD_DELETE_ACK: forwardCommand(rep,command); break; case SMCMD_SYNC: @@ -1144,6 +1131,8 @@ lock_editor = 0; rep->prevSeq = rep->seqno; update_screen_now_wrp(); + case SMCMD_QUIT_2: + // close session.... default: break; }
--- a/src/reditor.h Wed Nov 26 15:02:37 2008 +0900 +++ b/src/reditor.h Wed Nov 26 18:19:53 2008 +0900 @@ -4,8 +4,10 @@ #define MAX_FDS 10 +#define REPCMD_INSERT_USER ( 5) #define REPCMD_INSERT ( 6) #define REPCMD_INSERT_ACK ( 7) +#define REPCMD_DELETE_USER ( 8) #define REPCMD_DELETE ( 9) #define REPCMD_DELETE_ACK ( 10) #define REPCMD_CLOSE ( 11)