Ohh, so the rest of the code acts asa a delay for the cursor? That's clever, I'll see if I can get mine to work like that.

Kerning is spacing between characters. In the gif you posted, characters like i and t have really large spaces after them, which would be considered bad kerning.
M. I. Wright wrote:
Kerning is spacing between characters. In the gif you posted, characters like i and t have really large spaces after them, which would be considered bad kerning.

Oh, I see. Actually, I did have 3 different versions of the note-editing at first, but I got rid of them because it would be very hard and time-consuming in the program to find what part of the note you were editing, and where to move the cursor too (for the cursor to move to the right spot, I originally had 2 For() loops with pxl-Test, and it would keep moving over 1 until there were no pixels in a column - but that was just slightly too slow).

My original one had all the characters that weren't 3 pixels wide documented, and would adjust the spacing accordingly. Perfect kerning, that is. However, I got rid of this because it would've been too hard, like I mentioned above.

My second one involved matrices to print special tokens that were over 3 pixels wide, but as you may guess, that was not very practical and it just took up unnecessary time and space.

My final one (although nowhere near complete yet) spaces out each character by 3. To deal with special tokens that were over 3 pixels wide, such as "m", "w", "z", "*", and pi (which I removed), I instead did a capital M and some graphical adjusting to make it shorter. Same with the w. For the Z, I just let the cursor cut the 4th pixel off so that it became 3 pixels. For the "*", I just replaced it with a Pt-On() command.

Also, Mateo suggested that each character be a certain amount of pixels apart, to save speed/time:
MateoConLechuga wrote:
As for text wrapping and character spacing, it might be easier to just let all characters be 5 (or 4?) pixels in width, that way no crazy time-consuming calculations have to take place. Just an idea. Otherwise you may be able to have a list of certain character widths, of pxl-Test(), but that would cause a lot of overhead.

So, I most likely won't try to fix the kerning...

However, another thing I could try is to center each character on where they would go, but I'm not sure...

EDIT: The only way to find where you are / what part of the note you're editing, each character has to be 3 pixels in width (or less). Here's the formula I came up with to find where you are:

Code:

23round((A-6)/6,0)+B/4+1
UI for OneNote:

Looks good?
Looks pretty good, solar! I like it Smile

M. I. Wright wrote:
Ohh, so the rest of the code acts as a delay for the cursor? That's clever, I'll see if I can get mine to work like that.

Well, yes, but I don't know how much "getKey->K" really slows it down...

I would add a rand(#) in there, but it should be obvious why I'm definitely not going to do that. Although it would be cool to have the cursor blink slower so you can actually see it blink, it's much easier to just have it be grayscale Smile
Oops, accidentally edited this post when I should've made a new one. Previously this was a todo list Razz
Hurray, adding and replacing characters in the string now works!


Code:

23round((A-6)/6,0)+B/4+2->theta
If length(Str7)-1>Ans  //if your cursor is greater than or equal to 2 away from the end of the string
sub(Str7,1,Ans)+Str8+sub(Str7,Ans+2,length(Str7)-(Ans+1->Str7
If theta=length(Str7  //if your cursor is at the last possible place to continue editing (at the end of the string)
Str7+Str8->Str7
If theta=length(Str7)-1   //if your cursor is 1 away from the end of the string
sub(Str7,1,theta)+Str8->Str7

Optimization is appreciated Smile

Also I would like some answers to the questionable things I had in the last post. I'm wondering whether things like inserting text is worth it - if I were to add it, I would have to update the graphical placement of every character after it, which technically wouldn't be that hard, but the fastest way to do it would be to insert the text, and then display the note all over again, using sub() to redraw the string on every row. That might be slightly too slow, impeding user experience. I would greatly appreciate your thoughts.
This is smaller:

Code:
23round(A/6,0)+B/4-21->θ
sub(Str7,1,θ)+Str8
If θ+1<length(Str7
Ans+sub(Str7,θ+2,length(Str7)-θ-1
Ans->Str7


This is larger than the above but faster with the cursor at the end of the string:

Code:
23round(A/6,0)+B/4-21->θ
If Ans=length(Str7
Then
Str7+Str8->Str7
Else
sub(Str7,1,θ)+Str8
If θ+1<length(Str7
Ans+sub(Str7,θ+2,length(Str7)-θ-1
Ans->Str7
End


Edit: saved one byte.
Thanks, lirto Smile
You could do this for highlighting, although it assumes that you start from the end of the string, which won't always be what you want. It's a start, though:

Code:

If K=[highlight key]:Then
length(Str8->Z //replace Str8 with the string that the note is in. Z is the highlight index var
Repeat K=105
getKey->K
Z-(K=24)+(K=26->Z //no bounds checking
"""code for highlighting the text goes here; something like
DelVar B //B is the row variable
3(Z-1)->A //convert Z to a draw-able coordinate. You said that the letters were 3 pixels, so I multiplied Z by 3
While A>max_width //If the screen's width is less than A
A-max_width->A
B+1->B //move the 'pointer' down a row
End
InvertRectangle(A,B"""
End
Str8
sub(Ans,Z,1+length(Ans)-Z->Str7 //replace Str7 with whatever you want the clipboard to be
End

Edit: fixed broken code
edit: although it's no longer necessary, I commented it
Okay, I'm going to need a bit of help with the highlighted text tracker... One way M.I. Wright suggested was to only keep track of the start and end of the highlighted text, and then when the user presses the copy button (TRACE), it takes the sub() of the current string, starting at the beginning and ending at the last highlighted text. However, I'm having a bit of difficulty...

The way I have it setup is that X is the constant, where the start or end of your highlighted text is. V is the one that moves around with your cursor, if you are highlighting. Then, when you want to copy, it determines which variable is greater, which enables it to know which variable it should put first in the sub() command. If X=0, it stores the placement in the string of the cursor in X. Every time after that, it stores the placement to V. Btw, you can look at earlier posts to see how I converted the cursor value to string placement.

My code is hardly working at all, so I would appreciate some help...

[EDIT]
another problem is that the numbers will have to change whether you are highlighting from right to left or left to right. My code is pretty much nothing, I'm just tossing around numbers right now... I think I'm tired.

[EDIT 2]
I believe I fixed it. Just had to change some numbers around.

Here's for tracking (and highlighting):
Code:

Line(B,62-A,B,57-A,0
For(F,B,B+3(K-25),K-25
For(G,A,A+5
Pxl-Change(G,F
End:End
If not(X
23round(A/6-1,0)+B/4+2->X
B+4(K-25->B
23round(A/6-1,0)+Ans/4+2->V

and here's for copying:

Code:

If K=14 and X!=V:Then
If X>V
V+.01X
If V>X
X+.01V
sub(Str7,iPart(Ans)+1,100fPart(Ans)-iPart(Ans->Str6   //in the future i'll just add it to the beginning of BasicNote's entire note string
End
End:End


If you can optimize this, great Smile
Could you give us a video of what it yet looks like?
PT_ wrote:
Could you give us a video of what it yet looks like?


I will, but later. Not much has changed (graphically) since my last update post.
Well, if I see all the things good, you have a Str1 with the text, where you can add, replace or delete text somewhere in the Str1 at index V.
Here's what I came up, notice that I haven't tested it yet.

Add text:
Code:
sub(Str1,1,V)+[character]
If V<length(Str1
Ans+sub(Str1,V+1,length(Str1)-V
Ans->Str1
V+1->V


Replace text:

Code:
sub(Str1,1,V)+[character]
If V<length(Str1)-1
Ans+sub(Str1,V+2,length(Str1)-V-1
Ans->Str1
V+1->V


Delete text:

Code:
sub(Str1,1,V
If V<length(Str1)-1
Ans+sub(Str1,V+2,length(Str1)-V-1
Ans->Str1


What I would do for displaying your text, is NOT drawing each time the whole string, that takes much time. I think you only have to draw the section of the string on the line where the cursor is. Example, if your text looks like:

Code:
ABCDEFGHIJKLMNO|PQRSTUVWXYZ
ZYXWVUTSRQPONMLKJIHGFEDCBAB

(notice the 'cursor' between O and P), you only have to draw each time "ABCDEFGHIJKLMNO|PQRSTUVWXYZ"
To draw the string:

Code:
Text(1,1,sub(Str1,1,V)"|"+sub(Str1,V+1,length(Str1)-V-1

Sorry, but I have no idea to make a flashing cursor, since not all the characters have the same width in pixels. You should implement multiple lines etc. by yourself.
This is going to sound rather silly; but I believe that this program here will be of great help to you. It is no where near optimized; and could use a bunch of work, but it has many things that I think you are looking to implement. Lbl G in the main file contains things to do text selection; which is relatively fast because it doesn't do text highlighting. In order to highlight text though, it would be advantageous to just invert each character at a time, from the starting offset to the end, as this way you won't end up with weird rectangles and such.

Document XE: Link

I wish that I could be of more help; but text highlighting in basic is really no easy task. This would be your best bet though. Smile
MateoConLechuga wrote:
This is going to sound rather silly; but I believe that this program here will be of great help to you. It is no where near optimized; and could use a bunch of work, but it has many things that I think you are looking to implement. Lbl G in the main file contains things to do text selection; which is relatively fast because it doesn't do text highlighting. In order to highlight text though, it would be advantageous to just invert each character at a time, from the starting offset to the end, as this way you won't end up with weird rectangles and such.

Document XE: Link

I wish that I could be of more help; but text highlighting in basic is really no easy task. This would be your best bet though. Smile

Indeed, that is fairly unoptimized... But thanks for that, it might help! Smile

Oh, and congrats on 1111 posts Razz
I got highlighted text tracking and copying working today(but not pasting yet). I'll have to add multi-page note support for the whole program later, though...

Btw, the text wasn't being copied automatically. To copy highlighted text, you press [TRACE].
jsTIfied was being a bit buggy and slow, so sorry if it looks a bit strange.

Still got lots of stuff to do, some graphical things to fix, and such. I'm also thinking about putting the title editing back on the graph screen instead of the home screen, but I'm not sure yet Smile

See my post here for updates on what's done or not done.
Progress Update: I'm currently trying to fix the cursor in highlight mode. The main problem is right around with the For() loops - just trying to get rid of the line between the characters that sometimes gets left behind. Here's the current code that I'm trying to fix:

Code:

If S and sum(K={24,26
Then
If A>8 and K=24 and not(B:Then
92->B:A-6->A:End
If B=92 and A<54 and K=26
DelVar BA+6->A
If (length(Str7)>23round(A/6-1,0)+B/4+2 and K=26) or (K=24 and (B and A=8) or (B!=92 and A=54) or A>8 and A<54:Then
Line(B,62-A,B,57-A,X>V  //this is the main problem. The For() loops are also part of the problem.
For(F,B,B+3(K-25),K-25
For(G,A,A+5
Pxl-Change(G,F
End:End
If not(X
23round(A/6-1,0)+B/4+2->X
B+4(K-25->B
23round(A/6-1,0)+Ans/4+2->V
End:End

As you can see in the gif in the last post, the cursor gets left behind sometimes when highlighting, which is obviously not wanted, like I said.

1)If I first erase the cursor before pxl-changing, the pxl-change will change it back to a line, leaving it behind.
2)If I first draw the cursor before pxl-changing, it will erase it, however that just leaves separation between highlighted characters, instead of a smooth line of highlighted text.

Both options look fine in the opposite direction of highlighting, i.e. #1 is fine going left, and #2 looks fine going right.
Michael2_3B wrote:
Both options look fine in the opposite direction of highlighting, i.e. #1 is fine going left, and #2 looks fine going right.

Then use different code based on which direction arrow is pressed?
parrotgeek2 wrote:
Michael2_3B wrote:
Both options look fine in the opposite direction of highlighting, i.e. #1 is fine going left, and #2 looks fine going right.

Then use different code based on which direction arrow is pressed?

No, the arrow key does not affect anything. What changes it is whether you are highlighting or de-highlighting / left or right. Update: #1, when highlighting right to left, leaves blank lines in between the highlighted text, and de-highlighting (left to right) looks fine. #2 looks great highlighting left to right, but when de-highlighting (right to left) the cursor gets left behind.

Still thinking, but I need a bit of help Smile
Michael2_3B wrote:
parrotgeek2 wrote:
Michael2_3B wrote:
Both options look fine in the opposite direction of highlighting, i.e. #1 is fine going left, and #2 looks fine going right.

Then use different code based on which direction arrow is pressed?

No, the arrow key does not affect anything. What changes it is whether you are highlighting or de-highlighting / left or right. Update: #1, when highlighting right to left, leaves blank lines in between the highlighted text, and de-highlighting (left to right) looks fine. #2 looks great highlighting left to right, but when de-highlighting (right to left) the cursor gets left behind.

Still thinking, but I need a bit of help Smile

Keep track of the direction in which highlighting started AND which arrow key is pressed?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
» View previous topic :: View next topic  
Page 4 of 9
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement