================ rvDebuggerWindow::OpenScript Opens the script with the given filename and will scroll to the given line number if one is specified ================ */
| 2088 | ================ |
| 2089 | */ |
| 2090 | bool rvDebuggerWindow::OpenScript ( const char* filename, int lineNumber, idProgram* program ) |
| 2091 | { |
| 2092 | int i; |
| 2093 | |
| 2094 | SetCursor ( LoadCursor ( NULL, IDC_WAIT ) ); |
| 2095 | |
| 2096 | mActiveScript = -1; |
| 2097 | |
| 2098 | // See if the script is already loaded |
| 2099 | for ( i = 0; i < mScripts.Num(); i ++ ) |
| 2100 | { |
| 2101 | if ( !idStr::Icmp ( mScripts[i]->GetFilename ( ), filename ) ) |
| 2102 | { |
| 2103 | if ( mActiveScript != i ) |
| 2104 | { |
| 2105 | mActiveScript = i; |
| 2106 | break; |
| 2107 | } |
| 2108 | } |
| 2109 | } |
| 2110 | |
| 2111 | // If the script isnt open already then open it |
| 2112 | if ( mActiveScript == -1 ) |
| 2113 | { |
| 2114 | rvDebuggerScript* script = new rvDebuggerScript; |
| 2115 | |
| 2116 | // Load the script |
| 2117 | if ( !script->Load ( filename ) ) |
| 2118 | { |
| 2119 | SetCursor ( LoadCursor ( NULL, IDC_ARROW ) ); |
| 2120 | return false; |
| 2121 | } |
| 2122 | |
| 2123 | gDebuggerApp.GetOptions().AddRecentFile ( filename ); |
| 2124 | UpdateRecentFiles ( ); |
| 2125 | |
| 2126 | mActiveScript = mScripts.Append ( script ); |
| 2127 | } |
| 2128 | |
| 2129 | // Test code that will place a breakpoint on all valid lines of code |
| 2130 | #if 0 |
| 2131 | |
| 2132 | for ( i = 0; i < mScripts[mActiveScript]->GetProgram().NumStatements(); i ++ ) |
| 2133 | { |
| 2134 | dstatement_t* st = &mScripts[mActiveScript]->GetProgram().GetStatement ( i ); |
| 2135 | rvDebuggerBreakpoint* bp = new rvDebuggerBreakpoint ( filename, st->linenumber ); |
| 2136 | mBreakpoints.Append ( bp ); |
| 2137 | } |
| 2138 | |
| 2139 | #endif |
| 2140 | |
| 2141 | UpdateScript ( ); |
| 2142 | UpdateWindowMenu ( ); |
| 2143 | |
| 2144 | // Move to a specific line number? |
| 2145 | if ( lineNumber != -1 ) |
| 2146 | { |
| 2147 | long c; |
no test coverage detected