comp.lang.ada
 help / color / mirror / Atom feed
* Problem with Saving and printing a Gtk Textbuffer
@ 2018-11-20  8:30 ldries46
  2018-11-20 13:12 ` ldries46
  0 siblings, 1 reply; 2+ messages in thread
From: ldries46 @ 2018-11-20  8:30 UTC (permalink / raw)


I have a Gtk Textbuffer with some text in it. I want to save or print the 
contents of the buffer therefore I use in both cases about the same 
construction with transporting to  a string in a put Line for saving and , 
as shown in the example code, to a drawbuffer used for printing.

Get_Start_Iter(Draw_Buffer, start_it);
Get_End_Iter(Draw_Buffer, end_it);
Draw_Buffer.Delete(start_it, end_it);
len := Main_Window.Output_Buffer.Get_Line_Count;
nr := 1;
while nr < len loop
   Get_Iter_At_Line(Main_Window.Output_Buffer, start, nr);
   Get_Iter_At_Line_Offset(Main_Window.Output_Buffer, stop, nr, 500);
   str := To_Unbounded_String(Main_Window.Output_Buffer.Get_Text(start, 
stop));
   Num_Line := Get_Back(str);
   Draw_Buffer.Insert_At_Cursor(To_String(Num_Line.str & CRLF));
   nr := nr + 1;
end loop;

With saving after the loop is an Close statement voor the file,with printing 
the the printing is initiated there.

The problem is that somewhere within the loop the program crashes and I 
cannot find where.
I used exceptitons to run the program to the end and found with saving that 
the file exists but is not closed. Closing the program also closes the file 
and I can see that the contents of the file is correct. Before stopping the 
program the operating system tells me that another program is using the file 
when trying to open it with wordpad. The pproblem with printing is simular.

Who can help me?

Bertus Dries


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Problem with Saving and printing a Gtk Textbuffer
  2018-11-20  8:30 Problem with Saving and printing a Gtk Textbuffer ldries46
@ 2018-11-20 13:12 ` ldries46
  0 siblings, 0 replies; 2+ messages in thread
From: ldries46 @ 2018-11-20 13:12 UTC (permalink / raw)


In the mean time I made this loop working by changing the value of len. len 
was 50 lines but the loop ony works with 48 lines so I changed nr < len in 
nr < len - 1. I don't understand why this is so if anyone can tell me why or 
can give me a better solution i would be happy.

"ldries46"  schreef in bericht news:5bf3c62a$0$14970$e4fe514c@news.kpn.nl...

I have a Gtk Textbuffer with some text in it. I want to save or print the
contents of the buffer therefore I use in both cases about the same
construction with transporting to  a string in a put Line for saving and ,
as shown in the example code, to a drawbuffer used for printing.

Get_Start_Iter(Draw_Buffer, start_it);
Get_End_Iter(Draw_Buffer, end_it);
Draw_Buffer.Delete(start_it, end_it);
len := Main_Window.Output_Buffer.Get_Line_Count;
nr := 1;
while nr < len loop
   Get_Iter_At_Line(Main_Window.Output_Buffer, start, nr);
   Get_Iter_At_Line_Offset(Main_Window.Output_Buffer, stop, nr, 500);
   str := To_Unbounded_String(Main_Window.Output_Buffer.Get_Text(start,
stop));
   Num_Line := Get_Back(str);
   Draw_Buffer.Insert_At_Cursor(To_String(Num_Line.str & CRLF));
   nr := nr + 1;
end loop;

With saving after the loop is an Close statement voor the file,with printing
the the printing is initiated there.

The problem is that somewhere within the loop the program crashes and I
cannot find where.
I used exceptitons to run the program to the end and found with saving that
the file exists but is not closed. Closing the program also closes the file
and I can see that the contents of the file is correct. Before stopping the
program the operating system tells me that another program is using the file
when trying to open it with wordpad. The pproblem with printing is simular.

Who can help me?

Bertus Dries 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-20 13:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-20  8:30 Problem with Saving and printing a Gtk Textbuffer ldries46
2018-11-20 13:12 ` ldries46

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox