I am trying to understand this paragraph, if anyone can understand this, can he/she explain me? espacially strong black sentences..
thanks...
Buffer has to be an array. Implement two stacks on top of buffer
array. One stack grows from left to right and the other stack grows
from right to left.
When a character is inserted, push it to left stack.
When a character is deleted, pop from the right stack.
When cursor is moved to left, pop the top character from left stack
and push it to right stack
When cursor is moved to right, do opposite of left move
get(i): If i is less than left top then return buffer[i]. If it's more
then return buffer[right + i - left]
I had this assignment this semester. Here is my solution, if anyone is still looking:
https://gist.github.com/avindra/6572866
Related
I am drawing text on a UIView using core graphics, the restriction with this is that when the UIView is fully drawn to the end i can't shift all drawn text above to create empty line at the bottom to draw new text. I don't want to use the UITextView and UITableView.
A visual explanation:
Suppose a have a view as below to draw the text-
So I am on the last line in this view and when this line is completely filled, I have to shift to one line below which is not there. What I want to do is to shift the whole screen text one line up (shifting out the first line from screen), to make space for new line.
This view is actually a larger one to provide scroll back, but to explain the situation I just mentioned so.
Is there any way to do so? Please suggest.
If you want to provide scroll back, it means that you don't want to shift the whole text up to make space for one more line. Because in doing so you will lose the first line.
What you need to do is resize the view and make it bigger, this way you have more space to draw some more lines.
I would advise you to use a UITableView instead. It's too much work to draw the text by yourself and provide scrolling and all for no apparent advantage. Maybe just so you can learn how to do it :)
I have an NSSplitViewDelegate, and I'm constraining the SplitPosition. However, in an edge case, if I move the cursor dragging the divider off the edge of the screen, the divider itself starts at (0, 0). However, this happens even if the proposedPosition is 200, all I have to do is quickly drag the mouse off the screen. Is there any reason that the divider is being set to 0?
PseudoCode
constrainSplitPosition
ProposedPosition = 220 (after dragging mouse off screen quickly, so last marker is at 220)
splitView
(returns a drawnRect for the divider at origin (0,0), corresponds to mouse off screen).
Any ideas, thanks!
You need to add a constrainMinPosition function as outlined in the apple documentation.
is there a good way to make the container div expand to the left and top when a draggable is dragged outside of its borders?
When you drag to the right or down the container div is properly extended, and scrollbars appear as needed. Yet moving to left or top means that the draggable items has negative top / left position, so the container is not expanded.
Here's a fiddle that demonstrates the existing dragging behaviour: http://jsfiddle.net/NPC42/Un23w/1/, but this can also be seen on the official jQueryUI demos too (http://jqueryui.com/demos/draggable/#default).
I'd like to be able to expand to the top / left too :)
A brute-force approach would be to:
Reset all of the object's positions on the container div to that no negative top / left is required (including the object being dragged).
Change the scrolling position to make it look as if the objects are still on their spots.
But for many objects in the container this could cause a lot of flicker, or even slowdown, so I don't really want to go in that direction. Any suggestions are welcome!
The problem is that every html element has an absolute (0,0) origin coordinate in the top left corner. When you drag in that direction the coordinates for the dragable become negative. However the scrollbars can not become negative, their size can only grow in a positive direction.
I can imagine a custom scrollbars widget that can adjust in a negative direction when you drag below (0,0). Also try having a container inside of another container with the inner one move around so that all of the objects inside it don't have to be individually moved. I don't know of any in existence as it would be kinda weird to have a negative scroll offset.
I have a toolbar at the bottom of my screen. I want to have two buttons on it, one on the left side, and one on the right. However, unlike a navigation bar, there are multiple spots that aren't on each far side of the bar, but rather they stack next to each other from the left to right.
I tried using a fixed separator, however the length doesn't stay contant (the button needs to stay on the far left while another is on the far right) as orientation and device changes. So, how would I go about keeping the buttons on each side of the toolbar no matter the orientation and device? I feel like there has to be an easier way than getting the device type and orientation and varying the length for each one.
I tried my best to explain, and I can understand if there was an issue understanding what I'm trying to say. If you need any clarification or other details, just ask!
Thanks
Jake
There are two separators, a fixed separator and a flexible separator. You used the wrong one; use the flexible separator!
Basically the same as this question: How to make an infinitely long scroll view on iPhone? but using jQuery Mobile not objective C.
I'm using this plugin: http://jquerymobile.com/test/experiments/scrollview/scrollview-direction.html in particular the example under "Horizontal Scrollview". I want it to loop back on itself so when the user gets to the far right, it will go back to the start and if they scroll left from the start it will go to the end.
I'm not bothered if the solution uses the scrollview plugin in particular or not just that it can have a similar effect.
UPDATE: I eventually did a different way as moving elements to the end or the start of the list seemed flickery with jQuery Mobile scrollview on an iPhone.
What I did was copy all of the li elements within the ul 3 times, so that it was 4 times longer. Then at the start of the script, position the scroll point at the start of the 3rd copy (so the left most point of the screen was exactly half way along the length of the list).
Then whenever the scroll position went beyond the start of the 4th copy, simply move the scroll position back to the middle (offset by how many pixels over it went). Then the same in reverse, triggering it went it went beyond the start of the 2nd copy. Reason I needed 4 copies was so there was a bit of leeway when you scrolled left fast and it went beyond the start of the 2nd copy.
So essentially you want to do something simular to what I did for: http://bbh.co.uk?
The logic is very simple, let's say you have 7 panels, the first thing I did was work out where the 0 point of the movement, that is where the centre of the 7 panels, in this case it's the 4th as we'd have 3 on the left and 3 on the right.
With this 0 point we can then decide where panels will go onces a scroll has occurred, say the user scrolls 2 from the left to the right, this means our 0 point becomes -2, therefore we move two from the right to the front of the left, i.e. we prepend them to the list.
The easiest way to manage it was with an array, since we can .push(), .pop(), .shift() and .unshift() the panels.
Once we had the logic in order we placed each set the CSS position of each panel as absolute and then calculated its position depending on where it was within the array, for example panel 0 would be at 0px left in the container and panel 7 would be at panel.width * 7 and so on.
You then need to make sure that the container is at the centre, that initial 0 point and boom, you've got some infinite scrolling.