Harjinder Virdi
Frustration Build Up : BUG#542524

I usually wait to blog when I have accomplished a task or I believe I have something good to say. It’s neither. When I had started to work on my bespin word wrap bug I was not sure where to start. Normally when I start my work on any programming assignment I usually go straight to coding and try to experiment with the code and start narrowing it down until I get something right going. Of course this is not the best step if your working with a large code base. Then again at the same time you need to have some clue as to where you “might” think the code resides using keywords or just simple guessing loll?

I went into the file text.js because I had done some work in there previously. I began playing around and I was able to find the code where it inserts the character onto the line but it was not enough to do what I wanted. 

I needed help so the first thing I did was, I got on the IRC #Bespin channel and informed about my bug and that I needed help. Instantly Julian Viereck replied and told me to post my thoughts and suggestions on Bespin-core mailing list. I did and I got a few replies. First suggestion was by Dany Zatuchna for me to use the “Knuth’s Algorithm”. I took a look but it was not exactly what I needed at the moment. I wanted to break the solution into a few steps: 

1.) Get the length of each line
2.) Find out the max width of the editor
3.) Set a speciific margin so if the user reaches the end of a line then insert the      characters on to the next line.
4.) From there I can do the word wrap which would be iterating through each line and swapping words where necessary. 

Kevin Dangoor had told me that the editor lives in the ScrollView and that’s how it knows its dimensions. And that it uses character’s width and height to determine the total area of the editor. Interestingly It was not what I thought it would be. He also Implied that I should talk to Patrick and Julian. Since both had done most of the hacking in bespin-core. After going back to the IRC channel and speaking to Patrick Walton, I found out that most of my hacking would be done in LayoutManager and a little modification in the TextView. LayoutManager because it mostly entails what word wrap require. It is able to determine the pixel position of each character or a range within the editor.

However after spending some time with both files I was still unsure as to where I would start coding. Also I did not understand some of the functions in the file LayoutManager. So I sent Julian an email about my questions and he felt that this bug was not simple and it would be hard to do if I hadn’t had much experience working with Bespin coding. He offered to guide me through it but felt that I should work on the bugs suggested by him first so that I could get more fimiliar with the Bespin code base.

At the end of the day there are no stupid questions and from every question you learn something even if you don’t accomplish anything. I made a mistake and that was not being open about my problem. The idea of me looking “stupid” by not being able to do this or asking “stupid” questions kept stressing me. I was wrong and it’s not like It was not obvious to me. You only get better at something by keep working on it….Learning can come from experimenting and asking questions. Not everyone has the answer to everything… At the same time you might know something someone else might not and thats how we collaborate.

Now having said that I got a better understanding of how the Bespin code structure is layed out, similar to the way Cocoa does. In the mean time I’ll work on other bugs recommended by Julian Viereck. Then I will come back and experiment this word wrap bug.