From: <ls...@us...> - 2006-12-10 19:10:18
|
Revision: 2886 http://jnode.svn.sourceforge.net/jnode/?rev=2886&view=rev Author: lsantha Date: 2006-12-10 11:10:11 -0800 (Sun, 10 Dec 2006) Log Message: ----------- Added tab handling and status line. Modified Paths: -------------- trunk/distr/src/apps/org/jnode/apps/editor/TextEditor.java Modified: trunk/distr/src/apps/org/jnode/apps/editor/TextEditor.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/editor/TextEditor.java 2006-12-10 17:40:01 UTC (rev 2885) +++ trunk/distr/src/apps/org/jnode/apps/editor/TextEditor.java 2006-12-10 19:10:11 UTC (rev 2886) @@ -45,16 +45,16 @@ te.loadFile(f); } - public TextEditor(TextConsole first) { - this.console = first; - first.addKeyboardListener(this); - console.setCursorVisible(true); + public TextEditor(TextConsole console) { + this.console = console; + console.addKeyboardListener(this); + this.console.setCursorVisible(true); cx = 0; cy = 0; - sh = first.getHeight(); - sw = first.getWidth(); + sh = console.getHeight(); + sw = console.getWidth(); cxm = sw - 1; - cym = sh - 1; + cym = sh - 1 - 1; fx = 0; fy = 0; ls = new ArrayList<StringBuilder>(); @@ -107,19 +107,61 @@ }); } + private void updateScreen(){ - char[] data = new char[sw * sh]; + char[] data = new char[sw * (cym + 1 + 1)]; int k = 0; StringBuilder e = new StringBuilder(); - for(int i = 0; i < sh; i ++){ + List<StringBuilder> rl = new ArrayList<StringBuilder>(); + for(int i = 0; i < cym + 1; i ++){ StringBuilder l = (fy + i < ls.size()) ? ls.get(fy + i) : e; + StringBuilder sb = new StringBuilder(); + for(int j = 0; j < l.length(); j++){ + char c = l.charAt(j); + if(c == '\t'){ + sb.append(' '); + sb.append(' '); + sb.append(' '); + sb.append(' '); + } else if(c == '\n'){ + sb.append(' '); + } else{ + sb.append(c); + } + } + rl.add(sb); + } + + int tab_count = 0; + if(ls.size() > 0){ + CharSequence l = ls.get(oy()).subSequence(0, fx + cx); + for(int i = 0; i < l.length(); i ++ ){ + if(l.charAt(i) == '\t') tab_count ++; + } + } + + int tx = fx + cx + 3 * tab_count; + int cx2 = cx + 3 * tab_count; + int fx2 = fx; + if(tx >= sw){ + cx2 = sw -1; + fx2 = tx - cx2; + } + + for(int i = 0; i < cym + 1; i ++){ + StringBuilder l = rl.get(i); for(int j = 0; j < sw; j++){ - char c = (fx + j < l.length()) ? l.charAt(fx + j) : ' '; - data[k++] = (c == '\n' || c == '\t') ? ' ' : c; + char c = (fx2 + j < l.length()) ? l.charAt(fx2 + j) : ' '; + data[k++] = c; } } + + e.append(file.getName()).append(" [").append(fx2 + cx2 + 1).append(",").append(oy() + 1).append("]"); + for(int j = 0; j < sw; j++){ + data[k++] = (j < e.length()) ? e.charAt(j) : ' '; + } console.setChar(0, 0, data, 7); - console.setCursor(cx, cy); + console.setCursor(cx2, cy); } public void keyPressed(KeyboardEvent e) { @@ -131,8 +173,8 @@ case KeyEvent.VK_LEFT: {if(fx > 0) fx --; break;} case KeyEvent.VK_RIGHT: {if(fx < mx()) fx ++; break;} case KeyEvent.VK_HOME: {cx = fx = cy = fy = 0; break;} - case KeyEvent.VK_END: { if(my() < cym) cy = my(); else {cy = cym; fy = my() - cy;}; end(); break;} - case KeyEvent.VK_Y: { ls.remove(oy()); if(oy() > my()) cy --; break;} + case KeyEvent.VK_END: { if(my() < cym) cy = my(); else {cy = cym; fy = my() - cy;} end(); break;} + case KeyEvent.VK_Y: { if(oy() >= 0 && oy() <= my()) {ls.remove(oy()); if(cy > 0) cy --; else if(fy > 0) fy --;} break;} case KeyEvent.VK_S: { saveFile(); break;} case KeyEvent.VK_Q: { console.getManager().unregisterConsole(console); break;} @@ -170,6 +212,11 @@ cx = l2.length() - 1; l2.deleteCharAt(l2.length() - 1).append(ls.remove(oy())); cy --; + } else if(fy > 0){ + StringBuilder l2 = ls.get(oy() - 1); + cx = l2.length() - 1; + l2.deleteCharAt(l2.length() - 1).append(ls.remove(oy())); + fy --; } } else if(cx > 0){ cx --; @@ -201,6 +248,7 @@ } if(oy() > my()){ fy -= oy() - my(); + fy = fy < 0 ? 0 : fy ; } if(ox() > mx()) { if(mx() > cxm){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2007-01-02 16:16:54
|
Revision: 2974 http://jnode.svn.sourceforge.net/jnode/?rev=2974&view=rev Author: lsantha Date: 2007-01-02 08:16:45 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Consume KeyboardEvents. Modified Paths: -------------- trunk/distr/src/apps/org/jnode/apps/editor/TextEditor.java Modified: trunk/distr/src/apps/org/jnode/apps/editor/TextEditor.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/editor/TextEditor.java 2006-12-30 19:32:30 UTC (rev 2973) +++ trunk/distr/src/apps/org/jnode/apps/editor/TextEditor.java 2007-01-02 16:16:45 UTC (rev 2974) @@ -259,6 +259,7 @@ fx = 0; } } + e.consume(); updateScreen(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2007-01-05 20:55:44
|
Revision: 2988 http://jnode.svn.sourceforge.net/jnode/?rev=2988&view=rev Author: lsantha Date: 2007-01-05 12:55:34 -0800 (Fri, 05 Jan 2007) Log Message: ----------- Fixed Ctrl-Y. Modified Paths: -------------- trunk/distr/src/apps/org/jnode/apps/editor/TextEditor.java Modified: trunk/distr/src/apps/org/jnode/apps/editor/TextEditor.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/editor/TextEditor.java 2007-01-04 20:29:43 UTC (rev 2987) +++ trunk/distr/src/apps/org/jnode/apps/editor/TextEditor.java 2007-01-05 20:55:34 UTC (rev 2988) @@ -174,7 +174,7 @@ case KeyEvent.VK_RIGHT: {if(fx < mx()) fx ++; break;} case KeyEvent.VK_HOME: {cx = fx = cy = fy = 0; break;} case KeyEvent.VK_END: { if(my() < cym) cy = my(); else {cy = cym; fy = my() - cy;} end(); break;} - case KeyEvent.VK_Y: { if(oy() >= 0 && oy() <= my()) {ls.remove(oy()); if(cy > 0) cy --; else if(fy > 0) fy --;} break;} + case KeyEvent.VK_Y: { if(oy() >= 0 && oy() <= my()) {ls.remove(oy()); if(cy > 0 && oy() == my() + 1) cy --; else if(fy > 0) fy --;} break;} case KeyEvent.VK_S: { saveFile(); break;} case KeyEvent.VK_Q: { console.getManager().unregisterConsole(console); break;} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ls...@us...> - 2007-03-08 21:08:32
|
Revision: 3136 http://jnode.svn.sourceforge.net/jnode/?rev=3136&view=rev Author: lsantha Date: 2007-03-08 13:08:29 -0800 (Thu, 08 Mar 2007) Log Message: ----------- Added support for console stacking. Modified Paths: -------------- trunk/distr/src/apps/org/jnode/apps/editor/TextEditor.java Modified: trunk/distr/src/apps/org/jnode/apps/editor/TextEditor.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/editor/TextEditor.java 2007-03-08 21:07:31 UTC (rev 3135) +++ trunk/distr/src/apps/org/jnode/apps/editor/TextEditor.java 2007-03-08 21:08:29 UTC (rev 3136) @@ -37,7 +37,9 @@ ShellManager sm = InitialNaming.lookup(ShellManager.NAME); TextScreenConsoleManager manager = (TextScreenConsoleManager) sm.getCurrentShell().getConsole().getManager(); TextConsole console = manager.createConsole("editor", - ConsoleManager.CreateOptions.TEXT |ConsoleManager.CreateOptions.NO_SYSTEM_OUT_ERR_IN); + ConsoleManager.CreateOptions.TEXT | + ConsoleManager.CreateOptions.STACKED | + ConsoleManager.CreateOptions.NO_SYSTEM_OUT_ERR_IN); manager.focus(console); TextEditor te = new TextEditor(console); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |