News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Tabs <--> Spaces (Source) Converter

Started by Mark Jones, March 31, 2005, 04:30:37 PM

Previous topic - Next topic

Mark Jones

 Hi All. Here is my first useful application, a simple reformatter for source code tabs/spaces. I don't know about anyone else, but I can't stand manually indenting and converting formats! :lol

Any ideas, suggestions, bug reports etc, are welcome.

Either drop a (small text) file onto TSC or click open and select a file. Input is shown on left, output on right. Text copy is supported but not paste. Experiment with the checkboxes for added effect.

Caveats:
* I haven't figured out how to intercept drag-scrolling yet, but the mousewheel and arrows (and pg up/dn) will scroll both the input and output windows simultanously.

* TSC is not resizable. Maybe I could "port" it over to WinAsm and handle dynamically creating the controls at runtime, but this sounds fairly complex for such a simple app. :)

* There are still a few minor glitches with the spaces to tab conversion, but the output should be very usable. The algorithm rapidly outgrew my ability to debug!  :red

2005.03.31:   TSC v1.0.4.57 Win32.zip

[attachment deleted by admin]
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

thomasantony

I HATE files with spaces instead of tabs :bdg . Will check out prog anyway/

Thomas :U
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free

pbrennick

#2
Hi Mark,
I had a quick play with your program and feel that it looks very promising.  One question, though, how come the right hand window only has one scrollbar.  The left window has both horizontal and vertical, the right hand window is missing the vertical scrollbar.

Paul

Mark Jones

Hi Thomas, yes this little app will "tab" your "spaced" text files, and vice-versa. :)

Hi Paul, glad you like it. I wanted both edit controls to scroll simultaneously in the vertical direction, so they remain in "sync" with each other. It was very annoying keeping things in sync with two vertical scrolbars.   As for the horizontal scrollbars, I left them both because A), if the right scrollbar is removed then it looks really weird, and B), I never found an API that could scroll horizontally. :(
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

pbrennick

 :dazzled:

Well, I got news for you, the left window is not synced with the right window on my machine.  XP HE.

Paul

pbrennick

They are not synced on windows ME, either.

Paul

Mark Jones

Hmm.... are you dragging the vertical scrollbar? I haven't found the method of intercepting drag-scrolling either. Yet. But the mousewheel, pgup/pgdown, and up/down keys seem to work in XP SP1 - both edit controls should show the same thing. Does the right one flicker a little?

Here's how the first edit control is setting the scroll position of the second control (did I do something wrong?):

Invoke SendDlgItemMessage, hWnd, IDC_TSC_EDIT1, EM_GETFIRSTVISIBLELINE, 0, 0
Mov yScrollPos, Eax
; set same scroll position of Edit2:
Invoke SetDlgItemText, hWnd, IDC_TSC_EDIT2, NULL ; clear edit2
Invoke SetDlgItemText, hWnd, IDC_TSC_EDIT2, hSaveLocalAlloc ; display current text
Invoke SendDlgItemMessage, hWnd, IDC_TSC_EDIT2, EM_LINESCROLL, 0, yScrollPos


Yeah it's not pretty but it was the only thing I could think of at the time. EM_LINESCROLL (by itself) doesn't want to scroll backwards, that is why the control is cleared and reset first...  ::)
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

pbrennick

Mark,
Yes, the mouse wheel and the pg up/dn work fine.  Just the vertical scrollbar is a problem.  I have seen others make comments about being driven crazy by scrollbars so I feel your pain.  I am glad the mousewheel works as it is my favorite.

Paul