I started writing the logic but then realized that there's a bit of a catch. See if you are allowed to write anything outside of the normal parameters, like those comments you wrote for us. Will the program still work with it's normal hotkeys? If so, it'd be best to write a comment before each line with a more recognizable function-name. Otherwise, you'd best create a string matrix (or, for simplicity's sake, two arrays/vectors) with the "real" names and the simplified ones (i.e.
ACTION="SYSTEM::MERGE
== "Pan"). Remember to ignore anything with a number value, since they might change.
Whichever the case, it could be quite simple
1 2 3 4 5 6 7 8 9 10
|
Open the file
Ask user for function to be changed
Ask user for new hotkey
Scan file searching for the function's real name (or, if you can 'comment' the file, the simple name.
This also simplifies the code in the next few steps)
-If you can tamper with the file, simply edit the value of KEY= with an fseek(fp,NUM_CHAR_TO_KEY,SEEK_CUR)
-If you can't, you'll need to save the number of chars up to (and including) the real name, because you'll
need to use an fseek(fp,-CHARS_MOVED,SEEK_CUR) to step back to the KEY=section.
-Whichever the case, should the new hotkey involve modifiers, you'll need to modify the KEY= section
only with the key and then modify the MODIFIER= section with the rest.
|
You'll also probably want to run through the file and check that there is no command already using that hotkey so as not to create conflicts.
Wait. Oh bummer. You'll have a huge problem altering the modifiers, though. Well, adding modifiers, anyways. You'll start eating up anything after the previously-allocated area. And, in removing them, you'd need to make sure there's no trash after what you cleared. And, worst still, should you wish there be no modifier, you'd need to delete the MODIFIER= segment entirely, including the 'title.'
Huh, this'd actually be a bit more of a hassle than I thought when I started writing this...