Created
January 28, 2020 18:00
-
-
Save PeterMinin/14fef2de0f7ca2829e2314de0d59219a to your computer and use it in GitHub Desktop.
A kludge for a bug in old Eclipse versions where the Parameter Hints popup keeps getting smaller and closes if you try to resize it: https://bugs.eclipse.org/bugs/show_bug.cgi?id=466114
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import os | |
import re | |
workspace_path = os.environ['HOME'] + '/nsight-workspace' | |
plugin_name = 'org.eclipse.cdt.ui' | |
target_width = 800 | |
target_height = 500 | |
dialog_settings_path = (workspace_path + '/.metadata/.plugins/' + plugin_name + | |
'/dialog_settings.xml') | |
backup_path = dialog_settings_path + '.bak' | |
os.replace(dialog_settings_path, backup_path) | |
regex = re.compile( | |
r'^\s*<item value="(\d+)" key="contextSelector\.size\.([xy])"\/>\s*$') | |
x_found = False | |
y_found = False | |
try: | |
with open(backup_path) as in_file, \ | |
open(dialog_settings_path, 'w') as out_file: | |
for line in in_file: | |
m = regex.match(line) | |
if m: | |
if m.group(2) == 'x': | |
if x_found: | |
raise ValueError('Multiple x values found') | |
x_found = True | |
new_val = target_width | |
else: | |
if y_found: | |
raise ValueError('Multiple y values found') | |
y_found = True | |
new_val = target_height | |
line = line.replace(m.group(1), str(new_val)) | |
print('{} value: {} -> {}'.format( | |
m.group(2), m.group(1), new_val)) | |
out_file.write(line) | |
except: | |
print('Restoring the original file') | |
os.replace(backup_path, dialog_settings_path) | |
raise | |
if x_found and y_found: | |
print('Done') | |
else: | |
if x_found or y_found: | |
print('Didn\'t find the other value') | |
else: | |
print('Didn\'t find the lines with "contextSelector.size"') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment