- int pos = 0;
- int avail;
- tVTerm *term = &gVT_Terminals[ Node->Inode ];
- Uint32 *codepoint_buf = Buffer;
- Uint32 *codepoint_in;
-
- Mutex_Acquire( &term->ReadingLock );
-
- // Check current mode
- switch(term->Mode)
- {
- // Text Mode (UTF-8)
- case TERM_MODE_TEXT:
- VT_int_UpdateCursor(term, 1);
-
- VFS_SelectNode(Node, VFS_SELECT_READ, NULL, "VT_Read (UTF-8)");
-
- avail = term->InputWrite - term->InputRead;
- if(avail < 0)
- avail += MAX_INPUT_CHARS8;
- if(avail > Length - pos)
- avail = Length - pos;
-
- while( avail -- )
- {
- ((char*)Buffer)[pos] = term->InputBuffer[term->InputRead];
- pos ++;
- term->InputRead ++;
- while(term->InputRead >= MAX_INPUT_CHARS8)
- term->InputRead -= MAX_INPUT_CHARS8;
- }
- break;
-
- //case TERM_MODE_FB:
- // Other - UCS-4
- default:
- VFS_SelectNode(Node, VFS_SELECT_READ, NULL, "VT_Read (UCS-4)");
-
- avail = term->InputWrite - term->InputRead;
- if(avail < 0)
- avail += MAX_INPUT_CHARS32;
- Length /= 4;
- if(avail > Length - pos)
- avail = Length - pos;
-
- codepoint_in = (void*)term->InputBuffer;
- codepoint_buf = Buffer;
-
- while( avail -- )
- {
- codepoint_buf[pos] = codepoint_in[term->InputRead];
- pos ++;
- term->InputRead ++;
- while(term->InputRead >= MAX_INPUT_CHARS32)
- term->InputRead -= MAX_INPUT_CHARS32;
- }
- pos *= 4;
- break;
- }
-
- // Mark none avaliable if buffer empty
- if( term->InputRead == term->InputWrite )
- VFS_MarkAvaliable(&term->Node, 0);
-
- term->ReadingThread = -1;