Bug Location input keeps overwriting clipboard

Voker57

New member
I'm running latest build on linux and when autoadventuring, location name appears to be getting 'copypasted' into location input over and over, overwriting clipboard contents, even if kolmafia windows is not active. That's very annoying.
 

fronobulax

Developer
Staff member
I'm not sure I understand what you are saying or how to reproduce it. I can tell you that using the word "annoying" has side effects that you might not want. But until you tell me how to reproduce it and I (or someone else interested) can either reproduce it or isolate it to being Linux specific I doubt anything is going to be done.
 

slyz

Developer
If I understand correctly, he has Mafia in the background automating turns in a location, and whenever he pastes text it turns out to be the location's name instead of whatever he was expecting.
 
Last edited:

Voker57

New member
Slyz is right; And yes, it's probably linux specific, since only it has separate 'selection' buffer.
 

fronobulax

Developer
Staff member
Slyz is right; And yes, it's probably linux specific, since only it has separate 'selection' buffer.

But I'm still not 100% certain what I should do to reproduce it and understanding that is a prerequisite to making the effort to set up a Linux VM and see if it can be addressed. Alternatively we could just mark this as Not Going To Fix.
 

Catch-22

Active member
If any selected JList item is being copied into your clipboad then it sounds like something potentially strange is configured in your X server or possibly with your JVM. Make sure they're up to date.

Does it happen with other frames? eg. open the inventory frame, click " - Fine Tuning" and paste. Does it paste the value of the list item?
 

nworbetan

Member
I can reproduce this, or something pretty similar at least, in 3 easy steps:
1. start mafia
2. log in
3. middle clicking now pastes this:
All deeds are specified by one comma-delimited preference "dailyDeedsOptions". Order matters. Built-in deeds are simply called by referring to their built-in name; these are viewable by pulling up the Daily Deeds tab and looking in the "Built-in Deeds" list.
Custom Deeds
Custom deeds provide the user with a way of adding buttons or text to their daily deeds panel that is not natively provided for. All deeds start with the keyword $CUSTOM followed by a pipe (|) symbol. As you are constructing a custom deed, you separate the different arguments with pipes. All deed types except for Text require a preference to track. If you want to add a button that is always enabled, you will have to create a dummy preference that is always false. There are currently 5 different types of custom deeds. Remember that all of these "acceptable forms" are prefaced by $CUSTOM|. Command - execute a command with a button press acceptable forms: Command|displayText|preference Command|displayText|preference|command Command|displayText|preference|command|maxUses displayText - the text that will be displayed on the button preference - the preference to track. The button will be enabled when the preference is less than maxUses (default 1). command - the command to execute. If not specified, will default to displayText. maxUses - an arbitrary integer. Specifies a threshold to disable the button at. A counter in the form of <preference>/<maxUses> will be displayed to the right of the button. Item - this button will use fuzzy matching to find the name of the item specified. Will execute "use <itemName>" when clicked. Will only be visible when you possess one or more of the item. acceptable forms: Item|displayText|preference Item|displayText|preference|itemName Item|displayText|preference|itemName|maxUses itemName - the name of the item that will be used. If not specified, will default to displayText. Skill - cast a skill that is tracked by a boolean or int preference. Will execute "cast <skillName>" when clicked. Will not be visible if you don't know the skill. acceptable forms: Skill|displayText|preference Skill|displayText|preference|skillName Skill|displayText|preference|skillName|maxCasts skillName- the name of the skill that will be cast. If not specified, will default to displayText. Must be specified if maxCasts are specified. maxCasts - an arbitrary integer. Specifies a threshold to disable the button at. A counter in the form of <preference>/<maxCasts> will be displayed to the right of the button. Text acceptable forms: Text|pretty much anything. You can supply as many arguments as you want to a Text deed. Any argument that uniquely matches a preference will be replaced by that preference's value. If you want to use a comma in your text, immediately follow the comma with a pipe character so it will not be parsed as the end of the Text deed.

Pasting the currently selected text with a middle click is pretty normal behavior in Linux. I've used that functionality in a Linux system that didn't even have an X server, and I'm sure there are extra-fancy clipboard programs that change that behavior in more or less subtle ways too. But the one thing I'm really not sure about is why this wall of text is "selected" when I log in with mafia.
 
Last edited:

roippi

Developer
That's just a random instance of JTextComponent.setText, presumably the last such that occurs during initialization. The little combobox that the OP is referring to is another JTextComponent.

I don't know what the Best Practice is here. Calling setText apparently causes this behavior even when the component is not enabled ('grayed out' for the laymen). Maybe there's a system property we can set on startup or something.
 

Catch-22

Active member
The JTextComponents being referred to here are enabled, or else you wouldn't be able to interact with them. What you might be thinking of is that they are not editable. They are certainly handled differently, a component that is not enabled won't fire certain events.

The problem is related to the implementation of the DefaultCaret class that is assigned to each JTextComponent. There's a few ways we could handle it.

1. Create our own implementation of Caret that behaves how one would expect it to behave in Linux. This solution is probably way out of scope for KoLmafia.
2. Perform document changes that we don't want caret events to fire for on something other than the Event Dispatching Thread.
3. Set the NEVER_UPDATE property of the DefaultCaret for JTextComponents where we don't want the caret to move the dot around the document (thus causing unwanted events to fire). This is probably the easiest solution, but it may not be the best solution for every JTextComponent.

Interestingly, option 3 is what probably should've been done for the example nworbetan posted as someone has already implemented a hack to move the dot back to the start of the document for that component:

PHP:
textPane.setSelectionStart( 0 );
textPane.setSelectionEnd( 0 ); // don't have scrollPane scrolled to the bottom when you open it

If you tell the DefaultCaret to NEVER_UPDATE, you wouldn't need this hack.

Sorry, I don't have time to tinker at the moment. Hope the information is useful.
 

roippi

Developer
The JTextComponents being referred to here are enabled, or else you wouldn't be able to interact with them. What you might be thinking of is that they are not editable. They are certainly handled differently, a component that is not enabled won't fire certain events.

Well, I wasn't thinking of either. I thought that the location component was not enabled when mafia was in a pending state, but looks like it's always enabled.

You're right on the rest; I was unfamiliar with DefaultCaret but that is the proper way to implement a JTextComponent with that behavior. In that instance. I don't know if NEVER_UPDATE is the right behavior for the location combobox, I haven't looked at it.
 
Last edited:

Voker57

New member
Steps to reproduce (on linux):

1. Switch to Graphical GUI frame
2. Issue command to adventure somewhere
3. Go to terminal emulator and paste clipboard contents (Shift-Ins) or middle click in any text field.

Pasted text will be part of adventure location (like "Friars") despite the frame with this text field was not active.

Does it happen with other frames? eg. open the inventory frame, click " - Fine Tuning" and paste. Does it paste the value of the list item?

Yes.
 
Top