title: compile logisim
Use logisim In the process of discovery , Modify the device's Label The text in the edit box becomes too small , Can't see at all . After downloading the source code and doing some research , Found the edit box EmptyBorder Set yes (10,10,10,10), Take up too much space , There is too little space left for words , So the displayed text can't be seen at all , You need to set the blank border to (1,1,1,1), So you need to recompile the source code .
One 、jdk-1.5.0
logisim Software is based on jdk-1.5.0 Developed , Therefore, you need to use this version jdk Compile .
1. download
Download link jdk-1.5.0
Select Download File jdk1.5.0_22.bin download , Then change it to an executable :
chmod a+x jdk1.5.0_22.bin
Run it , You will get a directory jdk1.5.0_22, Copy the directory to /usr/lib/jvm
sudo cp jdk1.5.0_22/ /usr/lib/jvm/
2. Change of name
Create a and apt Install packages with similar names
cd /usr/lib/jvm
sudo ln -s java-1.5.0-oracle-amd64 jdk1.5.0_22
3. Create alternatives
sudo update-alternative --install /usr/bin/java java /usr/lib/jvm/java-1.5.0-oracle-amd64/bin/java --slave /usr/share/man/man1/java.1.gz java.1.gz /usr/lib/jvm/java-1.5.0-oracle-amd64/man/man1/java.1
sudo update-alternative --install /usr/bin/javac javac /usr/lib/jvm/java-1.5.0-oracle-amd64/bin/javac --slave /usr/share/man/man1/javac.1.gz javac.1.gz /usr/lib/jvm/java-1.5.0-oracle-amd64/man/man1/javac.1
sudo update-alternative --install /usr/bin/jar jar /usr/lib/jvm/java-1.5.0-oracle-amd64/bin/jar --slave /usr/share/man/man1/jar.1.gz jar.1.gz /usr/lib/jvm/java-1.5.0-oracle-amd64/man/man1/jar.1
4. Configuration substitution
Use the following command to jdk Configure to jdk-1.5.0 edition .
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config jar
Two 、logisim
1. Download source code
Download link :logisim
2. decompression
unzip circuit-code-r256-trunk.zip
Will get the same name circuit-code-r256-trunk Catalog .
3. Create build directory
Create in the extracted directory build Catalog .
mkdir circuit-code-r256-trunk/build
4. Modify the source program
(1)bash Script
# src_patch.sh, And circuit-code-r256-trunk At the same level
#python Script "i is 1" It's a grammatical error , It must be changed to "i == 1"
sed -i -e "s/i is 1/i == 1/g" scripts/create-jar.py
grep "i == 1" scripts/create-jar.py
# Put... In the input box EmptyBorder from 10 Change to 1, You can make room for text display
find . -name "*.java" -exec sed -i -e "s/10, 10, 10, 10/1, 1, 1, 1/g" {} \;
find . -name "*.java" -exec grep "EmptyBorder" {} \;
# This document has UTF8 Of BOM head , You need to remove , The way is to put the 1 The first two characters of the line "/*" Replace with "\n/*",
# That is, add a newline character at the beginning , Then delete the second 1 That's ok .
sed -i -e "1s/\/\*/\n\/\*/g" ./src/com/cburch/draw/shapes/CurveUtil.java
sed -i 1d ./src/com/cburch/draw/shapes/CurveUtil.java
hexdump -C ./src/com/cburch/draw/shapes/CurveUtil.java | head -n 3
(2) Execute the script
$ cd build
$ bash ../src_patch.sh
5. compile
cd build
python3 ../scripts/create-jar.py
stay build The directory gets a compiled jar, The temporary file has been deleted .
6. test
- stay jdk1.5.0 In the environment
- Newly compiled logisim When the edit box gets the input focus, the display of English string is normal , No longer too small to see clearly .
- But the Chinese string cannot be displayed , Each Chinese character is only given a virtual frame .
- take locale Switch to en_US.UTF-8 Environmental Science , Then compile to generate a version , And then run , Found the same thing , Also, Chinese characters cannot be displayed ; take locale Switch to zh_CN.UTF-8 Environmental Science , Same situation .
- apt Installed logisim You can see Chinese characters , But the text display is abnormal when the edit box gets the input focus , The words are too small , Can't see at all .
- Switch to openJDK Of default-jdk Environmental Science
- Both newly compiled applications can display Chinese characters , But when the edit box gets the input focus, the string display is abnormal , Too small to see clearly .
- apt Installed logisim Yes .
3、 ... and 、 Replace jdk
People feel different JDK, The display effect is different . To oracle The website has downloaded jdk-18_linux-x64_bin.deb, Install it :
dpkg -i jkd-18_linux-x64_bin.deb
Command update-alternate --config java
I found that I didn't join alternate In the system . Check the installation package list , Installed in the /usr/lib/jvm/jdk_18 It's in , Build for this version alternate archives , And switch to this version .
- function apt Installed logisim Software , The edit box is still too small to see clearly when editing text
- Run your own compiled logisim_en( stay en_US.UTF-8 locale Compile below ), The edit box displays normally when editing text
- function logisim_zh( stay zh_CN.UTF-8 locale Compile below ), The edit box displays normally when editing text .
Conclusion
- In the use of the oracle-jdk after , Changing the width of the blank border of the edit box is successful , Effective .
- explain default-jdk And oracle-jdk There are still differences in details .
Four 、 Other versions of logisim
Visited debian Of package Website , It is suggested to delete logisim It's packed , Because the original author is already 2014 In, it announced to stop maintaining the software , It is recommended to use other fork package . stay giuhub I've really found a lot of such xxxlogisim or logisimxxx, Many are short-lived , It has not been updated for many years . One of them logisim-evolution, It is still being updated , Download and use it , Found that a lot of 74 Series of devices . The appearance of the device also changes , More beautiful , But some packages occupy a large space , Fortunately, you can choose the traditional appearance in the drop-down menu , It's compact . It still works , There is no problem that the text is too small to see clearly after the attribute edit box gets the focus . Download the source code , stay src Search the directory "10, 10, 10, 10", I found several more , But there must be no problem with string input , Original version of bug So many years of iteration , It should have been solved long ago .