| 1260 | } |
| 1261 | |
| 1262 | void CodeTextEditor::convert_case(CaseStyle p_case) { |
| 1263 | if (!text_editor->has_selection()) { |
| 1264 | return; |
| 1265 | } |
| 1266 | text_editor->begin_complex_operation(); |
| 1267 | text_editor->begin_multicaret_edit(); |
| 1268 | |
| 1269 | for (int c = 0; c < text_editor->get_caret_count(); c++) { |
| 1270 | if (text_editor->multicaret_edit_ignore_caret(c)) { |
| 1271 | continue; |
| 1272 | } |
| 1273 | if (!text_editor->has_selection(c)) { |
| 1274 | continue; |
| 1275 | } |
| 1276 | |
| 1277 | int begin = text_editor->get_selection_from_line(c); |
| 1278 | int end = text_editor->get_selection_to_line(c); |
| 1279 | int begin_col = text_editor->get_selection_from_column(c); |
| 1280 | int end_col = text_editor->get_selection_to_column(c); |
| 1281 | |
| 1282 | for (int i = begin; i <= end; i++) { |
| 1283 | int len = text_editor->get_line(i).length(); |
| 1284 | if (i == end) { |
| 1285 | len = end_col; |
| 1286 | } |
| 1287 | if (i == begin) { |
| 1288 | len -= begin_col; |
| 1289 | } |
| 1290 | String new_line = text_editor->get_line(i).substr(i == begin ? begin_col : 0, len); |
| 1291 | |
| 1292 | switch (p_case) { |
| 1293 | case UPPER: { |
| 1294 | new_line = new_line.to_upper(); |
| 1295 | } break; |
| 1296 | case LOWER: { |
| 1297 | new_line = new_line.to_lower(); |
| 1298 | } break; |
| 1299 | case CAPITALIZE: { |
| 1300 | new_line = new_line.capitalize(); |
| 1301 | } break; |
| 1302 | } |
| 1303 | |
| 1304 | if (i == begin) { |
| 1305 | new_line = text_editor->get_line(i).left(begin_col) + new_line; |
| 1306 | } |
| 1307 | if (i == end) { |
| 1308 | new_line = new_line + text_editor->get_line(i).substr(end_col); |
| 1309 | } |
| 1310 | text_editor->set_line(i, new_line); |
| 1311 | } |
| 1312 | } |
| 1313 | text_editor->end_multicaret_edit(); |
| 1314 | text_editor->end_complex_operation(); |
| 1315 | } |
| 1316 | |
| 1317 | void CodeTextEditor::set_indent_using_spaces(bool p_use_spaces) { |
| 1318 | text_editor->set_indent_using_spaces(p_use_spaces); |
no test coverage detected