Re: [racket-users] racket/gui -- How to implement a text% area with line number displayed?

2017-03-08 Thread Daniel Feltey
The easiest way to do this is to use the text:line-numbers-mixin in the
framework. Here's an example of an editor with line numbers:

#lang racket

(require racket/gui framework)

(define text (new (text:line-numbers-mixin text:standard-style-list%)))
(define frame
  (new frame%
   [label "editor with line numbers"]
   [height 500]
   [width 500]))
(define editor (new editor-canvas% [parent frame] [editor text]))
(send text show-line-numbers! #t)
(send frame show #t)




On Wed, Mar 8, 2017 at 8:09 PM, WarGrey Gyoudmon Ju 
wrote:

> Sorry for so many small mails on one topic.
>
> In my current project, I implements something similar to line numbers.
> At the beginning, I separate them into different canvases so that the GUI
> behaves like iTunes(later I found that they do not implement it in a
> consistent way), but now I like the way that racket already provides, to
> override the (on-paint) method of text%, its first argument gives the
> change to draw something before or after the text% itself is displayed.
>
> On Thu, Mar 9, 2017 at 9:51 AM, WarGrey Gyoudmon Ju  > wrote:
>
>> Okay, in the gui framework, there is an interface text:line-numbers<%>
>>
>> On Thu, Mar 9, 2017 at 9:46 AM, WarGrey Gyoudmon Ju <
>> juzhenli...@gmail.com> wrote:
>>
>>> But sometimes I happened to see that some one-line codes and their line
>>> number are overlapped.
>>> And line numbers are also controlled by the same horizontal scrollbar(I
>>> mean, it is contained in the scrollbar's view, if there is another canvas
>>> this should not happen).
>>>
>>> Maybe they are displayed in a special image box(also, those non-string
>>> snips may produce lines that bigger than text line height).
>>>
>>> On Thu, Mar 9, 2017 at 9:31 AM, WarGrey Gyoudmon Ju <
>>> juzhenli...@gmail.com> wrote:
>>>
 I think, line numbers are likely displayed in another canvas.
 The current implementation of text% does not support advanced font
 features, the line height therefore is always the same. Displaying the line
 numbers just consists of a bit of arithmetic.

 On Thu, Mar 9, 2017 at 8:31 AM, 武晓宇  wrote:

>   I want to implement a text% object. And display the line number when
> string is inserted the text/canvas area.
>   Like the DrRacket IDE in "show line number" mode.
>   I read the source code of DrRacket but do not find the answer. Could
> anyone give a hand?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>


>>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] racket/gui -- How to implement a text% area with line number displayed?

2017-03-08 Thread WarGrey Gyoudmon Ju
Sorry for so many small mails on one topic.

In my current project, I implements something similar to line numbers.
At the beginning, I separate them into different canvases so that the GUI
behaves like iTunes(later I found that they do not implement it in a
consistent way), but now I like the way that racket already provides, to
override the (on-paint) method of text%, its first argument gives the
change to draw something before or after the text% itself is displayed.

On Thu, Mar 9, 2017 at 9:51 AM, WarGrey Gyoudmon Ju 
wrote:

> Okay, in the gui framework, there is an interface text:line-numbers<%>
>
> On Thu, Mar 9, 2017 at 9:46 AM, WarGrey Gyoudmon Ju  > wrote:
>
>> But sometimes I happened to see that some one-line codes and their line
>> number are overlapped.
>> And line numbers are also controlled by the same horizontal scrollbar(I
>> mean, it is contained in the scrollbar's view, if there is another canvas
>> this should not happen).
>>
>> Maybe they are displayed in a special image box(also, those non-string
>> snips may produce lines that bigger than text line height).
>>
>> On Thu, Mar 9, 2017 at 9:31 AM, WarGrey Gyoudmon Ju <
>> juzhenli...@gmail.com> wrote:
>>
>>> I think, line numbers are likely displayed in another canvas.
>>> The current implementation of text% does not support advanced font
>>> features, the line height therefore is always the same. Displaying the line
>>> numbers just consists of a bit of arithmetic.
>>>
>>> On Thu, Mar 9, 2017 at 8:31 AM, 武晓宇  wrote:
>>>
   I want to implement a text% object. And display the line number when
 string is inserted the text/canvas area.
   Like the DrRacket IDE in "show line number" mode.
   I read the source code of DrRacket but do not find the answer. Could
 anyone give a hand?

 --
 You received this message because you are subscribed to the Google
 Groups "Racket Users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to racket-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] racket/gui -- How to implement a text% area with line number displayed?

2017-03-08 Thread WarGrey Gyoudmon Ju
Okay, in the gui framework, there is an interface text:line-numbers<%>

On Thu, Mar 9, 2017 at 9:46 AM, WarGrey Gyoudmon Ju 
wrote:

> But sometimes I happened to see that some one-line codes and their line
> number are overlapped.
> And line numbers are also controlled by the same horizontal scrollbar(I
> mean, it is contained in the scrollbar's view, if there is another canvas
> this should not happen).
>
> Maybe they are displayed in a special image box(also, those non-string
> snips may produce lines that bigger than text line height).
>
> On Thu, Mar 9, 2017 at 9:31 AM, WarGrey Gyoudmon Ju  > wrote:
>
>> I think, line numbers are likely displayed in another canvas.
>> The current implementation of text% does not support advanced font
>> features, the line height therefore is always the same. Displaying the line
>> numbers just consists of a bit of arithmetic.
>>
>> On Thu, Mar 9, 2017 at 8:31 AM, 武晓宇  wrote:
>>
>>>   I want to implement a text% object. And display the line number when
>>> string is inserted the text/canvas area.
>>>   Like the DrRacket IDE in "show line number" mode.
>>>   I read the source code of DrRacket but do not find the answer. Could
>>> anyone give a hand?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Racket Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to racket-users+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] racket/gui -- How to implement a text% area with line number displayed?

2017-03-08 Thread WarGrey Gyoudmon Ju
But sometimes I happened to see that some one-line codes and their line
number are overlapped.
And line numbers are also controlled by the same horizontal scrollbar(I
mean, it is contained in the scrollbar's view, if there is another canvas
this should not happen).

Maybe they are displayed in a special image box(also, those non-string
snips may produce lines that bigger than text line height).

On Thu, Mar 9, 2017 at 9:31 AM, WarGrey Gyoudmon Ju 
wrote:

> I think, line numbers are likely displayed in another canvas.
> The current implementation of text% does not support advanced font
> features, the line height therefore is always the same. Displaying the line
> numbers just consists of a bit of arithmetic.
>
> On Thu, Mar 9, 2017 at 8:31 AM, 武晓宇  wrote:
>
>>   I want to implement a text% object. And display the line number when
>> string is inserted the text/canvas area.
>>   Like the DrRacket IDE in "show line number" mode.
>>   I read the source code of DrRacket but do not find the answer. Could
>> anyone give a hand?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] racket/gui -- How to implement a text% area with line number displayed?

2017-03-08 Thread WarGrey Gyoudmon Ju
I think, line numbers are likely displayed in another canvas.
The current implementation of text% does not support advanced font
features, the line height therefore is always the same. Displaying the line
numbers just consists of a bit of arithmetic.

On Thu, Mar 9, 2017 at 8:31 AM, 武晓宇  wrote:

>   I want to implement a text% object. And display the line number when
> string is inserted the text/canvas area.
>   Like the DrRacket IDE in "show line number" mode.
>   I read the source code of DrRacket but do not find the answer. Could
> anyone give a hand?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] racket/gui -- How to implement a text% area with line number displayed?

2017-03-08 Thread 武晓宇
  I want to implement a text% object. And display the line number when string 
is inserted the text/canvas area. 
  Like the DrRacket IDE in "show line number" mode.  
  I read the source code of DrRacket but do not find the answer. Could anyone 
give a hand?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.