Author Topic: Code Formatting  (Read 1305 times)

0 Members and 1 Guest are viewing this topic.

Jeff H

  • King Gator
  • Posts: 4025
Code Formatting
« on: August 11, 2011, 04:18:22 pm »
This started happening at Cadtutor and now here.
Pasting code from VS2010 to here does this
 
Code: [Select]
 

                  [CommandMethod("CaptureKeys")]         public void CaptureKeys()         {             Application.PreTranslateMessage +=               new PreTranslateMessageEventHandler(KeyHandler);         }         [CommandMethod("StopCaptureKeys")]         public void StopCaptureKeys()         {             Application.PreTranslateMessage -=               new PreTranslateMessageEventHandler(KeyHandler);         }         void KeyHandler(object sender, PreTranslateMessageEventArgs e)         {             Document doc = Application.DocumentManager.MdiActiveDocument;             Editor ed = doc.Editor;             if (e.Message.message == WM_KEYDOWN &&                 (e.Message.wParam.ToInt32() >= 37 &&                 e.Message.wParam.ToInt32() <= 40))             {                 e.Handled = true;                 switch (e.Message.wParam.ToInt32())                 {                     case 37:                         ed.WriteMessage("\nLeft Arrow");                         break;                     case 38:                         ed.WriteMessage("\nUp Arrow");                         break;                     case 39:                         ed.WriteMessage("\nRight Arrow");                         break;                     case 40:                         ed.WriteMessage("\nDown Arrow");                         break;                     default:                         break;                 }                        }         }         

 
Must paste in Notepad then copy from there and paste to get
 
Code: [Select]

         [CommandMethod("CaptureKeys")]
 
        public void CaptureKeys()
        {
 
            Application.PreTranslateMessage +=
 
              new PreTranslateMessageEventHandler(KeyHandler);
 
        }
 
        [CommandMethod("StopCaptureKeys")]
 
        public void StopCaptureKeys()
        {
 
            Application.PreTranslateMessage -=
 
              new PreTranslateMessageEventHandler(KeyHandler);
 
        }
 
 
        void KeyHandler(object sender, PreTranslateMessageEventArgs e)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
 
            if (e.Message.message == WM_KEYDOWN &&
 
                (e.Message.wParam.ToInt32() >= 37 &&
 
                e.Message.wParam.ToInt32() <= 40))
            {
                e.Handled = true;
                switch (e.Message.wParam.ToInt32())
                {
                    case 37:
                        ed.WriteMessage("\nLeft Arrow");
                        break;
                    case 38:
                        ed.WriteMessage("\nUp Arrow");
                        break;
                    case 39:
                        ed.WriteMessage("\nRight Arrow");
                        break;
                    case 40:
                        ed.WriteMessage("\nDown Arrow");
                        break;
                    default:
                        break;
 
                }
         
            }
 
        }


Another thing is since this starting to happen the editor picks up the color while creating post but does not persist inside or outside tags
pic as example

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 15874
  • Superior Stupidity at its best
Re: Code Formatting
« Reply #1 on: September 07, 2011, 02:48:51 pm »
The problem with the code tags is that the height of the code window is affected by the width of the code window. If you change the code to have shorter lines, the strange height problem goes away.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

BlackBox

  • Water Moccasin
  • Posts: 2261
Re: Code Formatting
« Reply #2 on: September 09, 2011, 11:17:37 am »
From VS IDE (I opened VB.NET 2010 Express), go to:

Options (Check "Show all settings") --> Text Editor --> Basic --> Tabs --> Select "Insert spaces" radio button.

"Potential has a shelf life." - Margaret Atwood

Jeff H

  • King Gator
  • Posts: 4025
Re: Code Formatting
« Reply #3 on: September 09, 2011, 11:32:49 am »
I have that already set.

BlackBox

  • Water Moccasin
  • Posts: 2261
Re: Code Formatting
« Reply #4 on: September 09, 2011, 11:34:54 am »
I have that already set.

Well I'm not sure what settings you have that may be different, my friend.

Here's a snippet directly copied from VB.NET 2010 Express, and pasted in my reply CODE tags:

Code: [Select]
Imports Autodesk.AutoCAD.Runtime

'Imports System
'Imports System.IO

Public Class _Foo
    Shared Sub _OpenFile(ByVal filePath As String)
        System.Diagnostics.Process.Start(filePath)
    End Sub

    <CommandMethod("OpenFile")> _
    Public Sub OpenFile()
        _OpenFile("<FilePath>\<FileName>.txt")
    End Sub
End Class
"Potential has a shelf life." - Margaret Atwood

BlackBox

  • Water Moccasin
  • Posts: 2261
Re: Code Formatting
« Reply #5 on: September 09, 2011, 11:37:02 am »
... Do you have "word wrap" turned on?

"Potential has a shelf life." - Margaret Atwood