decomp.me icon indicating copy to clipboard operation
decomp.me copied to clipboard

Copy pasting asm out of the diff window is messy

Open Rainchus opened this issue 2 years ago • 5 comments

As is, if you want to copy the asm out of the diff window it copies both, which results in this https://cdn.discordapp.com/attachments/897066363951128590/1128170199313559573/image.png Since the original asm can be gotten by exporting a scratch, a way to only copy paste the asm from your C code or a way to output the new asm using export would be nice.

Rainchus avatar Jul 14 '23 00:07 Rainchus

image cause discord snux

ethteck avatar Mar 10 '24 13:03 ethteck

Splitting the divs for target and current should fix it. They are currently both in one <ul> element and the separation is on the line level.

dbalatoni13 avatar Jun 03 '24 23:06 dbalatoni13

If it wasn't infinite scrolling, something like this gets close (nth-child would change depending on the column you want):

navigator.clipboard.writeText([].slice.call(document.querySelectorAll('li[class^=Diff_row] div:nth-child(2)') || []).map(div => div.innerText.replace(/^\s*/, '')).join('\r\n'));

jtl3d avatar Aug 22 '24 18:08 jtl3d

import json

with open('data.json', 'r') as file:
    parsed_data = json.load(file)

target_lines = []
current_lines = []

for row in parsed_data.get('diff_output', {}).get('rows', []):
    base_text = ""
    current_text = ""

    if 'base' in row:
        base_text = ' '.join([t.get('text', '') for t in row['base'].get('text', [])])

    if 'current' in row:
        current_text = ' '.join([t.get('text', '') for t in row['current'].get('text', [])])
    target_lines.append(base_text)
    current_lines.append(current_text)

with open('target.txt', 'w') as target_file:
    target_file.write('\n'.join(target_lines))

with open('current.txt', 'w') as current_file:
    current_file.write('\n'.join(current_lines))

print("saved to 'target.txt' and 'current.txt'")

I temporary solved by coping the json response of the compile endpoint and parsing it with this script. Not perfect but for me is enough.

teopiaz avatar Aug 22 '24 21:08 teopiaz

Working on #1357

PerikiyoXD avatar Oct 05 '24 18:10 PerikiyoXD

Done in #1357

ethteck avatar Mar 26 '25 01:03 ethteck