Author Topic: Closing / deleting buffers?  (Read 5556 times)

slickMark

  • Community Member
  • Posts: 11
  • Hero Points: 0
Closing / deleting buffers?
« on: November 29, 2006, 04:54:14 pm »
I have a form that has an tab control and editor control. When the user right-clicks and chooses to
close the file / buffer I call "editorCtrl.close_buffer()" and delete the active tab. This is fine for closing
the buffer but it ALSO loads the 'next' buffer in the form's editor control.

How can I simply close the buffer without doing anything else?
When the user chooses to close the buffer, I will make another tab active and load THAT buffer in the
form's editor control. If it's the LAST tab, then I don't want to display anything in the form's editor
control.

Is there a way to close the buffer without doing anything else?

Thanks in advance,

Graeme

  • Senior Community Member
  • Posts: 2300
  • Hero Points: 301
Re: Closing / deleting buffers?
« Reply #1 on: November 30, 2006, 09:37:26 am »

I'm unfamiliar with what you're doing but I'm curious.

You talk about the "form's editor control" which suggests you have a single editor control.  How did you create the buffer you're trying to delete in the first place.  I haven't used an editor control much but my impression is that when you create the editor control it creates a single buffer for you so I'm wondering how you created the multiple buffers you're referring to.

I guess you've trekked through the close_buffer code and seen where _delete_buffer gets called.  I'm wondering how much of slick code tolerates some of the buffers being in non "_mdi" windows. 

You ask
Quote
How can I simply close the buffer without doing anything else?

What will your editor control show when a buffer is deleted?  Won't you have to switch to a new buffer?  Can't you just override the buffer selected by _delete_buffer and show whichever buffer you want?

Graeme
 

slickMark

  • Community Member
  • Posts: 11
  • Hero Points: 0
Re: Closing / deleting buffers?
« Reply #2 on: November 30, 2006, 02:52:06 pm »
I create the 'other' buffers by calling load_files('+T' bufferName)
This creates a temporary buffer. Every time the form's button is pressed, I:
a) create a new buffer as described above.
b) add a tab to the form's tab control
c) assign the text I want to the new buffer (the text comes from the build window, result of an external
    command).
d) record the necessary info in an array.
Now when a different tab is selected, I display the buffer (created above) which is associated with that
tab in the form's editor control by calling load_files('+B ' bufferName)

Similarily, when the user closes a tab, (and another tab becomes the active tab) I would like to display
the buffer associated with that tab in the form's editor control.

Graeme

  • Senior Community Member
  • Posts: 2300
  • Hero Points: 301
Re: Closing / deleting buffers?
« Reply #3 on: December 01, 2006, 07:58:29 am »
Similarily, when the user closes a tab, (and another tab becomes the active tab) I would like to display
the buffer associated with that tab in the form's editor control.

If I do this
Code: [Select]
   close_buffer();
   edit('+B c:\somefile.txt');

the buffer selected by the close_buffer operation never appears and the buffer somefile.txt is shown  - so can't you just do a load_files command immediately after the close_buffer?

Graeme

slickMark

  • Community Member
  • Posts: 11
  • Hero Points: 0
Re: Closing / deleting buffers?
« Reply #4 on: December 01, 2006, 01:46:27 pm »
Yes. I tried this and it does give the result that I want. When the last tab; however, is closed I do not have another buffer to show in the form's editor control. Since I cannot call load_files() in this case, what happens is that one of the buffers in Slick Edit's main form editor is displayed in my form's editor
control.

For now my hack is to not allow the last tab to be closed.

Thank you for all of your valuable input.

shadowbane

  • Community Member
  • Posts: 85
  • Hero Points: 4
Re: Closing / deleting buffers?
« Reply #5 on: December 29, 2006, 06:30:31 pm »
How about when you run out of buffers to display, you just create a new empty buffer to display and switch the editor control to readonly.  Then it would have something to display besides the source buffer.

Tyler