It would be great to be able to retrieve all or one region from Textview (not just its text).
I'm not talking about GetTextRegion(regionID) that return the text contained in a specific region but:
GetRegions() []*cview.textViewRegion: Return all textViewRegion
GetRegion(regionID string) *cview.textViewRegion: Return a textViewRegion that match the provided regionID. And I want to potentially add other custom code when clicks happen.
The use case for me is that I want to override the mouseHandler for a textview that has a long text with many regions.
Left click right now seems to select only the first displayed region and not the clicked one.
Even if that might be a bug in the textview mouse handler, I think it would be great to be able to retrieve regions (at least all of them) and use FromX, FromY, ToX, ToY variables.
It would be great to be able to retrieve all or one region from Textview (not just its text).
I'm not talking about `GetTextRegion(regionID)` that return the text contained in a specific region but:
* `GetRegions() []*cview.textViewRegion`: Return all textViewRegion
* `GetRegion(regionID string) *cview.textViewRegion`: Return a textViewRegion that match the provided regionID. And I want to potentially add other custom code when clicks happen.
The use case for me is that I want to override the mouseHandler for a textview that has a long text with many regions.
Left click right now seems to select only the first displayed region and not the clicked one.
Even if that might be a bug in the textview mouse handler, I think it would be great to be able to retrieve regions (at least all of them) and use `FromX`, `FromY`, `ToX`, `ToY` variables.
The use case for me is that I want to override the mouseHandler for a textview that has a long text with many regions. Left click right now seems to select only the first displayed region and not the clicked one.
Will you please share a demo that reproduces this? Region clicking seems to work in my limited testing.
>The use case for me is that I want to override the mouseHandler for a textview that has a long text with many regions. Left click right now seems to select only the first displayed region and not the clicked one.
Will you please share a demo that reproduces this? Region clicking seems to work in my limited testing.
Will you please share a demo that reproduces this? Region clicking seems to work in my limited testing.
I think I found the reason.
See the example based on demo code:
package main
import (
"code.rocketnine.space/tslocum/cview"
)
const corporate = `["region-1"]Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.[""]
["region-2"]Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring.[""]
["region-3"]Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line.[""]
["region-4"][yellow]Press Enter, then Tab/Backtab for word selections[""]`
func main() {
app := cview.NewApplication()
app.EnableMouse(true)
textView := cview.NewTextView()
textView.SetDynamicColors(true)
textView.SetRegions(true)
textView.SetWordWrap(true)
textView.SetBorder(true)
textView.SetText(corporate)
app.SetRoot(textView, true)
if err := app.Run(); err != nil {
panic(err)
}
}
When running this and using left click anywhere in the terminal, only the first region is selected and highlighted for me.
By changing the text to:
const corporate = `["region-1"]Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.
["region-2"]Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring.
["region-3"]Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line.
["region-4"][yellow]Press Enter, then Tab/Backtab for word selections`
By removing the "closing" tags ([""]), it seems to work as expected so I'm guessing the issue is around those tags :)
> Will you please share a demo that reproduces this? Region clicking seems to work in my limited testing.
I think I found the reason.
See the example based on demo code:
```
package main
import (
"code.rocketnine.space/tslocum/cview"
)
const corporate = `["region-1"]Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.[""]
["region-2"]Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring.[""]
["region-3"]Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line.[""]
["region-4"][yellow]Press Enter, then Tab/Backtab for word selections[""]`
func main() {
app := cview.NewApplication()
app.EnableMouse(true)
textView := cview.NewTextView()
textView.SetDynamicColors(true)
textView.SetRegions(true)
textView.SetWordWrap(true)
textView.SetBorder(true)
textView.SetText(corporate)
app.SetRoot(textView, true)
if err := app.Run(); err != nil {
panic(err)
}
}
```
When running this and using left click anywhere in the terminal, only the first region is selected and highlighted for me.
By changing the text to:
```
const corporate = `["region-1"]Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.
["region-2"]Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring.
["region-3"]Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line.
["region-4"][yellow]Press Enter, then Tab/Backtab for word selections`
```
By removing the "closing" tags (`[""]`), it seems to work as expected so I'm guessing the issue is around those tags :)
Thanks again for reporting this. This was fixed upstream in tview, so I've merged their fix.
If you still neeed additional TextView methods, please open a new issue.
Thanks again for reporting this. This was fixed upstream in tview, so I've merged their fix.
If you still neeed additional TextView methods, please open a new issue.
It would be great to be able to retrieve all or one region from Textview (not just its text).
I'm not talking about
GetTextRegion(regionID)
that return the text contained in a specific region but:GetRegions() []*cview.textViewRegion
: Return all textViewRegionGetRegion(regionID string) *cview.textViewRegion
: Return a textViewRegion that match the provided regionID. And I want to potentially add other custom code when clicks happen.The use case for me is that I want to override the mouseHandler for a textview that has a long text with many regions.
Left click right now seems to select only the first displayed region and not the clicked one.
Even if that might be a bug in the textview mouse handler, I think it would be great to be able to retrieve regions (at least all of them) and use
FromX
,FromY
,ToX
,ToY
variables.Will you please share a demo that reproduces this? Region clicking seems to work in my limited testing.
I think I found the reason.
See the example based on demo code:
When running this and using left click anywhere in the terminal, only the first region is selected and highlighted for me.
By changing the text to:
By removing the "closing" tags (
[""]
), it seems to work as expected so I'm guessing the issue is around those tags :)Thanks again for reporting this. This was fixed upstream in tview, so I've merged their fix.
If you still neeed additional TextView methods, please open a new issue.