============ Cbuf_InsertText Adds command text immediately after the current command Adds a \n to the text ============ */
| 113 | ============ |
| 114 | */ |
| 115 | void Cbuf_InsertText( const char *text ) { |
| 116 | int len; |
| 117 | int i; |
| 118 | |
| 119 | len = strlen( text ) + 1; |
| 120 | if ( len + cmd_text.cursize > cmd_text.maxsize ) { |
| 121 | Com_Printf( "Cbuf_InsertText overflowed\n" ); |
| 122 | return; |
| 123 | } |
| 124 | |
| 125 | // move the existing command text |
| 126 | for ( i = cmd_text.cursize - 1 ; i >= 0 ; i-- ) { |
| 127 | cmd_text.data[ i + len ] = cmd_text.data[ i ]; |
| 128 | } |
| 129 | |
| 130 | // copy the new text in |
| 131 | Com_Memcpy( cmd_text.data, text, len - 1 ); |
| 132 | |
| 133 | // add a \n |
| 134 | cmd_text.data[ len - 1 ] = '\n'; |
| 135 | |
| 136 | cmd_text.cursize += len; |
| 137 | } |
| 138 | |
| 139 | |
| 140 | /* |
no test coverage detected