Mercurial > hg > RemoteEditor > Eclipse
changeset 127:6f174e2b7503
*** empty log message ***
author | pin |
---|---|
date | Mon, 07 Jan 2008 05:41:45 +0900 |
parents | b56b5950cb18 |
children | 75fc44fda583 |
files | bin/remoteeditor/editors/RemoteEditor$1.class bin/remoteeditor/editors/RemoteEditor.class src/remoteeditor/editors/RemoteEditor.java |
diffstat | 3 files changed, 39 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/remoteeditor/editors/RemoteEditor.java Tue Dec 25 20:52:18 2007 +0900 +++ b/src/remoteeditor/editors/RemoteEditor.java Mon Jan 07 05:41:45 2008 +0900 @@ -159,33 +159,56 @@ try { sendInsert(line); } catch (BadLocationException e) { - // TODO Auto-generated catch block e.printStackTrace(); } -// if(inputText.equals("\n")){ -// line--; -// } -// lineText = inputText; - //line += 1; + }else if(numberOfLinesNew == numberOfLinesOld){ cmd = REP.REPCMD_REPLACE; + try { + sendReplace(line); + } catch (BadLocationException e) { + e.printStackTrace(); + } }else { cmd = REP.REPCMD_DELETE; + try { + sendDelete(line); + } catch (BadLocationException e) { + e.printStackTrace(); + } } //rep.sendCmd(cmd, line, length, lineText); - if(!lock){ - REPCommand usercmd = new REPCommand(cmd, mysid, myeid, myseq, line, lineText.length(), lineText); - repsend.send(usercmd); - //translate.addUserList(usercmd); - trans.addUserList(usercmd); - //System.out.println("User List" + userCmdList.toString()); - //System.out.println("Token List" + tokenCmdList.toString()); - }else{ - - } +// if(!lock){ +// REPCommand usercmd = new REPCommand(cmd, mysid, myeid, myseq, line, lineText.length(), lineText); +// repsend.send(usercmd); +// //translate.addUserList(usercmd); +// trans.addUserList(usercmd); +// //System.out.println("User List" + userCmdList.toString()); +// //System.out.println("Token List" + tokenCmdList.toString()); +// }else{ } numberOfLinesOld = numberOfLinesNew; } + private void sendDelete(int line) throws BadLocationException { + if(!lock){ + int offset = document.getLineOffset(line-1); + int length = document.getLineLength(line-1); + String lineText = document.get(offset, length); + REPCommand usercmd = new REPCommand(REP.REPCMD_DELETE, mysid, myeid, myseq, line, lineText.length(), lineText); + repsend.send(usercmd); + } + } + + private void sendReplace(int line) throws BadLocationException { + if(!lock){ + int offset = document.getLineOffset(line-1); + int length = document.getLineLength(line-1); + String lineText = document.get(offset, length); + REPCommand usercmd = new REPCommand(REP.REPCMD_REPLACE, mysid, myeid, myseq, line, lineText.length(), lineText); + repsend.send(usercmd); + } + } + private void sendInsert(int line) throws BadLocationException { if(!lock){ int offset = document.getLineOffset(line-1);