Armenian Knowledge Base  

Go Back   Armenian Knowledge Base > Technical sections > Operating Systems > Unix
Register

Reply
 
LinkBack Thread Tools
Old 27.08.2002, 09:23   #1
4294967296
 
Boyov's Avatar
 
Join Date: 03 2002
Location: /proc/1
Age: 33
Posts: 379
Downloads: 4
Uploads: 0
Reputation: 0 | 0
Post Unix programming question

Zdarova Lyudi

Ya znayu chtop etot topic imeet malo obshego
s programmiraovaniem, no ya bil bi super
extremely blagodaren vam esli bi vi mne otvetili na
odin vopros.

Vot cikl
-------------
do {

a++;

} while ('?')
--------------

chto nado postavit' vmesto '?'-a chtob etot cikl
ostanavlivalsy pri najatii klavishi? To est' ya znayu
funkcii tipa bioskey() ili kbhit(), no v standartnoy linuxovskoy
biblioteke ya ix ne nashel .

10x

Boyov.
__________________
Free your mind and your OS will follow
Reply With Quote
Old 27.08.2002, 10:18   #2
ЙЦУКЕН
 
Join Date: 07 2002
Location: 0x68,0x69,0x72, 0x69,0x6e,0x67, 0x20,0x6e,0x6f, 0x77
Age: 47
Posts: 3,118
Downloads: 0
Uploads: 0
Reputation: 5 | 0
Post

не надейся ... это тебе не windows и не дос
не дадут такого сделать

ну а что-то приблизительное ... тебе надо включить у терминала режим, -тоб он пересылал бы тебе символы сразу
а то так они пихаются в буфер ... и отдаются обыкновенно только после нажатия ентер
Reply With Quote
Old 27.08.2002, 10:40   #3
4294967296
 
Boyov's Avatar
 
Join Date: 03 2002
Location: /proc/1
Age: 33
Posts: 379
Downloads: 4
Uploads: 0
Reputation: 0 | 0
Post

Na samom dele ya uje sdelal tak chtobi u menya pod linux getch() normalno zarabotal, to est' on reagiruet bez najatiya <Enter>-a , ya v svoyu programmu takoy kusok koda vstavil kotoriy stavit terminal v "non canonical mode"(a v samom konce programmi estestvenno obratno v "canonical"). No razve vmesto '?' a mojno ispolzovat' getch() ?

10x
Reply With Quote
Old 27.08.2002, 17:03   #4
ЙЦУКЕН
 
Join Date: 07 2002
Location: 0x68,0x69,0x72, 0x69,0x6e,0x67, 0x20,0x6e,0x6f, 0x77
Age: 47
Posts: 3,118
Downloads: 0
Uploads: 0
Reputation: 5 | 0
Post

елы - палы ... ну отвыкайте вы от этого [censored] ДОС-а ))

ee. копай с сторону fctnl, O_NONBLOCK, может и заработает
Reply With Quote
Old 28.08.2002, 08:15   #5
4294967296
 
Boyov's Avatar
 
Join Date: 03 2002
Location: /proc/1
Age: 33
Posts: 379
Downloads: 4
Uploads: 0
Reputation: 0 | 0
Post

Ya nashel finkcii (tipa poll() i select()) , kotorie reagiruyut na najatiye klavishi, no problema v tom, chto oni vozvrashayut libo 1 libo 0 (tipa klavisha bila najata ili ne bila najata), no problema v tom, chto mne nado znat' konkretno kakaya klavisha bila najata.

Mojet u kogo nibud' est' kakiye libo idei ?

Spasibo
Reply With Quote
Old 28.08.2002, 19:38   #6
ЙЦУКЕН
 
Join Date: 07 2002
Location: 0x68,0x69,0x72, 0x69,0x6e,0x67, 0x20,0x6e,0x6f, 0x77
Age: 47
Posts: 3,118
Downloads: 0
Uploads: 0
Reputation: 5 | 0
Post

если я все правильно понимаю в юниксах, poll и select ничего общего не имеют ))

2. они работают с FD, а тебе нужны функции таботающие с терминалом ....
Reply With Quote
Old 29.08.2002, 11:09   #7
4294967296
 
Boyov's Avatar
 
Join Date: 03 2002
Location: /proc/1
Age: 33
Posts: 379
Downloads: 4
Uploads: 0
Reputation: 0 | 0
Post

OK, ya pereformuliruyu vopros

Esli ya vklyuchil u terminala rejim chtobi on peresilal mne simvoli srazu, kakaya funkciya skajet mne bila li knopka najata , i esli bila to kakaya?

Wishes

Artem.
Reply With Quote
Old 29.08.2002, 23:07   #8
Младенец
 
Join Date: 08 2002
Location: Yerevan
Posts: 4
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

Snachala ustanavlivaesh' v fctl O_NONBLOCK,
a potom, vmesto '?' stavish' fread(str, stdin...)
fread vozvraschaet 0 esli klavisha ne byla nazhata, ili >0 v protivnom sluchae... klavisha potom izvlekaetsya is str.

eto konkretno rabotayuschaya model', no mozhno escho poigratsya.. ..naprimer ispol'zovat' feo()

man fcntl, man fread recommended

armench aka levontiy
Reply With Quote
Old 30.08.2002, 01:42   #9
ЙЦУКЕН
 
Join Date: 07 2002
Location: 0x68,0x69,0x72, 0x69,0x6e,0x67, 0x20,0x6e,0x6f, 0x77
Age: 47
Posts: 3,118
Downloads: 0
Uploads: 0
Reputation: 5 | 0
Post

остается только согласится
Reply With Quote
Old 31.08.2002, 18:57   #10
4294967296
 
Boyov's Avatar
 
Join Date: 03 2002
Location: /proc/1
Age: 33
Posts: 379
Downloads: 4
Uploads: 0
Reputation: 0 | 0
Post

Many many many Thanks for useful info.

Boyov.
Reply With Quote
Old 01.09.2002, 01:27   #11
Консервативн
 
VX's Avatar
 
Join Date: 01 2002
Location: Кавказская Албания
Posts: 889
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

da, i eshe O_NONBLOCK upotreblyaut pri FIFO.
Reply With Quote
Sponsored Links
Reply

Thread Tools


На правах рекламы:
реклама

All times are GMT. The time now is 18:19.


Powered by vBulletin® Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.