I have a lot of selections hanging around. How do I reduce them to a single one? - kakoune

After any Kakoune operation which results in multiple selections (like a global search with %s, for example), I get multiple selections and when move up and down or left or right they all move.
How do I get back to having just my primary single selection?

I had to ask on #kakoune # freenode IRC, the answer is simply space.

Related

Open multiple positions in Backtrader

Does someone know if it's possible to open multiple positions with only a single data feed? I am trying to do a second buy whilst in a position, which doesn't seem to be possible.
Nobody seems to adress this issue. Does anyone have any experience with Backtrader and have any input?
If you are just trying to buy more stock to add to your position, then yes, you should be able to do this and if you cannot recheck your strategy code in next.
If you are trying to track two separate positions of the same data...
One cannot have two separate positions in the same data feed. You may trade additional positions if you like but they will be combined in Backtrader. Even if you use two strategies you will still have one combined broker.
The reason for this is to simulate as near as possible real world conditions. If you have a brokerage account you most likely would have just one postion. (I know there are exceptions)
One solution would be to track your trading manually in a dictionary trades that result from different signals/sub-strategies. It's a bit more tedious to develop but very doable.

python3 tkinter: can I get ragged grids without aligned columns?

I'm writing a GUI in python, and using tkinter. I'm having trouble settling on an approach and need guidance.
Background: there's a server (not a webserver) that wants to present a lot of information to users, and let them edit some of it. It needs to send down information that a (relatvely) dumb python client uses to fill the window. Read only fields are Labels. The fields are generally single line Entry widgets, but some are multiline Text. There are some buttons, checkboxes and dropdowns. Asynchronously, the server can also update widgets, add them and remove them. In some cases, there are tables presented, to which the user needs to be able to add and remove rows.
The real problem is, the layout is dense and chaotic. The first row might contain 3 dropdown fields. The next might be 20 short Labels. The next might be a single long Entry field, and then I might want two tables (of different lengths) side by side,and then etc.. Based on user input of external factors, widgets, rows or entire tables might have to be dyamically added, or vanish.
I considered Grid, but it's unusable. A row with a single, long entry widgit in it, makes the first column wide and thereby pushes 12 of the 13 columns in the next row right off the window.
I considered Place, but this app will run on 3 different operating systems and users will be able to select their own fonts, so I'll never get the positions right. If there was some way to ask a widget how big it was, I'd happily use that to compute my own layouts in pixels, but it's apparently impossible to ask the size of a widget until AFTER it's been laid out by a geometry manager, which of course is too late.
So what I think I'm left with is Pack, where each row is its own frame, and some of those rows have tables (grids) in them. But I'm concerned that that means lots and lots of frames to render, and some of the users are on old, slow hardware. Plus... it looks just plain complex.
Am I missing a better way? Grid would be fine if I could convince it to stop trying to make columns line up. Place would be crunchy, but ok, if I could get the size of each widget in advance. Is placing within a lot of frames really the best I have?
Short answer, there's no better way; and the frame count isn't high enough to cause performance problems; so generating a frame per row is what works.

Printing Grid Component

I have a MultiGrid component with a single fixed row. I would like to print the result, but since multiple columns overflow on the x-axis, the print output gets truncated.
Is it possible to wrap each row in another element and then use display table-cell/table-row to get the desired, table-like behavior? The added benefit is that a table can easily stretch the entire page, even if the number of columns is low.
Is it possible to wrap each row in another element
Yes. It would be possible to wrap rows by injecting your own cellRangeRenderer property. That being said, I don't really recommend it. RV doesn't really have "rows" or "columns"- just positioned cells. Wrapping would add extra elements which could slow down scroll performance. (Probably not much, but every little bit counts for scrolling.)
and then use display table-cell/table-row to get the desired,
table-like behavior?
If you're using MultiGrid I assume you have enough columns to warrant windowing horizontal data as well as vertical? In which case, I don't think display:table would really work for you. I'm not sure what it would buy you.
Have you considered just rendering a non-RV layout specifically printing? I Haven't done this myself but maybe you could tap into beforeprint/afterprint and setState to render a different result? Alternately you could try setting overflowColumnCount really high when print mode is enabled to just render the entire horizontal axis.
I don't really have much experience with this unfortunately. It might require a little of experimentation on your part for the best performing solution. :)

How do state machines deal with events that contain value(like floor number)?

I am playing around with http://boost-experimental.github.io/msm-lite/tutorial/index.html (tag is for boost-msm because there is not tag for msm-lite but similar question applies) and I have a question wrt designing state machines with many possible inputs.
Imagine you are modelling elevator. Beside obvious states like moving, stopped, door_open, door_closed I wonder how to model button pressed(that is a number from -2 to 39) since it is not feasible to have that many events(42 just for every button pressed).
I guess if you design a floor selection with 42 buttons you would probably not map them each to a single input, but make a matrix (nobody will put 42 buttons on top of each other, would one?). Then of course you would not model each row an column but only two so you can show the sequential polling of each row column. Maybe you could also use "intelligent" buttons today that have a microchip which sends some "I have been pressed" information a serial line. Or you introduce a voice recognition.
Having listed those few examples, I tend to close this question as simply too broad.
You can use guard conditions on transitions. They look like [currentFloor != requested floor]. Perhaps a better way is to model events like upper floor selected, lower floor selected, current floor selected. That collapses 42 buttons into three categories rather neatly.

Search by using the keyboard in a list/grid - algorithm

I need to implement a custom search in a grid and I would like to find some user interface guidelines that explain the standard way to implement it.
I mean this kind of search that is initiated by the user using the keyboard. The focus on the grid must move to the first row that match the pressed key.
I would like to find a good algorithm to do it.
Thanks.
There is no standard way, many grids/lists implement this in different ways and it drives me bonkers. Some only search on the first letter, some search on multiple letters without indicating which ones, others show a (non-modal) window that shows which letters it is currently using, others keep this buffer hidden and use a timeout to reset, other don't reset at all or with a (hidden) key like esc.
From the way you phrase your question it sounds like a simple 'jump to first row that starts with the pressed char' - which is the simplest use case, and I fail to see what the 'algorithm' in this case should do.
If there is a specific application you want to mimic I think you should provide a detailed description of its behavior. Although I think that after making this description, the algorithm will be peanuts.

Resources