Skip to content
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

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

Open
peter1384 opened this issue Jun 19, 2024 · 22 comments
Open

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

peter1384 opened this issue Jun 19, 2024 · 22 comments

Comments

@peter1384
Copy link

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
Copy link
Contributor

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
Copy link
Author

@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
Copy link
Contributor

@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
Copy link
Author

@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
Copy link
Author

@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
Copy link
Owner

samtupy commented Jun 24, 2024

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

@samtupy
Copy link
Owner

samtupy commented Jun 24, 2024

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
Copy link
Author

@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
Copy link
Author

@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
Copy link
Author

@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
Copy link
Owner

samtupy commented Jun 30, 2024

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
Copy link
Author

@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
Copy link
Author

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 peter1384 changed the title form. A fue improvements for go to line functions form. The go to line functions are completely broken, plus A fue improvements for go to line functions Jul 1, 2024
@samtupy samtupy changed the title form. The go to line functions are completely broken, plus A fue improvements for go to line functions form. A fue improvements for go to line functions Jul 1, 2024
@peter1384
Copy link
Author

peter1384 commented Jul 1, 2024

@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
Copy link
Author

@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
Copy link
Author

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
Copy link
Author

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

@harrymkt
Copy link
Contributor

Hello @peter1384.
I have implemented the changes of supporting go to line offset on non multiline input at #79, so you can use it by including in your projects until it gets merged.

Enjoy!

samtupy pushed a commit that referenced this issue Aug 9, 2024
Audio Form modifications:
* You can use `audioform_keyboard_echo` property to save in your game data file, and then retrieve it when the game loads the data etc.
	* Once an input field is popped out, You can use the F2 key to change between echo modes. The changed echo mode will be spoken out loud, as well as setting `audioform_keyboard_echo` property to match with the changed echo (fixes #77).
	* The `reset` method now takes a new parameter, true by default, which resets the form's echo mode to default. This is useful to retrieve the value of the `audioform_keyboard_echo` property.
* The go to line functionality can now be used on non multiline input fields as well. In non multiline fields, the line number field will be invisible (references #62).
	* Added a new property in `control` class called `enable_go_to_index`, which is true by default, which allows setting to enable or disable the go to line functionality. This is natively used in `go_to_index` class to disable the ability to promt the dialog on go to line dialog over and over.
	* Added a new method that allows you to toggle the go to line functionality. `bool set_enable_go_to_index(int control_index, bool enabled);`

Sound Pool modifications:
* Added a new parameter in `update_listener_3d` function called `refresh_y_is_elevation` (bool) which toggles whether the sound pool should refresh the global `sound_pool_default_y_is_elevation` property. This makes it possible to constantly change the global property for the sound elevation.

Token Gen modifications:
* A new parameter has been added, `mode`, which you can choose the mode to generate, see `token_gen_flag` enum constants for possible modes. Default mode is `token_gen_flag_all`
@amirmahdifard
Copy link

@harrymkt first, really thanks! then, I think you can also very easily do the second point in this issue as wel! look at set column function, we have 2 values there, one is int col and the other is int maxcol. So, up on pressing ok button for this dialog, along other checks, you can add else if col grater than maxcol invalid column! return; sorry, i'm typing on phone so that's why I didn't typ simbles and stuf. Thanks a lot!

@harrymkt
Copy link
Contributor

Hello @amirmahdifard.

First of all, I think it is not necessary because it moves to the last maximum possible column, so user can continue its typing from the last.

Please let me know why you think this should be implemented.

Thanks!

@harrymkt
Copy link
Contributor

The column minus issue when it is used on line 1 has been resolved at #84.

@amirmahdifard
Copy link

amirmahdifard commented Aug 26, 2024

it's ok anyway, thanks!

harrymkt added a commit to harrymkt/nvgt that referenced this issue Oct 10, 2024
* `set_line` function now returns an int rather than a bool. Values are 0 for success, 1 for invalid line and 2 for invalid coloumn, as well as -1 for an internal error.
* You can no longer go beyond the maximum coloumn in form input. For example if the input has 50 characters in length, you can go up to 51, because 51 will be the blank character from which you can continue to write from the end. This change closes samtupy#62.
* Improved the touch.nvgt `is_available` method's return value as `return dev.length() > 0;` for short.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants