
paolo jeroen: just finished to comment the API
jeroen paolo: i see it, thanks
jeroen paolo: what do you mean by opaque object? I agree that the internals shouldn't be exposed to the developer
paolo jeroen: as I have written in the comment, I think the API needs some work, but the required changes will not require much code changes
* zwnj (~behnam@81.31.160.199) has joined #gedit
jeroen cool
paolo jeroen:  I mean that its fields should not be public
jeroen paolo: how do you make that work so you can access the internals from both the buffer and view?
paolo you can add accessor functions 
paolo or declare it in a private header file
jeroen i'll do the latter i think
jeroen accessor functions is overkill imo
paolo yep, but you need some of them anyway (for the public API)
jeroen what does gtk_source_fold_get_bounds do?
* zwnj (~behnam@81.31.160.199) has left #gedit
paolo it returns the bounds of a given fold (it is one of the public accessor functions I was referring to)
jeroen ah, ok
jeroen paolo: gtk_source_buffer_get_folds_in_region is a *very* important function
jeroen it's used to determine the folds to draw/line numbers to draw for a given region (see gtk_source_view_get_lines)
paolo I see, but I don't think it should be public
paolo I think we should have a public function that returns all the root folds
jeroen we already have that
jeroen iirc
paolo as we discussed at GUADEC
jeroen gtk_source_buffer_get_all_folds
jeroen s/all/root/ perhaps
paolo and then a private function that returns a flat list (to be used by the view)
jeroen right
jeroen i'll look into making that private
paolo i.e. I think we should have a function like:
paolo GSList *gtk_source_buffer_get_root_folds_in_region (buffer, start, end)
paolo where start and end can be NULL 
jeroen why?
jeroen the root fold list is already ordered/sorted by appearance
paolo hmmm... ok
paolo GSList *gtk_source_buffer_get_root_folds (buffer)
jeroen right
jeroen const GSList 
paolo yep
paolo then using the accessor function of GtkSourceFold users can get the bouds, the children and the status of the folds
pbor why a SList?
pbor is it really never needed to move to the prev fold?
paolo I don't think
paolo jeroen: ?
jeroen not afaics
pbor ok
jeroen i'm fine with a GList though
jeroen i can change that easily
paolo I think GSList is ok
jeroen k
jeroen gtk_source_buffer_get_fold_at_iter could probably be dropped
jeroen gtk_source_buffer_get_fold_at_line is used extensively in gtksourceview.c
paolo jeroen: BTW, before fixing the entire patch. Can you please try to attach the fixed API so that we can agree on it
jeroen basically used for things like: when the mouse is over the gutter, is there a fold at that line
jeroen paolo: i'll just update the entire patch (not that much work)
paolo it returns the leaf fold then
jeroen not now though (on windows atm)
jeroen paolo: yeah, it returns the leaf fold if there is any
paolo if it possible I'd prefer to use GtkTextIter in the public API (since all the other functions use iters)
jeroen that's what i had initially
jeroen there's a very good reason why i changed it to a line number:
jeroen the start of a fold can be anywhere on a line
jeroen at the start, in the middle or at the end
jeroen you want to get the fold on the line, *regardless* of where on the line it exactly begins
jeroen i need to add checks later so you can only have 1 fold per line
pbor generic question (sorry if this is silly): what about interleaved folds? will they work?
paolo well, if you have the _iter function you can easily implement the _line one
jeroen pbor: define interleaved please
pbor I mean:
jeroen paolo: that's what i have now :)
pbor foo {
pbor #if bar
pbor ...
pbor }
pbor #endif
jeroen paolo: implementation is different. the text iter comparison is different from a line comparison
paolo jeroen: so I think we can have a public _iter function and a private _line one
jeroen pbor: you mean a fold has a child fold etc?
jeroen paolo: _iter function is useless afaics atm
jeroen pbor: sorry
jeroen pbor: i understand now
paolo but it is more generic hence better for the public API
jeroen pbor: that doesn't/won't work and already you'll get a g_warning if you try to do that
jeroen pbor: folds can't intersect
paolo pbor: do you think this is a big limitation?
jeroen paolo: so call it _line and make the parameter a GtkTextIter
jeroen paolo: regardless of that, it's impossible to implement it
pbor paolo: no idea... I was just thinking of edge cases :)
pbor paolo, jeroen: do other editor support that?
paolo jeroen: hmmm... I'm confused
jeroen no
pbor 'k
paolo jeroen: it is not clear to me: "so call it _line and make the parameter a GtkTextIter"
jeroen paolo: gtk_source_buffer_get_fold_at_line (GtkSourceBuffer *buffer, GtkTextIter *line);
jeroen a bit silly really
jeroen since the first thing the impl does is call gtk_text_iter_get_line (line);
paolo but suppose the cursor is a line 1, 1 and the fold start at line 1, col 10
jeroen right, so it matches the fold and returns it
paolo in that case you are not inside the fold
jeroen yeah
jeroen ok
jeroen i can see a use case for that
jeroen user is editing code and has a shortcut to collapse the fold
jeroen you want a _iter function for that
paolo you can use it for example to implement an accellerator that folds/unfolds the current fold
jeroen i'll leave that and make the _line private
paolo ok
pbor other question, related to your _line discussion: would be something like if (bar) { .... } (on a single line) unfoldable?
jeroen pbor: yep
paolo while we are at it, I think we should add a keybinding for collapse the current fold
jeroen you only ever want folds when the fold spans multiple lines
jeroen paolo: good idea
paolo or the father if the current fold is already collapsed
pbor jeroen: well, sometimes I wish I could fold big expressions on a single line...
jeroen pbor: that's not really something that this patch (is meant to) adresses
pbor jeroen: ok
pbor but would the api be suitable for that kind of enanchement?
paolo pbor: I think the api is suitable
pbor good
* paolo tests the patch
pbor another question...
* pbor is playing devil's advocate
pbor can two folds start at the same iter?
pbor or end at the same iter?
pbor (not that I can think of an example...)
jeroen no
paolo yep, but they should be father and child
jeroen that means they intersect
jeroen intersecting folds is a no no
paolo jeroen: cannot they be nested?
pbor what about the end iter?
jeroen paolo: nesting is fine
jeroen as longs as parent start iter != child start iter and the same for the end iters
jeroen so:
jeroen {
jeroen   {
jeroen   }
jeroen }
jeroen is find
jeroen fine even
pbor for end iter I mean: does that mean that that you can't fold until you close the }?
jeroen paolo: test-widget has nesting
jeroen pbor: yes
jeroen but that's normal behavior (find me one editor which doesn't work that way)
pbor jeroen: fair enough :)
pbor jeroen: as I said I'm just trying to come up with problematic cases :)
jeroen heh, np :)
pbor telling me "screw you, that is crack" is ok ;)
jeroen i've banged my head (figure of speech), several times during implementation of code folding myself :)
jeroen getting your head around how it's implemented takes a bit of thought :)
jeroen pbor: heh
jeroen i don't work way
jeroen i'll just ignore you ;)
pbor :)
jeroen paolo: how's the testing going?
* jessevdk (~jesse@flits103-171.flits.rug.nl) has joined #gedit
paolo jeroen: problem with compilation... but it is on my side
jeroen k
paolo jeroen: I'd like to have a visual feedback of where a given fold ends
paolo and also of which is the current fold
paolo and also of the fact a given fold is collapsed
jeroen paolo: i want to try and experiment with adding a GtkLabel using gtk_text_view_add_child_in_window
jeroen paolo: i'm going for a look where you have a [..] (box with 2 dots in it) at the position where the fold start
jeroen but that shouldn't be a part of the buffer (not selectable, and the cursor shouldn't be able to get to it)
paolo hmmm... or at the end of the first line of a collapsed fold
jeroen paolo: the arrow collapsing already is an indication if a fold is collapsed
jeroen paolo: yeah, that where i want it
jeroen that's
paolo just found a little problem:
paolo - collapse a fold
paolo - set show_fold_regions to folds
jeroen not tested :)
paolo - all the collapsed folds should be unfolded
jeroen i didn't test that path
paolo s/to folds/to FALSE
paolo ok
jeroen basically so far i've just run test-widget and (un)collapsed folds
paolo I'm going to attach the IRC log to the bug report... ok for you?
jeroen paolo: http://www.xs4all.nl/~jeroen/screenshots/foldindicator.PNG
paolo yep, cool
jeroen that's from eclipse (not gtksourceview :)
jeroen but it's the look i'm aiming for
jeroen paolo: sure, but as an attachment please (not the entire text as comment)
paolo yep
paolo what about marking the ned of the current fold like in http://kate.kde.org/images/kwrite_01.png
paolo s/ned/end
jeroen paolo: on my todo list (see the bug :)
paolo ok
