OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Mar 29, 2017 3:27 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: xOS v0.07 -- testing needed!
PostPosted: Sun Jan 29, 2017 1:45 pm 
Offline
Member
Member

Joined: Wed Jan 25, 2017 3:37 pm
Posts: 71
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);
}



Top
 Profile  
 
 Post subject: Re: xOS v0.07 -- testing needed!
PostPosted: Sun Jan 29, 2017 2:22 pm 
Offline
Member
Member

Joined: Sat Dec 27, 2014 9:11 am
Posts: 760
Location: Maadi, Cairo, Egypt
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...

_________________
Byte me; OS site, source code.
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: xOS v0.07 -- testing needed!
PostPosted: Sun Jan 29, 2017 2:32 pm 
Offline
Member
Member

Joined: Wed Jan 25, 2017 3:37 pm
Posts: 71
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);
}


Top
 Profile  
 
 Post subject: Re: xOS v0.07 -- testing needed!
PostPosted: Sun Jan 29, 2017 2:55 pm 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 568
Location: Tallinn, Estonia
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.

_________________
Learn to read.


Top
 Profile  
 
 Post subject: Re: xOS v0.07 -- testing needed!
PostPosted: Sun Jan 29, 2017 3:01 pm 
Offline
Member
Member

Joined: Sat Dec 27, 2014 9:11 am
Posts: 760
Location: Maadi, Cairo, Egypt
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.

_________________
Byte me; OS site, source code.
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: xOS v0.07 -- testing needed!
PostPosted: Sun Jan 29, 2017 3:59 pm 
Offline
Member
Member

Joined: Wed Jan 25, 2017 3:37 pm
Posts: 71
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?


Top
 Profile  
 
 Post subject: Re: xOS v0.07 -- testing needed!
PostPosted: Sun Jan 29, 2017 4:11 pm 
Offline
Member
Member

Joined: Sat Dec 27, 2014 9:11 am
Posts: 760
Location: Maadi, Cairo, Egypt
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.

_________________
Byte me; OS site, source code.
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: xOS v0.07 -- testing needed!
PostPosted: Mon Jan 30, 2017 12:35 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 568
Location: Tallinn, Estonia
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

_________________
Learn to read.


Top
 Profile  
 
 Post subject: Re: xOS v0.07 -- testing needed!
PostPosted: Tue Jan 31, 2017 11:16 am 
Offline
Member
Member

Joined: Thu Mar 10, 2016 7:35 am
Posts: 99
Location: Lancaster, England
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 3 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group