samtupy / nvgt

The Nonvisual Gaming Toolkit
https://nvgt.gg
Other
43 stars 27 forks source link

form. A fue improvements for go to line functions #62

Open peter1384 opened 3 weeks ago

peter1384 commented 3 weeks ago

1: currently, If a list is in focus, the go to item dialog appears and allowes us to select an item in the list, and if a multy line editbox is in focus, the go to line dialog appears, allowing to find a line number and a line columb. But, When a non multy line editbox is in focus, This dialog cannot help us at all currently, But, If a non multy line edit box is in focus, this dialog should open, with only line columb, and an ok and a cancel button, allowing us to set the line columb in a long line inside the non multy line editbox 2: Currently, if you enter an out of range line number for example you only have 10 lines and you enter 11 and press enter, you get invalid line number error, But this is not the case for the line columb. If you enter an out of range number columb for a line and press enter, you will be put on the last columb of the line and you won't get an invalid line columb error, Which you should. I didn't find how to fix this in the form.nvgt my self

harrymkt commented 3 weeks ago

I don't think we should place invalid error in line columb, as Notepad itself is the same does that, putting to the last or first whatever is available.

peter1384 commented 3 weeks ago

@harrymkt yes, We should get error if we enter an out of range columb, for example, a line only have 4 columbs and you enter 26 for the columb number. In this case, If We don't get a out of range columb error, The user will be confused and can think that actually they are now at columb 26, But in reality, This line only has 4 columbs and the user is at columb 4, So for this reason and also teknikly, We should have these errors, As we have for the line numbers Also, notepad doesn't support go to line columb, only line number, And that's what I like about nvgt's form

harrymkt commented 3 weeks ago

@peter1384 It's correct.

However, Notepad++ has the ability to go to a specified offset, or column, and it moves to last and first depending on the input.

Even though they are moved to last or first, users won't I think confused, because they have been put in blank character, which means they can type in last or first, so I don't think this is a big issue.

But yeah, it is good to provide as an optional feature.

peter1384 commented 3 weeks ago

@harrymkt yeah, it's good that you understand, Also, I have another reason for needing this error. I've built a notepad for my self with nvgt since I like it, And I use it to figger out my code compilation error problems. So when I get compilation error in my code, and it says on line 226 25, I quickly open my nvgt notepad, press ctrl g, and enter 226 in line number, and 25 in line columb, And if such line number or line columb doesn't exist in my code, I'd like to get an error raather than my line number or columb set focused on anything else

peter1384 commented 2 weeks ago

@samtupy Currently, This dialog only has one editbox which renames between line number and item number, and if a multy line editbox is in focus, the line columb will be inserted in it, so it will contane line number and line columb in that case. This is all that i've understood from that class. So if we want to have only line columb for the non multy line editboxes, what should we do? it is a bit unclear for me, it would be much simpler i think if we said if list is in focus, do blaaablaa. else if is multy line do blaablaa. But currently it only says if a list is in focus, rename to go to item, and then a kolen, and go to line, and insert line columb. I'm not so much advance to change that, And I think that kolen can only be useful if we only have 2 cases, but not more than 2. Can you please have a look? thanks!

samtupy commented 2 weeks ago

Hi, I agree with these changes and will implement them in the coming days.

samtupy commented 2 weeks ago

To answer your question specifically, you would set the f_index field to hidden once it turned out that a single line text field was in use.

peter1384 commented 2 weeks ago

@samtupy hi, Thanks! even with that, I don't know the function name to hide a feald in nvgt form lol, and yeah i'll just let you do it. Thanks! i'm excitedly waiting for it!

peter1384 commented 2 weeks ago

@samtupy hi, I wanted to do the first case and only leave the second case to you because I know I can do that, I just don't know how to hide a feald in the form. I saw the boolians about enabled and visible, And I tryed to check if the feald was not multi line, I go f_index.visible = false That gets compilation error, And I go also f_index.enabled = false for both, I get error: visible is not a member of int and, error: enabled is not a member of int If you tell me how should I hide the feald I can do the first suggestion that was requested in this issue, But i'll leave the second one to you. Thanks!

peter1384 commented 2 weeks ago

@samtupy actually, I've just noticed this go to line functions does not work at all, But I don't know why, But it works in stw inputs, But I tryed it with both nvgt 0.85.1 and 0.87.2 but it doesn't work, having 5 lines in the editbox, focusing on line 1, and entering 5 or 4 or anything in line number and pressing enter just stays at line 1 focused on line 5 and entered 3 or 2 in line number and pressed enter, I got focused on line 1 But in stw inputs this works fine completely Just in case the problem is from my script that i'm trying this with, hear is the code for my script

include "form.nvgt"

audio_form f; void main(){ show_window("My test"); f.create_window(); int multtxt=f.create_input_box("text", multiline: true); while(true){ wait(5); f.monitor(); if(key_pressed(KEY_ESCAPE)) exit(); } } Lol, Strange that this is not working

samtupy commented 2 weeks ago

Oops you are correct, this was accidentally broken when form.nvgt got converted to no longer need bgt_compat.nvgt. I shall fix it when I attend to the other things in this issue, thanks. As to your question in the comment before last, f_index is indeed an integer. You need to call the form.set_state method passing f_index as the first parameter.

peter1384 commented 2 weeks ago

@samtupy ok then. I'll just let you do everything in this issue As another suggestion, This dialog can be even extended to be useful for sliders as wel, And to be called go to value in that case, And any number or word you enter in that editbox, If such exist in that slider, you should be focused on that, As nvgt's form's sliders are not only limited to having only numbers, They can also have words, Such as this. Compress packets when they become larger than Slider: no compression What do you think about this suggestion as wel? Though if you agree with this to be implemented as wel, We can no longer have this class as like this. f.create_window((type == ct_list ? "go to item" : "go to line"), false, true); and we have to define if type.ct list blaablaa else if type.ct input blaablaa else if slider blaablaa Which I think This way is more clearer if that class becomes like this your opinion?

peter1384 commented 2 weeks ago

But, You know better. May be this kind of code has its disadvantages also, As we need to create the f index feald for all cases, but in the current state you only created the f index once, And you are using it for everything So, I trust you that you can do this in the best way possible

peter1384 commented 1 week ago

@samtupy thanks, the go to line functions are working perfectly fine now, But the line column has a problem. step in line 1 which is hello, And don't change line number, Just line column if you set any columb and press enter, and you look at the character or press ctrl+g and look at the selected line column in the line column editbox, you'll see that it's one number above than what you wanted to go. example. Setting line columb as 2 and pressing enter, it will move to column 3, entering 3 wil move to column 4, etc note: This only happens with the first line of your text and column movement works with out any bug in second line and heier if you have more than 1 line, And if you only have a single line of text, This column bug will also happen with that, as your line is considered the first line oof, how hard

peter1384 commented 1 week ago

@samtupy This also happens with stw inputs, So don't worry, it's not because of your recent codes. Now my multi line editbox is exactly same as stw, meaning both have the same bug in same way as provided above

peter1384 commented 1 week ago

don't care about the note 2 provided by me because it was a bug in that time and now nothing about it, and i'll edit my comment and remove it

peter1384 commented 1 week ago

oh! how notepad plus plus is stupid! Since i've heard it supports going to column and line, I downloaded it to try how is it, And When I pressed ctrl+g on it, It showed me an editbox with lable line number, and a set of radio buttons contaning line number, and offset options, And a go button and a cansel button, And the lable of editbox was changing depending on the radio buttons selection to number or offset How stupid! That's what I like about nvgt, We can have both line number and line column editboxes in the dialog, allowing us to set both number and column in one operation But the search text dialog having a set of radio buttons makes sence because you can only go one direction, You can't search next and prev both at the same time, But that's also fine anyway and can be kept as it is currently because if you want to find next you would press next button, and if you want to find prev you would press the prev button But please don't change the go to line dialog's interface, it's very nice as it is currently, And that's what why I prefer nvgt's form's go to dialog over notepad plus plus which also supports line column