-
-
Notifications
You must be signed in to change notification settings - Fork 598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
virtual Table view #question #248
Comments
At this point, no. I guess one could experiment with using a If you do have random access to your log, I could look into this. But it could take a while and I don't know yet if I might hit any major roadblocks. (I haven't looked at the code in detail from this perspective.) |
I'm thinking of parsing the logfile in the background and "index" it properly. So I would take care of the GetCell implementation details, and telling about the number of rows/columns. Don't get how the fixed columns/rows complicate the implementation. But to recap the big picture: could you separate the Table model and the table view? Then I'd like to implement my own model, and pass it to your view. |
I was thinking about parsing the logfile to an sqlite database in the background. Either way, I would just need a model interface to implement and a way to notify the viewer about the data changes. |
Apologies for the late reply. I was away for a few weeks. Is this issue still relevant to you? |
Relevant, but I can postpone this development (as this is a half-hobby project). I haven't dealt with the problem in the past weeks, but not having a model-view separation can be a dealbreaker for me. |
What is your current appetite to see this implemented? I'm needing this and might try to implement this myself but what are the criteria you are looking for? |
To be frank I lost interest in this feature. But the original need was to be able to lazily access a potentially huge number of items and have it rendered. So there should be a callback provided to retrieve the element specified in a parameter. It implies that the columns of the table should not depend on the actual length of the (huge) table. |
I went ahead and produced a VirtualTable that is to my liking but I'm not sure if @rivo would be interested in seeing my pull request because there are some breaking changes:
This would imply perhaps remake the original Table primitive on top of VirtualTable primitive and all should be well. |
I'm not really sure I understand your suggestion. Maybe you can elaborate how this would work. I looked at the code regarding implementing a virtual table and it doesn't look like there's a simple way. Tables are not read-only. There are all kinds of modifying functions like Then, every time the table is redrawn, it would let the implementer know what rows can be displayed so it can adjust its mapping. While drawing, it would query the implementer for all cells in the visible row range. (If Something like this: type TableContent interface {
GetCell(row, column int) *TableCell
GetRowCount()
GetColumnCount()
SetCell(row, column int, cell *TableCell)
RemoveRow(row int)
RemoveColumn(column int)
InsertRow(row int)
InsertColumn(column int)
Clear()
UpdateView(fromRow, toRow int)
} Looking forward to your thoughts. |
Yes that's it, separate the handling of table model (I'd use TableModel as a type) and the table view. |
Your proposal assumes that the My implementation of
Some of my needs such as sub-columns maybe not relevant to most people but from this |
I understand your use case and if we only looked at a subset of the current feature set of Sure, you can choose not to implement functions like Along with a function
Unless I misunderstood what you wrote, I don't think this is the case. In your case, you would implement Does this make sense to you? This is quite a bit of work so I want to make sure that we're on the same page. |
I think you misunderstood some of my suggestions. Yes, my Again, My ideal version of type TableContent interface {
GetCells(row int, column int) []*TableCell
GetRowCount() int
GetColumnCount() int
} Also I'm reiterating that I want to split the current |
Let me ask you this way: Assuming I have a |
I assume you want the interface for And then when the |
Why not just implement |
Because that means code duplication. Any drawing logic that |
But if you are simply asking whether |
As for what type should be embedded in what type, I thought the answer should be |
It would make sense to embed I don't know the code base very well, but I suspect you could reuse most of the |
I was never aware that putting in the effort is one of the issues in discussion here. But if @rivo decides that he likes this direction then rest assure I'll open a PR with my own |
Definitely yes. This is one of the core principles of this package that whenever possible, backwards compatibility is guaranteed. @pckhoi I've gone over your comments many times. Maybe I'm looking at the problem from a completely different angle but I have trouble understanding the details of your suggestion, especially how to handle write operations when the I have a slight hunch that you want the But since you already have an implementation, how about you post a link to it? No need to submit a PR, a link to your code will do. I'll have a look. Maybe that will help me understand where you're coming from. |
My table would not need to maintain a large matrix of |
If you're asking about whether a new |
Thanks for providing a link to your implementation. It helped me understand what you've been talking about all along. (Maybe it's just me but from your descriptions alone, it was not clear that this is what you meant — too many questions unanswered.) To be honest, though, I find this distinction between your I also don't think this distinction between So all in all, I think what I outlined before is what I'll be going for after all. You will still be able to handle changes to the data on the implementation side, i.e. your "separation of concerns". For example, if you want to display a log that is continuously being written to, you're free to let the table access only the trailing rows of your log. You don't need to call or even implement I understand that this is a very different direction from the one you've already taken and you may not be interested in this version. There are other people in this thread, though, that will hopefully benefit from this. (Also, I would say that things like sub-cells, the lack of the "evaluate all rows" flag, and a different selection functionality are out of scope for now anyway.) Everyone, feel free to weigh in. I'm never quite sure if I missed a certain perspective that would make this a bad solution. But as of now, it looks like this will be the implementation. |
I see that you have decided on an outcome. I don't think I can change your mind but the VirtualTable does follow a consistent pattern of the tview package that is composability. Higher-level components can be composed of lower-level components. For example 99% of all users are never expected to use the Box component, yet it is still exposed. And this is a powerful pattern, adding functionalities using layers of components (which is very successful in Facebook's React ecosystem). Extensibility via plugins is certainly possible but it is a dying trend, just look at React and a slew of technologies that emulate it such as Web Component, Vue.js. None of them rely on plugins for extensibility, all rely on composability. Since tview is a view library I thought it would be best if it also learns from other successful view libraries. But I understand if you don't agree.
|
And regarding modifying data away from the table. Again, this is a pattern borrowed from React: separation of state management and view logic. But anyway if you feel like it's just coming from a React fanboy then feel free to ignore me. |
Sure, React has its merits, and it's currently undoubtedly popular. Whether or not its model is the best of its kind is debatable. I've been programming with UI toolkits for 25 years, including React, and honestly, I wouldn't say React is the best I've ever used. In fact, when I started using it, I found it quite difficult to get it right due to its variety of concepts (e.g. mounting, updating, unmounting pre/post phases, states vs. props, and many others). I wanted What I didn't anticipate was that people would request a lot more complex functionality from As a side note, I don't see how my proposal mixes state management and view logic. Whatever your data structure is, a
Oh, I would love to hide |
This is why I disagree with the idea of introducing virtualisation to My original thought was that, if I think |
So this is implemented now. But for now, it's in a separate branch "virtualtable" (see PR #634). I also added an example with As discussed previously, Give it a go and let me know how it works for you. Once it's stable, I'll merge the PR into the master branch. |
I've merged this branch into |
Does the library support virtual table?
I'd like to build a simple log viewer with this lib, but the log is quite huge, so I don't think I'd like to load the whole logfile to memory.
The text was updated successfully, but these errors were encountered: