# Code folding for sourceview

**URL:** <https://www.ruby-forum.com/t/code-folding-for-sourceview/198845>\
**Category:** Ruby-Gnome 2\
**Created:** [November 9, 2010, 4:43am UTC](https://www.ruby-forum.com/t/code-folding-for-sourceview/198845 "2010-11-09T04:43:42Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![okkezSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Post date:** [November 9, 2010, 4:43am UTC](https://www.ruby-forum.com/t/code-folding-for-sourceview/198845/1 "2010-11-09T04:43:42Z")

</div>

Dear all

I am writing a code editor  
using ruby gtk with sourceview as the editor

is there a way to implement code folding here?

If you have already done that, it would be great if you could share  
if not, some idea on how to implement this is greatly appreciated

Thank you  
Regards  
Hendra

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [November 9, 2010, 7:02am UTC](https://www.ruby-forum.com/t/code-folding-for-sourceview/198845/2 "2010-11-09T07:02:59Z")

</div>

Hi,

I found Gtk::TextTag.invisible, but docs says: Gets the value whether  
this text is hidden. Not implemented in GTK 2.0.

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [November 9, 2010, 1:59pm UTC](https://www.ruby-forum.com/t/code-folding-for-sourceview/198845/3 "2010-11-09T13:59:39Z")

</div>

What about this?  
[http://live.gnome.org/GtkSourceView](http://live.gnome.org/GtkSourceView)

Can it help?  
Or any other ideas? Or currently its just not possible?

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [November 21, 2010, 6:50am UTC](https://www.ruby-forum.com/t/code-folding-for-sourceview/198845/4 "2010-11-21T06:50:26Z")

</div>

Hi Hendra:

I’m writing an IDE for Ruby/Gtk myself. I’m interested in your  
progress. I didn’t know that we could get sourceview to work with ruby,  
but I’ve heard that they will be releasing a gem in the next release.  
I’d like to see how you’re doing it. Perhaps we could show each other  
our projects so we can help each other. Perhaps we could beta test for  
each other too.

Let me know.  
Eric

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [November 22, 2010, 9:52pm UTC](https://www.ruby-forum.com/t/code-folding-for-sourceview/198845/5 "2010-11-22T21:52:30Z")

</div>

Thanks Hendra.

I’m reading some of it now. It looks good. I’m going to try to run it  
when I get home.

Eric

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [November 26, 2010, 3:21am UTC](https://www.ruby-forum.com/t/code-folding-for-sourceview/198845/6 "2010-11-26T03:21:17Z")

</div>

On Tue, Nov 23, 2010 at 4:52 AM, Eric C.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> Thanks Hendra.
> 
> I’m reading some of it now. It looks good. I’m going to try to run it  
> when I get home.

Dear Eric,  
if you have something to ask about my code, or some news about your  
project  
please inform me  
Thank you  
Regards  
Hendra

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [November 27, 2010, 9:47am UTC](https://www.ruby-forum.com/t/code-folding-for-sourceview/198845/7 "2010-11-27T09:47:30Z")

</div>

Hi Hendra:

I just got home from vacation, and successfully installed gtksourceview.  
I installed your program, and it ran perfectly on the first try. Its a  
really nice looking program. You did an excellent job. I really like  
your code. I’m able to understand what each file does without much  
trouble.

I’m going to read more of it tomorrow. My first question is, why did  
you write the GUI code by hand instead of using glade?

My project is similar to yours. Mine has a code editor, and it adds  
version control over the network, and a simple object save/retrieve  
methods so you can serialize any object and store it to disk. Also, I’m  
including a simple method to run a glade file. So, for example, if you  
make a class MyClass.rb then there could be a file MyClass.glade. You  
could then call the MyClass#build\_glade() method to load the glade file.  
I’d love your help if you’re interested. I’m in my 2nd month of Ruby,  
so I’m still re-writing a lot. Andrea D. has been helping me break  
in to ruby (Thanks Andrea if you see this!).

I’ll get back to you after I read more of your code.

Also, what are your plans for this program?

Eric

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [November 22, 2010, 12:08pm UTC](https://www.ruby-forum.com/t/code-folding-for-sourceview/198845/8 "2010-11-22T12:08:09Z")

</div>

On Sun, Nov 21, 2010 at 1:50 PM, Eric C.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> Eric
> 
> –

Hi Eric

It’s good to hear your interest  
Too bad I am a bit busy right now so I must put my project on hold  
But of course you can see my code  
It is bad written thought  
my first intention is to get it work, optimize later  
so code organization is a bit messy,  
but shouldn’t be very difficult to understand  
since I only use basic syntax (and there Ruby helps with clean syntax)

I attached my code here  
to put it on the web right now  
I also hope to see yours too,  
perhaps you can post it somewhere we can see  
Thanks

ps.  
In the code you will see folder script, look into it.  
It’s part of my big plan, the FastGTK framework (temporary name)  
If you ever touch Rails, you should get some of the idea  
(I use some of Rails idea)

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [November 27, 2010, 3:09pm UTC](https://www.ruby-forum.com/t/code-folding-for-sourceview/198845/9 "2010-11-27T15:09:13Z")

</div>

On Sat, Nov 27, 2010 at 4:47 PM, Eric C.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> I’ll get back to you after I read more of your code.
> 
> Also, what are your plans for this program?

Glad you like it  
actually, I didn’t write the code by hand.  
OK, I did it by hand, but not the files on controller/base directory, I  
generate them.  
Remember when I told you to take a look at script directory?  
There’s a code generator there.  
so basically, I write those ruby code in view folder,  
then generate files in controller/base based on files in view folder  
using script/migrate-view.rb,  
that’s what I mean when I mention my framework

The reason why I don’t use glade is… because previously I have  
already  
created similar  
code generator for wxwidget (wxruby)  
but since I got stuck with wxruby I decide to migrate the code to GTK.  
It was far easier for me back then to migrate the code rather than to  
learn  
glade  
(I migrate the code from wxwidget to gtk in less than a week)

your code to load glade seems very interesting, if you don’t mind  
perhaps  
you can share it? I have no experience with glade before, I think I’ll  
give  
it a try

For now this project is on hold because I am very busy at the moment. I  
haven’t plan anything other than finishing main features. Actually I  
want it  
to be good enough to replace Geany (editor I used to code ruby). That’s  
the  
main reason why I write this app.

I don’t really understand about version control so I guess yours is  
better  
than mine.  
But I hope you include those object browser, directory tree and split  
view  
in your project, because if you do, I will use your app, as long as it  
is  
lightweight ;D

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [November 27, 2010, 9:09pm UTC](https://www.ruby-forum.com/t/code-folding-for-sourceview/198845/10 "2010-11-27T21:09:19Z")

</div>

HI Hendra:

I’ll be glad to share my project with you. However, its under heavy  
development right now. I can email it to you, if you send me your  
address.

I’m planning on doing a big re-write now.

You mentioned that you’re short on time, so I’m not sure if you want to  
take the time to understand all of it, but I’d be happy to explain  
what’s going on if you like.

I’m going to try to find the time to understand all of your program too.  
I think it may take me a few sessions of reading it. I didn’t realize  
that the code that I was reading was generated, so its obviously more  
complex than I realized.

Yours,  
Eric

---

<div class="post-metadata">

**Author:** ![hendra\_kusuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/5f8ce5/32.png) [@hendra\_kusuma](https://www.ruby-forum.com/u/hendra_kusuma)\
**Post date:** [November 28, 2010, 4:38am UTC](https://www.ruby-forum.com/t/code-folding-for-sourceview/198845/11 "2010-11-28T04:38:39Z")

</div>

On Sun, Nov 28, 2010 at 4:09 AM, Eric C.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> what’s going on if you like.
> 
> I’m going to try to find the time to understand all of your program too.  
> I think it may take me a few sessions of reading it. I didn’t realize  
> that the code that I was reading was generated, so its obviously more  
> complex than I realized.
> 
> Yours,  
> Eric

I’ll give you some hints for understanding my code

you run app.rb  
it call a file in controller directory.  
file in controller folder is an inheritance of files in controller/base.  
files in controller/base is generated from files in view folder.  
code generation is done before hand, not at the runtime.  
the code generation file is script/module-view.rb.  
all files in module folder is loaded automatically, there is function to  
make life easier such as alert, show\_message, etc (in gtk\_additional.rb)

Please send your code to my email : [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
I’ll try to spare my time to see your code

Thanks Eric
