Page 2 of 2

Re: xOS v0.07 -- testing needed!

Posted: Sun Jan 29, 2017 1:45 pm
by monobogdan
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: Select all


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);
}


Re: xOS v0.07 -- testing needed!

Posted: Sun Jan 29, 2017 2:22 pm
by BrightLight
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...

Re: xOS v0.07 -- testing needed!

Posted: Sun Jan 29, 2017 2:32 pm
by monobogdan
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: Select all


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);
}

Re: xOS v0.07 -- testing needed!

Posted: Sun Jan 29, 2017 2:55 pm
by dozniak
monobogdan wrote:

Code: Select all


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.

Re: xOS v0.07 -- testing needed!

Posted: Sun Jan 29, 2017 3:01 pm
by BrightLight
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.

Re: xOS v0.07 -- testing needed!

Posted: Sun Jan 29, 2017 3:59 pm
by monobogdan
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?

Re: xOS v0.07 -- testing needed!

Posted: Sun Jan 29, 2017 4:11 pm
by BrightLight
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.

Re: xOS v0.07 -- testing needed!

Posted: Mon Jan 30, 2017 12:35 am
by dozniak
monobogdan wrote:
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: Select all

& keychar != vk_space

Re: xOS v0.07 -- testing needed!

Posted: Tue Jan 31, 2017 11:16 am
by MichaelFarthing
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.