]> code.citadel.org Git - citadel.git/commitdiff
Limited the length of lines that enterPanel would send for ent0
authorChilly <chilly@uncensored.citadel.org>
Wed, 11 Aug 1999 02:12:13 +0000 (02:12 +0000)
committerChilly <chilly@uncensored.citadel.org>
Wed, 11 Aug 1999 02:12:13 +0000 (02:12 +0000)
shaggy/enterPanel.java

index a5caded27bfb409277ffaf53b2519b78a7986cfc..f4ddf1912672cb66153f0b7be90c063d23e7e412 100644 (file)
@@ -59,8 +59,10 @@ public class enterPanel extends JPanel{
                if( ri.mail ) cmd = cmd + to.getText();
                cmd = cmd+"|0|0|0";
 
-               System.out.println( msg.getText() );
-               citadel.me.networkEvent( cmd, msg.getText(), new CallBack() {
+               String  theMsg = wrap( msg.getText() );
+
+               System.out.println( theMsg );
+               citadel.me.networkEvent( cmd, theMsg, new CallBack() {
                    public void run( citReply r ) {
                        if( r.error() )
                            citadel.me.warning( r.getArg(0) );
@@ -85,4 +87,20 @@ public class enterPanel extends JPanel{
 
        to.setEnabled( ri.mail );
     }
+
+    public String wrap( String in ) {
+       StringBuffer    b = new StringBuffer( in );
+       int     last_space = 0, line_length=0;
+       for( int i = 0; i < b.length(); i++ ) {
+           line_length++;
+           if( line_length > 76 ) {
+               b.setCharAt( last_space, '\n' );
+               line_length = 0;
+           }
+
+           if( b.charAt(i) == ' ' )
+               last_space = i;
+       }
+       return b.toString();
+    }
 }