OSDev.org
https://forum.osdev.org/

xOS v0.07 -- testing needed!
https://forum.osdev.org/viewtopic.php?f=2&t=31310
Page 2 of 2

Author:  monobogdan [ Sun Jan 29, 2017 1:45 pm ]
Post subject:  Re: xOS v0.07 -- testing needed!

omarrx024 wrote:
monobogdan wrote:
Looks nice :)

Is checkbox/combobox/multiline textbox controls implemented, or it's only showcase?

Thanks!
No, the only components implemented at the moment are label, button and gbutton (which is basically a button whose look can be enhanced). The text box is my next coming priority, and then the list box, as both are needed for the file manager I have in mind, and the text box is the main thing in a text editor as well. :)


Implementing textbox is easy.

You simply need add chars to textbuffer.

Some example code:

Code:

int x;
int y;
string str;

void process(int keychar) {
  if(keychar != vk_return & keychar != vk_escape & keychar != vk_control & keychar != vk_space) {
    str += (char)keychar;
  }
  if(keychar == vk_backspace) {
    str = str.remove(str.length, 1);
  }
}

void draw() {
  drawstr(x, y, str);
}


Author:  BrightLight [ Sun Jan 29, 2017 2:22 pm ]
Post subject:  Re: xOS v0.07 -- testing needed!

monobogdan wrote:
Implementing textbox is easy.

You simply need add chars to textbuffer.

You also need to handle line overflows/text wrapping, select all, some copy/paste mechanism, arrow keys and cursor position, etc...

Author:  monobogdan [ Sun Jan 29, 2017 2:32 pm ]
Post subject:  Re: xOS v0.07 -- testing needed!

omarrx024 wrote:
monobogdan wrote:
Implementing textbox is easy.

You simply need add chars to textbuffer.

You also need to handle line overflows/text wrapping, select all, some copy/paste mechanism, arrow keys and cursor position, etc...


Code:

int MAX_STR = 255;
int x;
int y;
string str;

void process(int keychar) {
  if(keychar != vk_return & keychar != vk_escape & keychar != vk_control & keychar != vk_space & str.length() < MAX_STR) {
    str += (char)keychar;
  }
  if(keychar == vk_backspace) {
    if(str.length() > 0) {
      str = str.remove(str.length, 1);
    }
  }

}

void draw() {
  drawstr(x, y, str);
}

Author:  dozniak [ Sun Jan 29, 2017 2:55 pm ]
Post subject:  Re: xOS v0.07 -- testing needed!

monobogdan wrote:

Code:

void process(int keychar) {
  if(keychar != vk_return & keychar != vk_escape & keychar != vk_control & keychar != vk_space & str.length() < MAX_STR) {
    str += (char)keychar;
  }
  if(keychar == vk_backspace) {
    if(str.length() > 0) {
      str = str.remove(str.length, 1);
    }
  }

}

void draw() {
  drawstr(x, y, str);
}


omarrx024 wrote:
You also need to handle ...text wrapping,


No handling in this code.
omarrx024 wrote:
select all,


No handling in this code.

omarrx024 wrote:
some copy/paste mechanism


No handling in this code.

omarrx024 wrote:
, arrow keys and cursor position,


No handling in this code.

omarrx024 wrote:
etc...


Error in your code: when you press backspace it will be added to the string first, and then removed from the string, so the string itself will remain unchanged. Error #2: you cannot enter spaces into the string.

Author:  BrightLight [ Sun Jan 29, 2017 3:01 pm ]
Post subject:  Re: xOS v0.07 -- testing needed!

dozniak wrote:
No handling in this code.

Anyways, my OS is written in assembly, and I'm going to implement the text box in assembly, so either way I cannot use this code.

Author:  monobogdan [ Sun Jan 29, 2017 3:59 pm ]
Post subject:  Re: xOS v0.07 -- testing needed!

Quote:
Error in your code: when you press backspace it will be added to the string first, and then removed from the string, so the string itself will remain unchanged. Error #2: you cannot enter spaces into the string.

You can enter spaces.

It's sample code for example.

OP, why you not write applications in C, Pascal or anything?

Author:  BrightLight [ Sun Jan 29, 2017 4:11 pm ]
Post subject:  Re: xOS v0.07 -- testing needed!

monobogdan wrote:
OP, why you not write applications in C, Pascal or anything?

I will write a C library for my OS to let users have a "standard" way of writing applications, but in my early stages such as I am in now, it's unlikely anyone would write anything for me. In fact, it's unlikely anyone would write anything for anyone else on this forum, and so it's not high in my to-do list.

Author:  dozniak [ Mon Jan 30, 2017 12:35 am ]
Post subject:  Re: xOS v0.07 -- testing needed!

monobogdan wrote:
Quote:
Error in your code: when you press backspace it will be added to the string first, and then removed from the string, so the string itself will remain unchanged. Error #2: you cannot enter spaces into the string.

You can enter spaces.


I'm pretty sure you can not with the code you posted.

Code:
& keychar != vk_space

Author:  MichaelFarthing [ Tue Jan 31, 2017 11:16 am ]
Post subject:  Re: xOS v0.07 -- testing needed!

monobogdan,

Though far too polite to tell you so directly, Omarxx is miles ahead of you in his understanding of what is needed.
There is an English saying, "Trying to teach your grandmother to suck eggs" which roughly means that you are a relative beginner trying to give unnecessary lessons to an experienced person.

Page 2 of 2 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/