├── LICENSE ├── README.org ├── chdir.lisp ├── clfm-2.asd ├── clfm-2.lisp ├── clfm-demo-picture.png ├── command-utilities.lisp ├── commands-update.lisp ├── commands.lisp ├── copy.lisp ├── create-directory.lisp ├── create-file.lisp ├── delete.lisp ├── demo.mp4 ├── dialog.lisp ├── fonts ├── ETBembo-RomanOSF-fake-sans-serif.ttf ├── et-book-bold-line-figures.ttf ├── et-book-display-italic-bold-old-style-figures.ttf ├── et-book-display-italic-old-style-figures.ttf ├── et-book-roman-line-figures.ttf ├── et-book-roman-old-style-figures.ttf ├── et-book-semi-bold-old-style-figures.ttf ├── et-book-super-bold-roman-old-style-figures.ttf └── license.txt ├── help.lisp ├── init.lisp ├── keybindings.lisp ├── make-executable.sh ├── mark-and-operate.lisp ├── move-file-directory.lisp ├── open-files.lisp ├── package.lisp ├── password.lisp ├── rename-file-directory.lisp └── testing.org /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | #+TITLE: the Common Lisp File Manager 2 | * Demo 3 | [[./clfm-demo-picture.png]] 4 | see demo.mp4 for a video 5 | 6 | * Running 7 | There are two options for running this application, make an executable or open it from a running lisp image. There is a script included called =make-executable.sh=, which creates a standalone executable that you can copy wherever youd like. To make an executable one requires SBCL and Quicklisp installed, and the script will check for this and exit if they aren't found. If you wish to install CLFM, I recommend creating a symbolic link to a location in your path - I use =~/.bin=. This allows you to rebuild the binary at any time without having to copy it. 8 | * A File Manager Written in Common Lisp 9 | This is a very regular file manager. It is mainly mouse driven, but the plan is to make it more keyboard oriented. 10 | 11 | ** Init file 12 | CLFM reads from an init file at =~/.clfm.d/init.lisp=. 13 | ** Opening files and entering directories 14 | clicking on an item will either open it via =xdg-open=, or if its a directory it is entered. 15 | *** Clicking 16 | Clicking on a file or directory invokes the primary operation. This can be set with the functions ~set-file-command-order~ and ~set-directory-command-order~. Right clicking opens a menu of all possible operations. 17 | ** Marks and Operations 18 | CLFM lets you mark any file or directory and run batch operations on them. By default marking an item is not the primary operation. It can be made such with the functions ~file-prefer-marks~ and ~directory-prefer-marks~. 19 | Once items are marked one can open the =Operate/Marks= menu and select =Select Operation=. You will be prompted for an operation to on all marks. 20 | *** Operations 21 | Operations are defined by the macro ~define-operation~. It works just like defining a function, but they arent callable like a general function. Each operation takes two arguments - the item to operate upon, and a finished argument. When running an operation on the marks, it is funcalled on every mark with finished as nil. After all marks are finished, it is called with the item as nil and finished as t. 22 | * Quirks 23 | - In order to leverage the feature of opening another pane as root, CLFM must be in the =$PATH=. 24 | -------------------------------------------------------------------------------- /chdir.lisp: -------------------------------------------------------------------------------- 1 | 2 | (in-package :clfm-2) 3 | 4 | (defparameter *passwd-test* nil) 5 | 6 | (define-clfm-command (com-change-directory) ((directory string)) 7 | (handler-case 8 | (when (uiop:directory-exists-p directory) 9 | (uiop:chdir directory)) 10 | (sb-posix:syscall-error (err) 11 | (case 12 | (notify-user *application-frame* 13 | (let ((errno (sb-posix:syscall-errno err))) 14 | (cond ((= errno 13) 15 | "You don't have permission to access this directory 16 | 17 | To access this directory CLFM needs to be running as root 18 | 19 | To relaunch CLFM please ensure it is in your $PATH") 20 | (t 21 | (format nil "SB-POSIX Error Code: ~a" errno)))) 22 | :title "CLFM Error" 23 | :name "CLFM Error" 24 | :documentation "CLFM Error" 25 | :text-style (make-text-style "ETBembo" "BoldLF" 18) 26 | :exit-boxes '((t "OK") 27 | (:sudo "Relaunch as root"))) 28 | ((:sudo) 29 | (and (notify-user *application-frame* 30 | "WARNING: CLFM will now be running with root privilidges. 31 | This is not safe, and should be avoided. 32 | 33 | If you continue, type your password when presented with the blank window and use 34 | M-RET (meta + return or Alt + return) to submit it" 35 | :exit-boxes '((t "CONTINUE") (nil "ABORT")) 36 | :text-style (make-text-style "ETBembo" "BoldLF" 18)) 37 | (let (passwd 38 | (stream (frame-standard-input *application-frame*))) 39 | (accepting-values (stream 40 | :own-window t 41 | :initially-select-query-identifier 'password) 42 | (formatting-table (stream) 43 | (formatting-column (stream) 44 | (formatting-cell (stream) 45 | (setf passwd (accept 'password 46 | ;; 'string 47 | :prompt "sudo password" 48 | :stream stream 49 | :query-identifier 'password)))))) 50 | (uiop:launch-program 51 | (format nil "echo \"~a\" | sudo -S clfm" passwd))))))))) 52 | 53 | (define-clfm-command (com-chdir-~/ :name "Go Home") () 54 | (com-change-directory-temper "~/")) 55 | 56 | 57 | -------------------------------------------------------------------------------- /clfm-2.asd: -------------------------------------------------------------------------------- 1 | ;;;; clfm-2.asd 2 | 3 | (asdf:defsystem #:clfm-2 4 | :description "Describe clfm-2 here" 5 | :author "Your Name " 6 | :license "Specify license here" 7 | :version "0.0.1" 8 | :serial t 9 | :depends-on (#:osicat 10 | #:alexandria 11 | #:mcclim 12 | #:slim) 13 | :components ((:file "package") 14 | (:file "clfm-2") 15 | (:file "dialog") 16 | (:file "help") 17 | (:file "password") 18 | (:file "command-utilities") 19 | (:file "open-files") 20 | (:file "chdir") 21 | (:file "delete") 22 | (:file "create-file") 23 | (:file "create-directory") 24 | (:file "rename-file-directory") 25 | (:file "copy") 26 | (:file "move-file-directory") 27 | (:file "mark-and-operate") 28 | (:file "commands") 29 | (:file "commands-update") 30 | (:file "keybindings"))) 31 | -------------------------------------------------------------------------------- /clfm-2.lisp: -------------------------------------------------------------------------------- 1 | ;;;; clfm-2.lisp 2 | 3 | (in-package #:clfm-2) 4 | 5 | (defparameter *hide-files* t) 6 | 7 | (defmacro nlet (name vars &body body) 8 | (let ((gensym-list (loop for x in vars collect (gensym))) 9 | (name-gensym (gensym "Name")) 10 | (block-gensym (gensym "Block"))) 11 | `(macrolet 12 | ((,name ,gensym-list 13 | `(progn 14 | (psetq 15 | ,@(loop for r in ',vars 16 | for l in (list ,@gensym-list) 17 | collect (car r) 18 | collect l)) 19 | (go ,',name-gensym)))) 20 | (block ,block-gensym 21 | (let ,vars 22 | (tagbody 23 | ,name-gensym 24 | (return-from ,block-gensym (progn ,@body)))))))) 25 | 26 | ;; (defmacro monospaced ((stream &optional (type :roman) (size 16)) &body body) 27 | ;; `(with-text-style (,stream (make-text-style :fix ,type ,size)) 28 | ;; ,@body)) 29 | 30 | (defmacro with-etbembo ((stream &optional (type :roman) (size 16)) &body body) 31 | ;; `(with-text-style (,stream (make-text-style :serif ,type ,size)) 32 | ;; ,@body) 33 | `(with-text-style (,stream (make-text-style "ETBembo" 34 | ,(cond ((eq type :bold) 35 | "BoldLF") 36 | ((eq type :semi-bold) 37 | "SemiBoldOSF") 38 | ((eq type :italic) 39 | "DisplayItalic") 40 | ((eq type :italic-bold) 41 | "DisplayItalicBold") 42 | ((eq type :super-bold) 43 | "SuperBoldOSF") 44 | (t "RomanLF")) 45 | ,size)) 46 | ,@body)) 47 | 48 | (defun make-executable () 49 | (sb-ext:save-lisp-and-die "clfm" 50 | :toplevel (lambda () 51 | (app-main)) 52 | :executable t 53 | :purify t)) 54 | 55 | (defun file-extension (file) 56 | (reverse (car (cl-ppcre:split "\\." (reverse (namestring file)))))) 57 | 58 | (defun initialize-fonts () 59 | (let ((port (find-port))) 60 | (loop for f in (uiop:directory-files (asdf:system-relative-pathname 61 | "clfm-2" "fonts/" :type :directory)) 62 | when (string= "ttf" (file-extension f)) 63 | do ;; (format t "Font: ~a" f) 64 | (loop for size in '(8 10 12 14 16 18 24 48 72) 65 | do (mcclim-truetype::make-truetype-font port f size)))) 66 | ) 67 | 68 | (defun gather-users-uid-gid () 69 | (let ((uid-lists '()) 70 | (gid-lists '()) 71 | (un (uiop:process-info-output (uiop:launch-program "awk -F: '{print $1}' /etc/passwd" :output :stream))) 72 | (ui (uiop:process-info-output (uiop:launch-program "awk -F: '{print $3}' /etc/passwd" :output :stream))) 73 | (gi (uiop:process-info-output (uiop:launch-program "awk -F: '{print $4}' /etc/passwd" :output :stream)))) 74 | (do ((n (read-line un nil) 75 | (read-line un nil)) 76 | (u (read-line ui nil) 77 | (read-line ui nil)) 78 | (g (read-line gi nil) 79 | (read-line gi nil))) 80 | ((or (null n) (null u) (null g))) 81 | (setf uid-lists (append uid-lists (list (cons u n)))) 82 | (setf gid-lists (append gid-lists (list (cons g n))))) 83 | (values uid-lists gid-lists))) 84 | 85 | (multiple-value-bind (uidl gidl) 86 | (gather-users-uid-gid) 87 | (defparameter *uid-username* uidl) 88 | (defparameter *gid-username* gidl)) 89 | 90 | ;;; The variable +clfm-permissions+ and the function permissions-as-string are a 91 | ;;; modified version of the varables and functions in osicat. these modified 92 | ;;; versions return a string instead of a list of keywords to show permissions 93 | 94 | (defvar +clfm-permissions+ '(("r" . #.nix:s-irusr) 95 | ("w" . #.nix:s-iwusr) 96 | ("x" . #.nix:s-ixusr) 97 | ("r" . #.nix:s-irgrp) 98 | ("w" . #.nix:s-iwgrp) 99 | ("x" . #.nix:s-ixgrp) 100 | ("r" . #.nix:s-iroth) 101 | ("w" . #.nix:s-iwoth) 102 | ("x" . #.nix:s-ixoth)) 103 | "for use in permissions-as-string, used to show permissions like ls -l") 104 | 105 | (defun permissions-as-list (pathname) 106 | (let ((mode (nix:stat-mode (nix:stat pathname)))) 107 | (loop for (name . value) in +clfm-permissions+ 108 | if (plusp (logand mode value)) 109 | collect name 110 | else collect "-"))) 111 | 112 | (defun permissions-as-string (pathname) 113 | (apply 'concatenate 'string (permissions-as-list pathname))) 114 | 115 | (defun hidden-pathname-p (path) 116 | (let ((pathname (namestring path))) 117 | (uiop:hidden-pathname-p 118 | (if (string= "/" (subseq pathname (- (length pathname) 1) (length pathname))) 119 | (subseq pathname 0 (- (length pathname) 1)) 120 | pathname)))) 121 | 122 | (defun list-directory (directory) 123 | (let ((contents (osicat:list-directory directory))) 124 | (loop for path in contents 125 | unless (hidden-pathname-p path) 126 | collect (let ((stat (osicat-posix:stat path))) 127 | (list path 128 | (cdr (assoc 129 | (format nil "~a" (osicat-posix:stat-uid stat)) 130 | *uid-username* :test #'string-equal)) 131 | (cdr (assoc 132 | (format nil "~a" (osicat-posix:stat-gid stat)) 133 | *gid-username* :test #'string-equal)) 134 | (permissions-as-string path)))))) 135 | 136 | (define-application-frame clfm () () 137 | (:menu-bar clfm-menu-bar) 138 | (:top-level (clim:default-frame-top-level :prompt #'commander-prompt)) 139 | (:panes 140 | (info :application 141 | :display-function #'display-info 142 | :width 600) 143 | (marks :application 144 | :display-function #'display-marks 145 | :width 600) 146 | (current-directory :application 147 | :display-function #'display-current-directory 148 | :scroll-bars t 149 | :incremental-redisplay t) 150 | (interactor :interactor)) 151 | (:layouts 152 | (default 153 | (vertically () 154 | (20 marks) 155 | (20 info) 156 | (horizontally () 157 | (:fill current-directory)) 158 | ;; (make-pane 'clim-extensions:box-adjuster-gadget) 159 | ;; (100 interactor) 160 | )) 161 | (no-marks 162 | (vertically () 163 | (20 info) 164 | (horizontally () 165 | (:fill current-directory)) 166 | (make-pane 'clim-extensions:box-adjuster-gadget) 167 | (100 interactor))))) 168 | 169 | (defun commander-prompt (pane frame) 170 | (declare (ignore frame)) 171 | (format pane "COMMAND: ") 172 | (stream-increment-cursor-position pane 5 0)) 173 | 174 | (defun app-main () 175 | (initialize-fonts) 176 | (handler-case (load "~/.clfm.d/init.lisp") 177 | (t () ())) 178 | (run-frame-top-level (make-application-frame 'clfm))) 179 | 180 | (defun path> (one two) 181 | (string> (namestring one) (namestring two))) 182 | 183 | (defun path< (one two) 184 | (string< (namestring one) (namestring two))) 185 | 186 | (defun file/directory-name (path) 187 | (car (last (cl-ppcre:split "/" path)))) 188 | 189 | (defun display-info (frame pane) 190 | (declare (ignore frame)) 191 | (labels ((looper (input &optional ac) 192 | (if input 193 | (progn 194 | (with-output-as-presentation 195 | (pane (format nil "~{~a~^/~}/" 196 | (append ac (list (car input)))) 197 | 'chdir-presentation) 198 | (format pane "~a/" (car input)) 199 | ) 200 | (looper (cdr input) (append ac (list (car input)))) 201 | ) 202 | (unless ac 203 | (with-output-as-presentation (pane "/" 204 | 'chdir-presentation) 205 | (format pane "/")))))) 206 | (with-etbembo (pane :bold) 207 | (format pane "Current Directory: ")) 208 | (with-etbembo (pane :italic-bold) 209 | (looper (cl-ppcre:split "/" (namestring (uiop:getcwd))))))) 210 | 211 | (defun display-marks (frame pane) 212 | (declare (ignore frame)) 213 | (with-end-of-line-action (pane :allow) 214 | (with-etbembo (pane :bold) 215 | (format pane "Current Marks: ")) 216 | (with-etbembo (pane :italic) 217 | (format pane "~{~a~^ ~}" (or *marks* '("")))))) 218 | 219 | ;; 📁 is the folder uncode codepoint (01f4c1) 220 | 221 | (defun display-current-directory (frame pane) 222 | (declare (ignore frame)) 223 | (with-end-of-line-action (pane :scroll) 224 | (slim:with-table (pane) 225 | (with-etbembo (pane :bold) 226 | (slim:row 227 | (slim:cell (format pane "Type")) (slim:cell (format pane "Name")) 228 | (slim:cell (format pane "User")) (slim:cell (format pane "Group")) 229 | (slim:cell (format pane "Permissions")))) 230 | (with-output-as-presentation (pane (concatenate 'string 231 | (namestring (uiop:getcwd)) 232 | "..") 233 | 'chdir-presentation 234 | :single-box t) 235 | (let* ((path (concatenate 'string (namestring (uiop:getcwd)) "..")) 236 | (stat (osicat-posix:stat path))) 237 | (slim:row 238 | (with-etbembo (pane) 239 | (with-drawing-options (pane :ink +blue+) 240 | (slim:cell (format pane "Dir"))) 241 | (slim:cell (format pane "Up One Directory")) 242 | (slim:cell (format pane "~a" 243 | (cdr 244 | (assoc 245 | (format nil "~a" (osicat-posix:stat-uid stat)) 246 | *uid-username* :test #'string-equal)))) 247 | (slim:cell (format pane "~a" 248 | (cdr 249 | (assoc 250 | (format nil "~a" (osicat-posix:stat-gid stat)) 251 | *gid-username* :test #'string-equal))))) 252 | (slim:cell (format pane "~a" (permissions-as-string path)))))) 253 | (let ((contents (sort (uiop:subdirectories (uiop:getcwd)) #'path<))) 254 | (loop for path in contents 255 | unless (and *hide-files* (hidden-pathname-p path)) 256 | do (let ((stat (handler-case (osicat-posix:stat path) 257 | (t () nil)))) 258 | (with-output-as-presentation (pane 259 | (namestring path) 260 | 'chdir-presentation 261 | :single-box t) 262 | (slim:row 263 | (with-drawing-options 264 | (pane :ink (if (member (namestring path) *marks* 265 | :test #'string=) 266 | +orange-red+ +black+)) 267 | (with-text-style 268 | (pane (make-text-style 269 | "ETBembo" (if (member (namestring path) 270 | *marks* 271 | :test #'string=) 272 | "DisplayItalicBold" "RomanLF") 273 | 16)) 274 | (slim:cell 275 | (with-drawing-options 276 | (pane :ink (if (member (namestring path) 277 | *marks* :test #'string=) 278 | +orange-red+ +blue+)) 279 | (format pane "Dir"))) 280 | (slim:cell (format pane "~a" (file/directory-name 281 | (namestring path)))) 282 | (slim:cell 283 | (format pane "~a" 284 | (cdr 285 | (assoc 286 | (format nil "~a" 287 | (and stat 288 | (osicat-posix:stat-uid stat))) 289 | *uid-username* :test #'string-equal)))) 290 | (slim:cell 291 | (format pane "~a" 292 | (cdr 293 | (assoc 294 | (format nil "~a" 295 | (and stat 296 | (osicat-posix:stat-gid stat))) 297 | *gid-username* :test #'string-equal))))) 298 | 299 | (slim:cell 300 | (format pane "~a" 301 | (and stat (permissions-as-string 302 | (namestring path))))))))))) 303 | (let ((contents (sort (uiop:directory-files (uiop:getcwd)) #'path<))) 304 | (loop for path in contents 305 | unless (and *hide-files* (hidden-pathname-p path)) 306 | do (let ((stat (handler-case (osicat-posix:stat path) 307 | (t () nil)))) 308 | (with-output-as-presentation (pane 309 | (namestring path) 310 | 'fopen-presentation 311 | :single-box t) 312 | (slim:row 313 | (with-drawing-options 314 | (pane :ink (if (member (namestring path) *marks* 315 | :test #'string=) 316 | +orange-red+ +black+)) 317 | (with-text-style 318 | (pane (make-text-style 319 | "ETBembo" (if (member (namestring path) 320 | *marks* 321 | :test #'string=) 322 | "DisplayItalicBold" "RomanLF") 323 | 16)) 324 | (slim:cell 325 | (with-drawing-options 326 | (pane :ink (if (member (namestring path) 327 | *marks* :test #'string=) 328 | +orange-red+ +green4+)) 329 | (format pane "File"))) 330 | (slim:cell (format pane "~a" (file/directory-name 331 | (namestring path)))) 332 | (slim:cell 333 | (format pane "~a" 334 | (cdr 335 | (assoc 336 | (format nil "~a" 337 | (and stat 338 | (osicat-posix:stat-uid 339 | stat))) 340 | *uid-username* :test #'string-equal)))) 341 | (slim:cell 342 | (format pane "~a" 343 | (cdr 344 | (assoc 345 | (format nil "~a" 346 | (and stat 347 | (osicat-posix:stat-gid 348 | stat))) 349 | *gid-username* :test #'string-equal))))) 350 | (slim:cell 351 | (format pane "~a" 352 | (and stat 353 | (permissions-as-string path))))))))))))) 354 | -------------------------------------------------------------------------------- /clfm-demo-picture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szos/CLFM/6ffdcea0d24ae5bc817e92487b014644e2b0fe0d/clfm-demo-picture.png -------------------------------------------------------------------------------- /command-utilities.lisp: -------------------------------------------------------------------------------- 1 | 2 | (in-package :clfm-2) 3 | 4 | (defmacro accept-with-table ((stream) &body accept-statements) 5 | "this simple macro wraps every accept statement in a formatting table, column, 6 | and cell. " 7 | `(formatting-table (,stream) 8 | ,@(loop for item in accept-statements 9 | collect `(formatting-column (,stream) 10 | (formatting-cell (,stream) 11 | ,item))))) 12 | 13 | (defmacro make-popup ((stream label) &body body) 14 | `(restart-case 15 | (let ((stream ,stream)) 16 | (accepting-values (stream :own-window t 17 | :label ,label) 18 | ,@body 19 | (terpri stream) 20 | (terpri stream) 21 | (accept 'string 22 | :prompt "DUMMY INPUT DO NOT USE" 23 | :stream stream))) 24 | (abort () ()))) 25 | 26 | (defun file-or-directory-exists-p (item) 27 | (or (uiop:file-exists-p item) 28 | (uiop:directory-exists-p))) 29 | 30 | (defun escape-spaces (string) 31 | (coerce (loop for char in (coerce string 'list) 32 | if (char= #\space char) 33 | collect #\\ 34 | and collect #\space 35 | else collect char) 36 | 'string)) 37 | 38 | (defun test/escape-spaces (string) 39 | (coerce (loop for char in (coerce string 'list) 40 | if (char= #\space char) 41 | collect #\\ 42 | and collect #\space 43 | else collect char) 44 | 'string)) 45 | 46 | ;; (nlet churner ((charlist '(#\\ #\space #\\ )) 47 | ;; (counter 1)) ; count down 48 | ;; (cond ((not (char= #\\ (car charlist))) 49 | ;; counter) 50 | ;; (t 51 | ;; (if (= counter 0) 52 | ;; (churner (cdr charlist) 1) 53 | ;; (churner (cdr charlist) 0))))) 54 | 55 | ;; (defun spaces-escaped (string) 56 | ;; (nlet spaceloop ((s (coerce string 'list)) 57 | ;; (previous-chars '())) 58 | ;; (if (char= (car s) #\space) 59 | ;; (if (and (char= (car previous-chars) #\\) 60 | ;; (char= (cadr previous-chars #\\))) 61 | ;; )) 62 | ;; (cond ((char= (car s) #\\) 63 | ;; )))) 64 | 65 | (defun string-contains (string character) 66 | (let ((char (if (stringp character) (coerce character 'character) character))) 67 | (loop for c across string 68 | when (char= c char) 69 | do (return-from string-contains t)))) 70 | 71 | (define-clfm-command (com-run-shell-command :name "Run Shell Command") 72 | ((command string :prompt "/bin/sh -c")) 73 | (uiop:launch-program (format nil "/bin/sh -c ~a" command))) 74 | 75 | (define-gesture-name :exit-clfm :keyboard (#\q :control :meta)) 76 | 77 | (define-clfm-command (com-quit :name "Quit" :keystroke :exit-clfm) () 78 | (frame-exit *application-frame*)) 79 | (define-clfm-command (com-exit :name "Exit") () 80 | (frame-exit *application-frame*)) 81 | 82 | (define-clfm-command (com-display-help-window) () 83 | (let ((frame (make-application-frame 'clfm-help))) 84 | (run-frame-top-level frame))) 85 | 86 | (define-clfm-command (com-loadrc :name "Load Init File") () 87 | (handler-case (load "~/.clfm.d/init.lisp") 88 | (t () ()))) 89 | 90 | (define-clfm-command (com-show-marks) () 91 | (setf (frame-current-layout *application-frame*) 'default)) 92 | 93 | (define-clfm-command (com-hide-marks) () 94 | (setf (frame-current-layout *application-frame*) 'no-marks)) 95 | 96 | (define-clfm-command (com-toggle-hidden-files) () 97 | (setf *hide-files* (not *hide-files*)) 98 | (redisplay-frame-panes *application-frame* :force-p t)) 99 | -------------------------------------------------------------------------------- /commands-update.lisp: -------------------------------------------------------------------------------- 1 | (in-package :clfm-2) 2 | 3 | (defparameter *override-characters-as-string* 4 | '(("RET" . :return) 5 | ("SPC" . #\space) 6 | ("TAB" . #\tab) 7 | ("æ" . #\latin_small_letter_ae) 8 | ("ø" . #\LATIN_SMALL_LETTER_O_WITH_STROKE) 9 | ("å" . #\LATIN_SMALL_LETTER_A_WITH_RING_ABOVE) 10 | ("ł" . #\LATIN_SMALL_LETTER_L_WITH_STROKE))) 11 | 12 | (defun key-chord (chord-def) 13 | (let* ((elements (reverse (cl-ppcre:split "-" chord-def))) 14 | (char (pop elements))) 15 | (setf char 16 | (if (assoc char *override-characters-as-string* :test #'string-equal) 17 | (cdr (assoc char *override-characters-as-string* 18 | :test #'string-equal)) 19 | (coerce char 'character))) 20 | (cons char (remove-if #'not (loop for s in elements 21 | collect (cond ((string= s "S") 22 | (setf char (char-upcase char)) 23 | nil) 24 | ((string= s "C") :control) 25 | ((string= s "M") :Meta) 26 | ((string= s "s") :super) 27 | ((string= s "H") :Hyper))))))) 28 | 29 | (defun kbd (key-seq) 30 | "This function parses a string into a list of gestures. The string is split by 31 | spaces, and every one of these is parsed into a single gesture. the final character 32 | is the character, all others are modifiers, and hyphens are ignored. Modifier 33 | translation is as follows: C - :control, M - :meta, H - :hyper, s - :super. 34 | a capital S in the modifier position changes the character to a capital. " 35 | (let* ((str-seq (cl-ppcre:split " " key-seq)) 36 | (seq (loop for str in str-seq 37 | collect 38 | (let* ((charbag (reverse (coerce str 'list))) 39 | (char (pop charbag)) 40 | (mods (loop for c in charbag 41 | unless (char= c #\-) 42 | collect (cond ((char= c #\S) 43 | (setf 44 | char 45 | (char-upcase char)) 46 | nil) 47 | ((char= c #\C) :control) 48 | ((char= c #\M) :Meta) 49 | ((char= c #\s) :super) 50 | ((char= c #\H) :Hyper))))) 51 | (cons char (remove-if #'not mods)))))) 52 | seq)) 53 | 54 | (defun display-info (frame pane) 55 | (declare (ignore frame)) 56 | (labels ((looper (input &optional ac) 57 | (if input 58 | (progn 59 | (with-output-as-presentation 60 | (pane (format nil "~{~a~^/~}/" 61 | (append ac (list (car input)))) 62 | 'chdir-presentation) 63 | (format pane "~a/" (car input))) 64 | (looper (cdr input) (append ac (list (car input))))) 65 | (unless ac 66 | (with-output-as-presentation (pane "/" 67 | 'chdir-presentation) 68 | (format pane "/")))))) 69 | (with-etbembo (pane :bold) 70 | (format pane "Current Directory: ")) 71 | (with-etbembo (pane :italic-bold) 72 | (looper (cl-ppcre:split "/" (namestring (uiop:getcwd)))) 73 | (with-etbembo (pane) 74 | (format pane "[~a]" 75 | (car (reverse (cl-ppcre:split "/" (namestring (current-item)))))))))) 76 | 77 | (define-clfm-command (com-change-directory-temper) ((directory string)) 78 | (handler-case 79 | (when (uiop:directory-exists-p directory) 80 | (change-directory directory)) 81 | (sb-posix:syscall-error (err) 82 | (case 83 | (notify-user *application-frame* 84 | (let ((errno (sb-posix:syscall-errno err))) 85 | (cond ((= errno 13) 86 | "You don't have permission to access this directory 87 | 88 | To access this directory CLFM needs to be running as root 89 | 90 | To relaunch CLFM please ensure it is in your $PATH") 91 | (t 92 | (format nil "SB-POSIX Error Code: ~a" errno)))) 93 | :title "CLFM Error" 94 | :name "CLFM Error" 95 | :documentation "CLFM Error" 96 | :text-style (make-text-style "ETBembo" "BoldLF" 18) 97 | :exit-boxes '((t "OK") 98 | (:sudo "Relaunch as root"))) 99 | ((:sudo) 100 | (and (notify-user *application-frame* 101 | "WARNING: CLFM will now be running with root privilidges. 102 | This is not safe, and should be avoided. 103 | 104 | If you continue, type your password when presented with the blank window and use 105 | M-RET (meta + return or Alt + return) to submit it" 106 | :exit-boxes '((t "CONTINUE") (nil "ABORT")) 107 | :text-style (make-text-style "ETBembo" "BoldLF" 18)) 108 | (let (passwd 109 | (stream (frame-standard-input *application-frame*))) 110 | (accepting-values (stream 111 | :own-window t 112 | :initially-select-query-identifier 'password) 113 | (formatting-table (stream) 114 | (formatting-column (stream) 115 | (formatting-cell (stream) 116 | (setf passwd (accept 'password 117 | ;; 'string 118 | :prompt "sudo password" 119 | :stream stream 120 | :query-identifier 'password)))))) 121 | (uiop:launch-program 122 | (format nil "echo \"~a\" | sudo -S clfm" passwd))))))))) 123 | 124 | (define-clfm-command (com-add-mark) ((markl t)) 125 | (let ((mark (if (listp markl) 126 | (namestring (car markl)) 127 | markl))) 128 | (if (member mark *marks* :test #'string=) 129 | (setf *marks* (remove mark *marks* :test #'string=)) 130 | (setf *marks* (cons mark *marks*))))) 131 | 132 | (define-clfm-command (com-delete) ((thing t)) 133 | (let ((item (if (listp thing) 134 | (namestring (car thing)) 135 | thing))) 136 | (cond ((uiop:directory-exists-p item) 137 | (delete-directory item)) 138 | ((uiop:file-exists-p item) 139 | (delete-item item))))) 140 | 141 | (define-clfm-command (com-open) ((thing t)) 142 | (let ((item (if (listp thing) 143 | (namestring (car thing)) 144 | thing))) 145 | (cond ((uiop:directory-exists-p item) 146 | (com-change-directory-temper item)) 147 | ((uiop:file-exists-p item) 148 | (open-file (namestring item)))))) 149 | 150 | (define-clfm-command (com-open-with) ((thing t)) 151 | (let (program 152 | (item (if (listp thing) 153 | (namestring (car thing)) 154 | thing))) 155 | (cond ((uiop:file-exists-p item) 156 | (restart-case 157 | (progn 158 | (accepting-values (stream :own-window t 159 | :label "Enter Program" 160 | :initially-select-query-identifier 161 | 'program 162 | :resynchronize-every-pass t 163 | ;; :resize-frame t 164 | :height 150 165 | :width 500) 166 | (formatting-table (stream) 167 | (formatting-column (stream) 168 | (formatting-cell (stream) 169 | (setf program (accept 'string 170 | :prompt "Program" 171 | :stream stream 172 | :query-identifier 'program)))))) 173 | (and program (uiop:launch-program 174 | (format nil "~a ~a" program (escape-spaces item))))) 175 | (abort () ()))) ))) 176 | 177 | (define-gesture-name :meta-click-left :pointer-button (:left :meta)) 178 | 179 | (define-gesture-name :meta-control :keyboard (:control :meta)) 180 | 181 | (define-gesture-name :prev-item :keyboard (#\p :control)) 182 | (define-gesture-name :mark-item :keyboard (#\m :control)) 183 | 184 | (define-presentation-type filesystem-presentation ()) 185 | 186 | (defun set-operation-order (&key (delete -1) 187 | (open 4) 188 | (open-with 3) 189 | (rename 2) 190 | (copy 1)) 191 | (define-presentation-to-command-translator up-selection 192 | (filesystem-presentation com-move-up clfm 193 | :gesture :control-p 194 | :documentation "Up one selection") 195 | (item) 196 | (list item)) 197 | (define-presentation-to-command-translator down-selection 198 | (filesystem-presentation com-move-down clfm 199 | :gesture :control-n 200 | :documentation "Down one selection") 201 | (item) 202 | (list item)) 203 | (define-presentation-to-command-translator filesystem-mark 204 | (filesystem-presentation com-add-mark clfm 205 | :gesture :meta-click-left 206 | :documentation "Mark") 207 | (item) 208 | (list item)) 209 | (define-presentation-to-command-translator filesystem-delete 210 | (filesystem-presentation com-delete clfm 211 | :gesture :select 212 | :documentation "Delete (PERMANENT)" 213 | :priority delete) 214 | (item) 215 | (list item)) 216 | (define-presentation-to-command-translator filesystem-open 217 | (filesystem-presentation com-open clfm 218 | :gesture :select 219 | :documentation "Open" 220 | :priority open) 221 | (item) 222 | (list item)) 223 | (define-presentation-to-command-translator filesystem-open-with 224 | (filesystem-presentation com-open-with clfm 225 | :gesture :select 226 | :documentation "Open With" 227 | :priority open-with 228 | :tester ((item) (uiop:file-exists-p (if (listp item) 229 | (namestring (car item)) 230 | item)))) 231 | (item) 232 | (list item)) 233 | (define-presentation-to-command-translator filesystem-rename 234 | (filesystem-presentation com-rename clfm 235 | :gesture :select 236 | :documentation "Rename" 237 | :priority rename) 238 | (item) 239 | (list item)) 240 | (define-presentation-to-command-translator filesystem-copy 241 | (filesystem-presentation com-copy clfm 242 | :gesture :select 243 | :documentation "Copy" 244 | :priority copy) 245 | (item) 246 | (list item))) 247 | 248 | (set-operation-order) 249 | 250 | (defun pane-scrolled-to-bottom-p (pane) 251 | (multiple-value-bind (x y) (transform-position (sheet-transformation pane) 252 | 0 0) 253 | (declare (ignore x)) 254 | (with-bounding-rectangle* (x1 y1 x2 y2) pane 255 | (declare (ignore x1 y1 x2)) 256 | (with-bounding-rectangle* (ax1 ay1 ax2 ay2) (sheet-parent pane) 257 | (declare (ignore ax1 ay1 ax2)) 258 | (<= (+ y y2) ay2))))) 259 | 260 | (defun scroll-pane-to-bottom (pane) 261 | (scroll-extent pane 0 (max 0 (- (bounding-rectangle-height pane) 262 | (bounding-rectangle-height 263 | (sheet-parent pane)))))) 264 | 265 | (defmacro with-pane-kept-scrolled-to-bottom ((pane-form) &body body) 266 | "Ensure that the pane in PANE-FORM has the same scroll state 267 | after BODY terminates as it had before: 268 | 269 | If the pane is scrolled to some position before the end, it is 270 | kept there. If the pane is at the bottom of the pane, the 271 | viewport is reset to the then-current bottom after BODY is 272 | finished." 273 | (let ((pane (gensym)) 274 | (bottom-p (gensym))) 275 | `(let* ((,pane ,pane-form) 276 | (,bottom-p (pane-scrolled-to-bottom-p ,pane))) 277 | (multiple-value-prog1 (progn ,@body) 278 | (when ,bottom-p (scroll-pane-to-bottom ,pane)))))) 279 | 280 | (let ((pre-selection-contents nil) 281 | (selected-item 282 | (let ((all (append (sort (uiop:subdirectories (uiop:getcwd)) #'path<) 283 | (sort (uiop:directory-files (uiop:getcwd)) #'path<)))) 284 | (if *hide-files* 285 | (car (remove-if #'hidden-pathname-p all)) 286 | (car all)))) 287 | (post-selection-contents 288 | (let ((all (append (sort (uiop:subdirectories (uiop:getcwd)) #'path<) 289 | (sort (uiop:directory-files (uiop:getcwd)) #'path<)))) 290 | (if *hide-files* 291 | (cdr (remove-if #'hidden-pathname-p all)) 292 | (cdr all))))) 293 | (defun current-item () selected-item) 294 | (defun add-current-selected-to-marks () 295 | (com-add-mark (namestring selected-item))) 296 | (defun enter-or-open-current-selection () 297 | (com-open selected-item)) 298 | (defun change-directory (directory) 299 | (uiop:chdir directory) 300 | (let ((contents 301 | (append (sort (uiop:subdirectories (uiop:getcwd)) #'path<) 302 | (sort (uiop:directory-files (uiop:getcwd)) #'path<)))) 303 | (setf pre-selection-contents nil 304 | selected-item (if *hide-files* 305 | (car (remove-if #'hidden-pathname-p contents)) 306 | (car contents)) 307 | post-selection-contents (if *hide-files* 308 | (cdr (remove-if #'hidden-pathname-p 309 | contents)) 310 | (cdr contents)))) 311 | (redisplay-frame-panes *application-frame* :force-p t)) 312 | (defun move-selection-up () 313 | (when pre-selection-contents 314 | (setf post-selection-contents (cons selected-item post-selection-contents)) 315 | (setf selected-item (pop pre-selection-contents)))) 316 | (defun move-selection-down () 317 | (when post-selection-contents 318 | (setf pre-selection-contents (cons selected-item pre-selection-contents)) 319 | (setf selected-item (pop post-selection-contents)) 320 | ;; (scroll-extent ()) 321 | )) 322 | (defun display-current-directory (frame pane) 323 | (declare (ignore frame)) 324 | (display-current-directory-worker pane pre-selection-contents selected-item post-selection-contents))) 325 | 326 | (defun display-current-directory-worker (pane pre-selection-contents selected-item post-selection-contents) 327 | (slim:with-table (pane) 328 | (labels ((display-item (path &optional current) 329 | (let ((stat (handler-case (osicat-posix:stat path) (t () nil)))) 330 | (with-output-as-presentation (pane 331 | (namestring path) 332 | 'filesystem-presentation 333 | :single-box t) 334 | (slim:row 335 | (slim:cell 336 | (if (member (namestring path) 337 | *marks* :test #'string-equal) 338 | (with-drawing-options (pane :ink +red+) 339 | (format pane "*")) 340 | (with-drawing-options (pane :ink +black+) 341 | (format pane " ")))) 342 | (with-drawing-options 343 | (pane :ink (if (member (namestring path) *marks* 344 | :test #'string=) 345 | (if current +purple+ +orange-red+) 346 | (if current +purple+ +black+))) 347 | (with-text-style 348 | (pane (make-text-style 349 | "ETBembo" 350 | (cond ((member (namestring path) *marks* 351 | :test #'string=) 352 | "DisplayItalicBold") 353 | ;; (current "SuperBoldOSF") 354 | (t "RomanLF")) 355 | 356 | 16)) 357 | (slim:cell 358 | (if (uiop:directory-exists-p path) 359 | (with-drawing-options 360 | (pane :ink (if (member (namestring path) 361 | *marks* 362 | :test #'string=) 363 | +orange-red+ +blue+)) 364 | (format pane "DIR")) 365 | (with-drawing-options 366 | (pane :ink (if (member (namestring path) 367 | *marks* 368 | :test #'string=) 369 | +orange-red+ +green4+)) 370 | (format pane "FILE")))) 371 | (slim:cell (format pane "~a" (file/directory-name 372 | (namestring path)))) 373 | (slim:cell 374 | (format pane "~a" 375 | (cdr 376 | (assoc 377 | (format nil "~a" 378 | (and stat 379 | (osicat-posix:stat-uid stat))) 380 | *uid-username* :test #'string-equal)))) 381 | 382 | ) 383 | (slim:cell 384 | (format pane "~a" 385 | (and stat (permissions-as-string 386 | path)))) 387 | ;; (let ((strs (permissions-as-list path))) 388 | ;; (loop for s in strs 389 | ;; do (slim:cell (format pane s)))) 390 | )))) 391 | )) 392 | (when pre-selection-contents 393 | (loop for path in (reverse pre-selection-contents) 394 | unless (and *hide-files* (hidden-pathname-p path)) 395 | do (display-item path))) 396 | (when selected-item 397 | (display-item selected-item t)) 398 | (when post-selection-contents 399 | (loop for path in post-selection-contents 400 | unless (and *hide-files* (hidden-pathname-p path)) 401 | do (display-item path))) 402 | ;; (when (< (length post-selection-contents) (length pre-selection-contents)) 403 | ;; (scroll-pane-to-bottom pane)) 404 | ))) 405 | 406 | (define-gesture-name :next-item :keyboard (#\n :control)) 407 | (define-gesture-name :prev-item :keyboard (#\p :control)) 408 | (define-gesture-name :mark-item :keyboard (#\space :control)) 409 | (define-gesture-name :up-directory :keyboard (#\p :meta)) 410 | ;; (define-gesture-name :open :keyboard (#\o :control)) 411 | (define-gesture-name :open :keyboard (:return :control)) 412 | (define-gesture-name :test :keyboard (#\t :control :meta) 413 | ;; (:return :control) 414 | ) 415 | 416 | ;; broken (define-gesture-name :carriage-return :keyboard ( )) 417 | (define-gesture-name :carriage-return :keyboard (#\m :control)) 418 | 419 | 420 | (define-clfm-command (com-move-up :name "Move Up Selection" 421 | :keystroke :prev-item) () 422 | (move-selection-up)) 423 | 424 | (define-clfm-command (com-move-down :name "Move Down Selection" 425 | :keystroke :next-item) () 426 | (move-selection-down)) 427 | 428 | (define-clfm-command (com-keyboard-mark :keystroke :mark-item) () 429 | (add-current-selected-to-marks)) 430 | 431 | (define-clfm-command (com-up-directory :keystroke :up-directory) () 432 | (change-directory (concatenate 'string (namestring (uiop:getcwd)) "../"))) 433 | 434 | (define-clfm-command (com-keyboard-open :keystroke :open) () 435 | (enter-or-open-current-selection)) 436 | 437 | ;; (define-clfm-command (com-test-test-keyboard :keystroke ;; (#\k :control) 438 | ;; (:test-cc :test-mc)) () 439 | ;; (enter-or-open-current-selection)) 440 | 441 | (define-clfm-command (com-keyboard-open :keystroke (#\i :shift :super)) () 442 | (enter-or-open-current-selection)) 443 | 444 | ;; (add-input-editor-command 445 | ;; ) 446 | 447 | (define-gesture-name :test-cc :keyboard (#\c :control)) 448 | (define-gesture-name :test-mc :keyboard (#\c :meta)) 449 | 450 | ;; ok this is broken... somehow... IDK why... 451 | (defmacro define-main-keybinding (gesture &body body) 452 | "Takes a gesture by name or by specification, and defines a command which runs 453 | body. If gesture is a string, it MUST be a single key chord. " 454 | (let ((command (intern (symbol-name (gensym "COM-ANONYMOUS-KEYBINDING-")))) 455 | (key-seq (if (stringp gesture) 456 | (key-chord gesture) 457 | gesture))) 458 | `(define-clfm-command (,command :keystroke ,key-seq) () 459 | ,@body))) 460 | 461 | ;; (define-main-keybinding "C-ł" 462 | ;; ;; "M- " ;; (#\j :meta) 463 | ;; (add-current-selected-to-marks)) 464 | 465 | ;; (define-main-keybinding (#\latin_small_letter_ae :control) 466 | ;; (add-current-selected-to-marks)) 467 | 468 | ;; (define-main-keybinding (:return :control) 469 | ;; (enter-or-open-current-selection)) 470 | 471 | -------------------------------------------------------------------------------- /commands.lisp: -------------------------------------------------------------------------------- 1 | (in-package :clfm-2) 2 | 3 | (define-gesture-name :meta-click-left :pointer-button (:left :meta)) 4 | 5 | (define-gesture-name :meta-control :keyboard (:control :meta)) 6 | 7 | (define-presentation-type fopen-presentation ()) 8 | 9 | (defun set-file-command-order (&key 10 | (delete -1) 11 | (open 4) 12 | (open-with 3) 13 | (rename 2) 14 | (copy 1) 15 | ;; (mark 0) 16 | ) 17 | "the higher the number, the higher on the list it will be" 18 | ;; (define-presentation-to-command-translator fshift-click 19 | ;; (fopen-presentation com-mark-between-items)) 20 | (define-presentation-to-command-translator fmark 21 | (fopen-presentation com-add-mark clfm 22 | ;; :gesture :select 23 | :gesture :meta-click-left 24 | :documentation "Mark File" 25 | ;; :priority mark 26 | ) 27 | (file) 28 | (list file)) 29 | (define-presentation-to-command-translator fdelete 30 | (fopen-presentation com-rm-file clfm 31 | :gesture :select 32 | :documentation "Delete File (PERMANENT)" 33 | :priority delete) 34 | (f) 35 | (list f)) 36 | (define-presentation-to-command-translator fopen 37 | (fopen-presentation com-open-file clfm 38 | :gesture :select 39 | :documentation "Open File" 40 | :priority open) 41 | (f) 42 | (list f)) 43 | (define-presentation-to-command-translator fopen-with 44 | (fopen-presentation com-open-file-with clfm 45 | :gesture :select 46 | :documentation "Open File With" 47 | :priority open-with) 48 | (f) 49 | (list f)) 50 | (define-presentation-to-command-translator frename 51 | (fopen-presentation com-rename-this clfm 52 | :gesture :select 53 | :documentation "Rename this" 54 | :priority rename) 55 | (f) 56 | (list f)) 57 | (define-presentation-to-command-translator fcopy 58 | (fopen-presentation com-copy-file-prompt clfm 59 | :gesture :select 60 | :documentation "Copy this file" 61 | :priority copy) 62 | (f) 63 | (list f))) 64 | 65 | (set-file-command-order) 66 | 67 | (define-presentation-type chdir-presentation ()) 68 | 69 | ;; (define-gesture-name :double-click :pointer-button (:left :double)) 70 | 71 | (defun set-directory-command-order (&key 72 | (change-directory 3) 73 | (delete -1) 74 | ;; (mark 2) 75 | (copy 1)) 76 | (define-presentation-to-command-translator dcopy 77 | (chdir-presentation com-copy-directory-prompt clfm 78 | :gesture :select 79 | :documentation "Copy Directory" 80 | :priority copy) 81 | (dir) 82 | (list dir)) 83 | (define-presentation-to-command-translator chdir 84 | (chdir-presentation com-change-directory-temper clfm 85 | :gesture :select 86 | ;; :gesture :double-click 87 | :Documentation "Change to Directory" 88 | :priority change-directory 89 | ) 90 | (dir) 91 | (list dir)) 92 | (define-presentation-to-command-translator dir-delete 93 | (chdir-presentation com-delete-directory clfm 94 | :gesture :select 95 | :documentation "Delete Directory (PERMANENT)" 96 | :priority delete) 97 | (dir) 98 | (list dir)) 99 | (define-presentation-to-command-translator dmark 100 | (chdir-presentation com-add-mark clfm 101 | ;; :gesture :select 102 | :gesture :meta-click-left 103 | :documentation "Mark Directory" 104 | ;; :priority mark 105 | ) 106 | (file) 107 | (list file))) 108 | 109 | (set-directory-command-order) 110 | 111 | (defun file-prefer-marks () 112 | (set-file-command-order :mark 5)) 113 | 114 | (defun directory-prefer-marks () 115 | (set-directory-command-order :mark 3)) 116 | 117 | ;; (define-drag-and-drop-translator drag-and-drop-directory 118 | ;; (chdir-presentation 119 | ;; chdir-presentation dcopy clfm 120 | ;; :documentation "drag and drop file" 121 | ;; :gesture )) 122 | 123 | (make-command-table 'clfm-menu-bar 124 | :errorp nil 125 | :menu '(("Quit" :command com-quit) 126 | ("File" :menu clfm-file) 127 | ("Operate/Marks" :menu clfm-operation-menu) 128 | ("View" :menu clfm-view-menu) 129 | ("Help" :menu clfm-help-menu))) 130 | 131 | (make-command-table 'clfm-file 132 | :errorp nil 133 | :menu '(("New File" :command com-new-file) 134 | ("New Directory" :command com-new-dir) 135 | ("Go Home" :command com-chdir-~/) 136 | ("Rename…" :command com-rename-prompt) 137 | ("Load Init File" :command com-loadrc))) 138 | 139 | (make-command-table 'clfm-operation-menu 140 | :errorp nil 141 | :menu '(("Select Operation" :command com-operate-on-marks))) 142 | 143 | (make-command-table 'clfm-view-menu 144 | :errorp nil 145 | :menu '(("Marks" :menu clfm-view-marks-menu) 146 | ("Display Hidden Files" :command 147 | com-toggle-hidden-files))) 148 | 149 | (make-command-table 'clfm-view-marks-menu 150 | :errorp nil 151 | :menu '(("Show Marks" :command com-show-marks) 152 | ("Hide Marks" :command com-hide-marks))) 153 | 154 | (make-command-table 'clfm-help-menu 155 | :errorp nil 156 | :menu '(("Help Window" :command com-display-help-window) 157 | ("test" :command com-move-down 158 | :keystroke (:n :control)))) 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /copy.lisp: -------------------------------------------------------------------------------- 1 | 2 | (in-package :clfm-2) 3 | 4 | (defun %copy-file (f1 f2) 5 | (with-open-file (infile f1 :direction :input 6 | :element-type '(unsigned-byte 8)) 7 | (with-open-file (outfile f2 :direction :output 8 | :element-type '(unsigned-byte 8) 9 | :if-exists :error) 10 | (when infile 11 | (loop for byte = (read-byte infile nil) 12 | while byte 13 | do (write-byte byte outfile)))))) 14 | 15 | (defun copy-file (&optional file new-file) 16 | (restart-case 17 | (let ((stream (frame-standard-input *application-frame*)) 18 | oldname newname) 19 | (accepting-values (stream :own-window t 20 | :label (or (and 21 | file 22 | (format nil "Copy ~a" file)) 23 | "Copy a file") 24 | :initially-select-query-identifier 25 | (or (and file 'newfile) 'file)) 26 | (accept-with-table (stream) 27 | (or (and file (setf oldname file)) 28 | (setf oldname (accept 'string 29 | :prompt "Filename" 30 | :stream stream 31 | :query-identifier 'file))) 32 | (or (and new-file (setf newname new-file)) 33 | (setf newname (accept 'string 34 | :prompt "Copy to" 35 | :stream stream 36 | :query-identifier 'newfile))))) 37 | (unless (member #\/ (coerce newname 'list)) 38 | (setf newname (concatenate 'string 39 | (namestring (uiop:getcwd)) 40 | newname))) 41 | (and oldname newname (%copy-file oldname newname))) 42 | (abort () ()))) 43 | 44 | (define-clfm-command (com-copy-file) ((file string) (copy-to string)) 45 | (copy-file file copy-to)) 46 | 47 | (define-clfm-command (com-copy-file-prompt) ((file string)) 48 | (copy-file file)) 49 | 50 | (defun %copy-directory-contents (from to) 51 | "copy the contents of from to to. This is a helper" 52 | (ensure-directories-exist to) 53 | (labels 54 | ((copier (tdir fdir list) 55 | (print fdir) 56 | (print list) 57 | (cond ((uiop:directory-exists-p (car list)) 58 | (let ((dirname 59 | (coerce 60 | (reverse 61 | (loop for c in (cdr (coerce (reverse 62 | (namestring (car list))) 63 | 'list)) 64 | while (not (char= c #\/)) 65 | collect c)) 66 | 'string))) 67 | (ensure-directories-exist (concatenate 'string 68 | (namestring tdir) 69 | dirname "/")) 70 | (copier (concatenate 'string (namestring tdir) dirname "/") 71 | (concatenate 'string (namestring fdir) dirname "/") 72 | (append (uiop:subdirectories 73 | (pathname 74 | (concatenate 'string (namestring fdir) 75 | dirname "/"))) 76 | (uiop:directory-files 77 | (pathname 78 | (concatenate 'string (namestring fdir) 79 | dirname "/"))))) 80 | (copier tdir fdir (cdr list)))) 81 | ((uiop:file-exists-p (car list)) 82 | (let ((cto 83 | (coerce 84 | (reverse 85 | (loop for c in (coerce (reverse (namestring (car list))) 86 | 'list) 87 | while (not (char= c #\/)) 88 | collect c)) 89 | 'string))) 90 | (%copy-file (car list) (concatenate 'string (namestring tdir) 91 | cto)) 92 | (copier tdir fdir (cdr list))))))) 93 | (copier to from (append (uiop:subdirectories (pathname from)) 94 | (uiop:directory-files (pathname from)))))) 95 | 96 | (defun copy-directory (old-dir new-dir) 97 | (let (ndir 98 | (n (cdr (reverse (coerce (namestring new-dir) 'list))))) 99 | (setf ndir 100 | (if (member #\/ n :test #'char=) 101 | ;; TODO: 102 | ;; if new-dir is an absolute path... no thats not what this does. 103 | ;; this checks if theres any other directories in the path... 104 | ;; so it would fail if we were in ~/docs/ and copying from 105 | ;; ~/docs/lisp to scheme/docs/new. This is not the behavior we 106 | ;; want, this needs to be reworked to allow relative paths with 107 | ;; subdirectories 108 | new-dir 109 | (concatenate 'string (namestring (uiop:getcwd)) 110 | (namestring new-dir)))) 111 | (ensure-directories-exist ndir) 112 | (%copy-directory-contents old-dir ndir))) 113 | 114 | (defun test/copy-directory (&optional old new) 115 | (restart-case 116 | (let ((stream (frame-standard-input *application-frame*)) 117 | oldname newname) 118 | (accepting-values (stream :own-window t 119 | :label (or (and 120 | old 121 | (format nil "Copy ~a" old)) 122 | "Copy a directory") 123 | :initially-select-query-identifier 124 | (or (and old 'newname) 'directory)) 125 | (accept-with-table (stream) 126 | (or (and old (setf oldname old)) 127 | (setf oldname (accept 'string 128 | :prompt "Directory" 129 | :stream stream 130 | :query-identifier 'directory))) 131 | (or (and new (setf newname new)) 132 | (setf newname (accept 'string 133 | :prompt "Copy to" 134 | :stream stream 135 | :query-identifier 'newname))))) 136 | (ensure-directories-exist newname) 137 | (%copy-directory-contents oldname newname)) 138 | (abort () ()))) 139 | 140 | (define-clfm-command (com-copy-directory) ((file string) (copy-to string)) 141 | (test/copy-directory file copy-to)) 142 | 143 | (define-clfm-command (com-copy-directory-prompt) ((file string)) 144 | (test/copy-directory file)) 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /create-directory.lisp: -------------------------------------------------------------------------------- 1 | 2 | (in-package :clfm-2) 3 | 4 | (defun %new-directory (&optional redo) 5 | (restart-case 6 | (let (dir 7 | (stream (frame-standard-input *application-frame*))) 8 | (accepting-values (stream :own-window t 9 | :label (or (and redo "That didnt appear to be a directory, please try again, and ensure theres a trailing “/”. ") 10 | "Enter a new directory name") 11 | :initially-select-query-identifier 'dirprompt) 12 | (formatting-table (stream) 13 | (formatting-column (stream) 14 | (formatting-cell (stream) 15 | (setf dir (accept 'string 16 | :prompt "Directory" 17 | :stream stream 18 | :query-identifier 'dirprompt)))))) 19 | (and dir (com-make-directory dir))) 20 | (abort () ()))) 21 | 22 | (define-clfm-command (com-new-dir) () 23 | (%new-directory)) 24 | 25 | (define-clfm-command (com-make-directory) ((dir 'string)) 26 | (let ((fd (coerce dir 'list)) 27 | (rd (reverse (coerce dir 'list)))) 28 | (if (char= #\/ (car rd)) 29 | (if (or (char= (car fd) #\/) 30 | (char= (car fd) #\~)) 31 | (ensure-directories-exist dir) 32 | (ensure-directories-exist 33 | (concatenate 'string (namestring (uiop:getcwd)) dir))) 34 | (%new-directory t)))) 35 | -------------------------------------------------------------------------------- /create-file.lisp: -------------------------------------------------------------------------------- 1 | 2 | (in-package :clfm-2) 3 | 4 | (defparameter *touch-file* nil) 5 | 6 | (define-clfm-command (com-touch) ((filename string)) 7 | (let ((file (if (string-contains filename "/") 8 | filename 9 | (concatenate 'string (namestring (uiop:getcwd)) filename)))) 10 | (open file :direction :probe :if-does-not-exist :create))) 11 | 12 | (define-clfm-command (com-new-file) () 13 | (restart-case 14 | (let (file 15 | (stream (frame-standard-input *application-frame*))) 16 | (accepting-values (stream :own-window t 17 | :label "Enter a new file name" 18 | :initially-select-query-identifier 'fileprompt) 19 | (formatting-table (stream) 20 | (formatting-column (stream) 21 | (formatting-cell (stream) 22 | (setf file (accept 'string 23 | :prompt "Filename" 24 | :stream stream 25 | :query-identifier 'fileprompt)))))) 26 | (and file (com-touch file))) 27 | (abort () ()))) 28 | -------------------------------------------------------------------------------- /delete.lisp: -------------------------------------------------------------------------------- 1 | 2 | (in-package :clfm-2) 3 | 4 | (defparameter *directory-deletion-validation-function* 'validate-directory) 5 | 6 | (defun validate-directory (directory) 7 | (uiop:directory-exists-p directory)) 8 | 9 | (defun %delete-directory (dir) 10 | (uiop:delete-directory-tree dir 11 | :validate *directory-deletion-validation-function*)) 12 | 13 | (defun delete-directory (directory) 14 | (let ((reter (clfm-notify (*application-frame* "IRREVERSIBLE OPERATION" nil 15 | :exit-boxes ((t "PROCEED") 16 | (nil "ABORT")) 17 | :width 400) 18 | (with-end-of-line-action (pane :wrap*) 19 | (with-etbembo (pane nil 18) 20 | (format pane "You are attempting to delete a file or directory. This operation is ") 21 | (with-etbembo (pane :bold 18) 22 | (format pane "IRREVERSIBLE")) 23 | (format pane ". Proceed with caution.")))))) 24 | (when reter 25 | (%delete-directory (pathname directory))))) 26 | 27 | (defun delete-item (item) 28 | (let ((reter (clfm-notify (*application-frame* "IRREVERSIBLE OPERATION" nil 29 | :exit-boxes ((t "PROCEED") 30 | (nil "ABORT")) 31 | :width 400) 32 | (with-end-of-line-action (pane :wrap*) 33 | (with-etbembo (pane nil 18) 34 | (format pane "You are attempting to delete a file or directory. This operation is ") 35 | (with-etbembo (pane :bold 18) 36 | (format pane "IRREVERSIBLE")) 37 | (format pane ". Proceed with caution.")))))) 38 | (when reter 39 | (cond ((uiop:directory-exists-p item) 40 | (%delete-directory (pathname item))) 41 | ((uiop:file-exists-p item) 42 | (delete-file item)))))) 43 | 44 | (define-clfm-command (com-delete) ((item string)) 45 | (cond ((uiop:directory-exists-p item) 46 | (delete-directory item)) 47 | ((uiop:file-exists-p item) 48 | (delete-item item)))) 49 | -------------------------------------------------------------------------------- /demo.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szos/CLFM/6ffdcea0d24ae5bc817e92487b014644e2b0fe0d/demo.mp4 -------------------------------------------------------------------------------- /dialog.lisp: -------------------------------------------------------------------------------- 1 | (in-package :clfm-2) 2 | 3 | (define-application-frame clfm-notify-user-frame () 4 | ((message-string :initarg :message-string) 5 | (message-body :initarg :message-body) 6 | (exit-boxes :initarg :exit-boxes) 7 | (title :initarg :title) 8 | (style :initarg :style) 9 | (text-style :initarg :text-style) 10 | (width :initarg :width) 11 | (return-value :initarg nil :initform :abort)) 12 | (:pane (clfm-notify-user-dialog *application-frame*))) 13 | 14 | (defun clfm-notify-generate-exit-box-buttons (specs) 15 | (mapcar 16 | (lambda (spec) 17 | (destructuring-bind (action string &rest args) spec 18 | (spacing (:thickness 2) 19 | (apply #'make-pane 20 | 'push-button 21 | :label string 22 | :text-style (make-text-style :sans-serif :roman :small) ; XXX 23 | :activate-callback 24 | (lambda (gadget) 25 | (declare (ignore gadget)) 26 | ;; This is fboundp business is weird, and only implied by a 27 | ;; random message on the old CLIM list. Does the user function 28 | ;; take arguments? 29 | (when (or (typep action 'function) (fboundp action)) 30 | (funcall action)) 31 | (setf (slot-value *application-frame* 'return-value) action) 32 | ;; This doesn't work: 33 | #+NIL 34 | (when (eql action :abort) 35 | (and (find-restart 'abort) 36 | (invoke-restart 'abort))) 37 | (frame-exit *application-frame*)) 38 | args)))) 39 | specs)) 40 | 41 | (defun clfm-notify-user-dialog (frame) 42 | (with-slots (message-string message-body exit-boxes text-style width) frame 43 | (vertically () 44 | (spacing (:thickness 6) 45 | (make-pane 'label-pane :label (or message-string "I'm speechless.") :text-style text-style)) 46 | (spacing (:thickness 6) 47 | (make-pane 'application-pane 48 | :display-function 49 | (or (and message-body (eval `(lambda (frame pane) 50 | (declare (ignore frame)) 51 | ,message-body))) 52 | (lambda (frame pane) 53 | (declare (ignore frame) 54 | (ignore pane)))) 55 | :width width)) 56 | 57 | (spacing (:thickness 4) 58 | (make-pane 'hbox-pane :contents 59 | (cons '+fill+ 60 | (clfm-notify-generate-exit-box-buttons exit-boxes))))))) 61 | 62 | (defun clfm-notify-user-frame-manager 63 | (frame-manager 64 | &key frame associated-window message-body message-string width 65 | (title "") 66 | documentation 67 | (exit-boxes '((:exit "OK"))) 68 | ;; The 'name' arg is in the spec but absent from the Lispworks 69 | ;; manual, and I can't imagine what it would do differently 70 | ;; than 'title'. 71 | name 72 | style 73 | (text-style (make-text-style :sans-serif :roman :small))) 74 | (declare (ignore associated-window documentation)) 75 | (let ((frame (make-application-frame 'clfm-notify-user-frame 76 | :calling-frame frame 77 | :pretty-name title 78 | :message-string message-string 79 | :message-body message-body 80 | :frame-manager frame-manager 81 | :exit-boxes exit-boxes 82 | :title (or name title) 83 | :style style 84 | :text-style text-style 85 | :width width))) 86 | (run-frame-top-level frame) 87 | (slot-value frame 'return-value))) 88 | 89 | (defparameter *clfm-notify-pass-to-notification* nil) 90 | 91 | (defmacro clfm-notify ((frame message (&rest args-to-pass) &rest args) 92 | &body message-body) 93 | `(progn 94 | (setf *clfm-notify-pass-to-notification* 95 | `(,,@(loop for arg in args-to-pass 96 | collect arg))) 97 | (apply #'clfm-notify-user-frame-manager 98 | (if ,frame (frame-manager ,frame) (find-frame-manager)) 99 | :message-string ,message 100 | :message-body `(let ,(loop for arg in ',args-to-pass 101 | for v in *clfm-notify-pass-to-notification* 102 | collect `(,arg (handler-case ,v 103 | (t () 104 | ',v)))) 105 | ,@',message-body) 106 | :frame ,frame 107 | ',args))) 108 | -------------------------------------------------------------------------------- /fonts/ETBembo-RomanOSF-fake-sans-serif.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szos/CLFM/6ffdcea0d24ae5bc817e92487b014644e2b0fe0d/fonts/ETBembo-RomanOSF-fake-sans-serif.ttf -------------------------------------------------------------------------------- /fonts/et-book-bold-line-figures.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szos/CLFM/6ffdcea0d24ae5bc817e92487b014644e2b0fe0d/fonts/et-book-bold-line-figures.ttf -------------------------------------------------------------------------------- /fonts/et-book-display-italic-bold-old-style-figures.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szos/CLFM/6ffdcea0d24ae5bc817e92487b014644e2b0fe0d/fonts/et-book-display-italic-bold-old-style-figures.ttf -------------------------------------------------------------------------------- /fonts/et-book-display-italic-old-style-figures.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szos/CLFM/6ffdcea0d24ae5bc817e92487b014644e2b0fe0d/fonts/et-book-display-italic-old-style-figures.ttf -------------------------------------------------------------------------------- /fonts/et-book-roman-line-figures.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szos/CLFM/6ffdcea0d24ae5bc817e92487b014644e2b0fe0d/fonts/et-book-roman-line-figures.ttf -------------------------------------------------------------------------------- /fonts/et-book-roman-old-style-figures.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szos/CLFM/6ffdcea0d24ae5bc817e92487b014644e2b0fe0d/fonts/et-book-roman-old-style-figures.ttf -------------------------------------------------------------------------------- /fonts/et-book-semi-bold-old-style-figures.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szos/CLFM/6ffdcea0d24ae5bc817e92487b014644e2b0fe0d/fonts/et-book-semi-bold-old-style-figures.ttf -------------------------------------------------------------------------------- /fonts/et-book-super-bold-roman-old-style-figures.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/szos/CLFM/6ffdcea0d24ae5bc817e92487b014644e2b0fe0d/fonts/et-book-super-bold-roman-old-style-figures.ttf -------------------------------------------------------------------------------- /fonts/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Dmitry Krasny, Bonnie Scranton, Edward Tufte. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /help.lisp: -------------------------------------------------------------------------------- 1 | 2 | (in-package :clfm-2) 3 | 4 | (define-application-frame clfm-help () () 5 | (:menu-bar clfm-help-window-menu-bar) 6 | (:panes 7 | (keybindings :application 8 | :display-function #'help-display-keybindings 9 | :width 600) 10 | (generic :application 11 | :display-function #'help-display-generic 12 | :width 600)) 13 | (:layouts 14 | (default 15 | generic) 16 | (keybindings keybindings))) 17 | 18 | (define-clfm-help-command (com-switch-to-generic-page) () 19 | (setf (frame-current-layout *application-frame*) 'default)) 20 | 21 | (define-clfm-help-command (com-switch-to-keybindings-page) () 22 | (setf (frame-current-layout *application-frame*) 'keybindings)) 23 | 24 | ;; (define-clfm-help-command (com-switch-to-opening-files) () 25 | ;; ) 26 | 27 | (make-command-table 'clfm-help-window-menu-bar 28 | :errorp nil 29 | :menu 30 | '(("General" :command com-switch-to-generic-page) 31 | ("Keybindings" :command com-switch-to-keybindings-page))) 32 | 33 | (defun help-display-keybindings (frame pane) 34 | (declare (ignore frame)) 35 | (slim:with-table (pane) 36 | (slim:row (slim:cell (format pane "Keybindings: "))) 37 | (slim:row (slim:cell (format pane " "))) 38 | (slim:row 39 | (slim:cell (format pane "M-RET")) 40 | (slim:cell (format pane "Submit Input"))))) 41 | 42 | (defun help-display-generic (frame pane) 43 | (declare (ignore frame)) 44 | (with-end-of-line-action (pane :wrap*) 45 | (with-etbembo (pane :bold) 46 | (format pane "This is the help page for CLFM. It should contain documentation on the usage and settings of CLFM")) 47 | (terpri pane) 48 | (terpri pane) 49 | (with-etbembo (pane) 50 | (format pane "CLFM stands for ") 51 | (with-etbembo (pane :italic) 52 | (format pane "Common Lisp File Manager")) 53 | (format pane ". It is primarily mouse driven, though it is planned to implement keybindings (and an init file where users can change them) to drive this application via the keyboard. ")))) 54 | -------------------------------------------------------------------------------- /init.lisp: -------------------------------------------------------------------------------- 1 | ;;; This is an example init file, which has some basic configuration stuff. 2 | 3 | (in-package :clfm-2) 4 | 5 | (define-operation notify-me (item finished) 6 | (declare (ignore finished)) 7 | (when item 8 | (clfm-notify (*application-frame* "A Notification" (item)) 9 | (format pane "This is a notificaton of an item were operating on.") 10 | (print item pane)))) 11 | 12 | (file-prefer-marks) 13 | -------------------------------------------------------------------------------- /keybindings.lisp: -------------------------------------------------------------------------------- 1 | (in-package :clfm-2) 2 | 3 | (make-command-table 'clfm-control-x :errorp nil) 4 | 5 | (add-keystroke-to-command-table 'clfm '(#\x :control) :menu 'clfm-control-x 6 | :errorp nil) 7 | 8 | (add-keystroke-to-command-table 'clfm-control-x '(#\c :control) 9 | :command '(com-exit) 10 | :errorp nil) 11 | 12 | ;; (clim:add-keystroke-to-command-table 'clfm-control-x) 13 | ;;; this doesnt work, but it should.... hmmmmmm.... 14 | -------------------------------------------------------------------------------- /make-executable.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | LISP=$(which sbcl) 4 | exit="$?" 5 | 6 | if [ ! "$exit" -eq 0 ]; then 7 | /bin/echo -e "\e[1;31mSBCL not installed, exiting\e[0m" 8 | exit 1 9 | else 10 | /bin/echo -e "\e[1;32mSBCL is installed, proceeding\e[0m" 11 | fi 12 | 13 | sbcl --eval "(progn (handler-case (in-package :ql) (PACKAGE-DOES-NOT-EXIST () (exit :code 1))) (sb-ext:exit :code 0))" > /dev/null 2>&1 14 | 15 | exit="$?" 16 | 17 | if [ ! "$exit" -eq 0 ]; then 18 | /bin/echo -e "\e[1;31mQuicklisp not installed, exiting\e[0m" 19 | exit 1 20 | else 21 | /bin/echo -e "\e[1;32mQuicklisp is installed, proceeding\e[0m" 22 | fi 23 | 24 | sbcl --eval "(push #p\"./\" asdf:*central-registry*)" --eval "(ql:quickload :clfm-2)" --eval "(clfm-2::make-executable)" 25 | 26 | exit="$?" 27 | 28 | if [ ! "$exit" -eq 0 ]; then 29 | /bin/echo -e "\e[1;31m:CLFM not found, aborting\e[0m" 30 | exit 1 31 | fi 32 | 33 | -------------------------------------------------------------------------------- /mark-and-operate.lisp: -------------------------------------------------------------------------------- 1 | 2 | (in-package :clfm-2) 3 | 4 | (defparameter *marks* nil) 5 | 6 | (define-clfm-command (com-add-mark) ((mark string)) 7 | (if (member mark *marks* :test #'string=) 8 | (setf *marks* (remove mark *marks* :test #'string=)) 9 | (setf *marks* (cons mark *marks*)))) 10 | 11 | (define-clfm-command (com-add-mark) ((markl t)) 12 | (let ((mark (if (listp markl) 13 | (namestring (car markl)) 14 | markl))) 15 | (if (member mark *marks* :test #'string=) 16 | (setf *marks* (remove mark *marks* :test #'string=)) 17 | (setf *marks* (cons mark *marks*))))) 18 | 19 | (defun operate-on-marks (operation) 20 | (let* ((op (symbol-name operation)) 21 | (function 22 | (if (assoc operation *mark-operation-commands*) 23 | (cdr (assoc operation *mark-operation-commands*)) 24 | (let ((reter 25 | (clfm-notify (*application-frame* "Unknown Operation" 26 | (op) 27 | :exit-boxes ((t "Retry") 28 | (nil "OK")) 29 | :width 300 30 | :text-style 31 | ("ETBembo" "BoldLF" 18)) 32 | (with-end-of-line-action (pane :wrap*) 33 | (with-etbembo (pane nil 18) 34 | (format pane "The operation \"~a\" is unknown" 35 | op)))))) 36 | (when reter 37 | (com-operate-on-marks)))))) 38 | (when function 39 | (loop for thing in *marks* 40 | do (handler-case (funcall function thing nil) 41 | (t (err) 42 | (let ((ret (notify-user *application-frame* 43 | (format nil "Error '~a'~%was encountered while running~%function '~a'~%with argument '~a'" err function thing) 44 | :exit-boxes 45 | '((nil "Continue") 46 | (:destroy-marks "Abort") 47 | (t 48 | "Abort Preserving Marks")) 49 | :title "CLFM Mark Error"))) 50 | (when ret 51 | (when (eq :destroy-marks ret) 52 | (setf *marks* nil)) 53 | (return-from operate-on-marks)))))) 54 | (funcall function nil t) 55 | (setf *marks* nil)))) 56 | 57 | (define-clfm-command (com-operate-on-marks) () 58 | ;; ((function 'symbol :prompt "Function")) 59 | (let (fun 60 | (stream (frame-standard-input *application-frame*))) 61 | (accepting-values (stream 62 | :own-window t 63 | :initially-select-query-identifier 'function) 64 | (formatting-table (stream) 65 | (formatting-column (stream) 66 | (formatting-cell (stream) 67 | (setf fun (accept 'symbol 68 | :prompt "Operate Using Function" 69 | :stream stream 70 | :query-identifier 'function)))))) 71 | (operate-on-marks fun) 72 | ;; (if (assoc fun *mark-operation-commands*) 73 | ;; (operate-on-marks (cdr (assoc fun *mark-operation-commands*))) 74 | ;; (let ((reter 75 | ;; (clfm-notify (*application-frame* "Unknown Operation" (fun) 76 | ;; :exit-boxes ((t "Retry") 77 | ;; (nil "OK")) 78 | ;; :width 300 79 | ;; :text-style 80 | ;; ("ETBembo" "BoldLF" 18)) 81 | ;; (with-end-of-line-action (pane :wrap*) 82 | ;; (with-etbembo (pane nil 18) 83 | ;; (format pane "The operation \"~a\" is unknown" fun)))))) 84 | ;; (when reter 85 | ;; (com-operate-on-marks)))) 86 | )) 87 | 88 | ;;; IDEA: 89 | ;;; Make a «defcommand» type thing and an accompanying accept type to use which 90 | ;;; searches through all commands and then calls one that matches, searching as 91 | ;;; strings! - this would mean that in the command com-operate-on-marks, we first 92 | ;;; accept a string or symbol, and then search in our faux-database for it, and 93 | ;;; call the associated function! 94 | 95 | (defparameter *mark-operation-commands* nil) 96 | 97 | (defun replace-alist-entry (alist key value &optional unintern-value) 98 | (alexandria:when-let ((k (assoc key alist))) 99 | (when unintern-value 100 | (unintern (cdr k))) 101 | (setf (cdr k) value))) 102 | 103 | (defmacro define-operation (name args &body body) 104 | "This macro defines a function and stores it in an alist. these functions can be 105 | used to operate on marks. Each function must take two arguments - the item to be 106 | operated upon, and a finished argument. This function will be called on every mark 107 | with with the finished argument being nil. When no marks remain it will be called 108 | one last time with the item being nil and the finished argument being t. The 109 | function that is defined is named after a gensym and cannot be called normally. 110 | When redefining a command the old gensym is uninterned to keep the function 111 | namespace clean." 112 | (let ((n (gensym (symbol-name name)))) 113 | `(progn 114 | (unless (replace-alist-entry *mark-operation-commands* ',name ',n t) 115 | (setf *mark-operation-commands* 116 | (cons (cons ',name ',n) *mark-operation-commands*))) 117 | (defun ,n ,args ,@body)))) 118 | 119 | (define-operation delete (item finished) 120 | (declare (ignore finished)) 121 | (when item 122 | (let ((reter (clfm-notify (*application-frame* "IRREVERSIBLE OPERATION" nil 123 | :exit-boxes ((t "PROCEED") 124 | (nil "ABORT")) 125 | :width 400) 126 | (with-end-of-line-action (pane :wrap*) 127 | (with-etbembo (pane nil 18) 128 | (format pane "You are attempting to delete a file or directory. This operation is ") 129 | (with-etbembo (pane :bold 18) 130 | (format pane "IRREVERSIBLE")) 131 | (format pane ". Proceed with caution.")))))) 132 | (when reter 133 | (cond ((uiop:directory-exists-p item) 134 | (com-delete-directory item)) 135 | ((uiop:file-exists-p item) 136 | (com-rm-file item)) 137 | (t 138 | (clfm-notify (*application-frame* "Not a file or directory" (item) 139 | :width 400) 140 | (with-etbembo (pane :italic 18) 141 | (format pane "~a~%is not an existing file or directory, and cannot be deleted" item))))))))) 142 | 143 | (define-operation display (item finished) 144 | (declare (ignore finished)) 145 | (when item 146 | (let ((message "The item is: ")) 147 | (test/clfm-notify (*application-frame* message (item) 148 | :width 500) 149 | (with-end-of-line-action (pane :wrap*) 150 | (with-etbembo (pane) 151 | (format pane "~a" item))))))) 152 | 153 | (let (copy-to) 154 | (define-operation copy (item finished) 155 | (when finished (setf copy-to nil)) 156 | (when item 157 | (unless copy-to 158 | (let ((stream (frame-standard-input *application-frame*))) 159 | (accepting-values (stream :own-window t 160 | :initially-select-query-identifier 'copy) 161 | (formatting-table (stream) 162 | (formatting-column (stream) 163 | (formatting-cell (stream) 164 | (setf copy-to 165 | (accept 'string 166 | :prompt "Copy To" 167 | :stream stream 168 | :query-identifier 'copy)))))))) 169 | (ensure-directories-exist copy-to) 170 | (if (uiop:file-exists-p item) 171 | (%%copy-file item (concatenate 'string copy-to 172 | (coerce 173 | (reverse 174 | (loop for c across (reverse item) 175 | while (not (char= c #\/)) 176 | collect c)) 177 | 'string))) 178 | (%copy-directory-contents item copy-to))))) 179 | 180 | ;; (let (move-to) 181 | ;; (define-operation move (item finished) 182 | ;; (when finished (setf move-to nil)) 183 | ;; (when item 184 | ;; (unless move-to 185 | ;; (let ((stream (frame-standard-input *application-frame*))) 186 | ;; (accepting-values (stream :own-window t 187 | ;; :initially-select-query-identifier 'move) 188 | ;; (formatting-table (stream) 189 | ;; (formatting-column (stream) 190 | ;; (formatting-cell (stream) 191 | ;; (setf move-to 192 | ;; (accept 'string 193 | ;; :prompt "Move To" 194 | ;; :stream stream 195 | ;; :query-identifier 'move)))))))) 196 | ;; (com-move-to )) 197 | ;; )) 198 | -------------------------------------------------------------------------------- /move-file-directory.lisp: -------------------------------------------------------------------------------- 1 | (in-package :clfm-2) 2 | 3 | #+NIL 4 | (defun move-item (item new-item) 5 | (unless (file-or-directory-exists-p new-item) 6 | (let ((typeof-item (or (and (uiop:directory-exists-p item) :directory) 7 | (and (uiop:file-exists-p item) :file) 8 | :nonexistant)) 9 | (typeof-new-item (or (and (uiop:directory-exists-p item) :directory) 10 | (and (uiop:file-exists-p item) :file) 11 | :nonexistant))) 12 | (cond ((eq typeof-item :nonexistant) nil) 13 | ((eq typeof-item :directory) 14 | (when (eq typeof-new-item :nonexistant) 15 | )) 16 | ((eq typeof-item :file)))) 17 | (let ((r (reverse (coerce new-file 'list))) 18 | newpath) 19 | (cond ((uiop:directory-exists-p item) 20 | (if (and (char= (car r) #\/) ; if it ends in a / and contains other /s 21 | (string-contains (coerce (cdr r) 'string) #\/)) 22 | ;; then move to another directory name 23 | (rename-file item ))) 24 | ((uiop:file-exists-p item) 25 | ) 26 | ) 27 | (if (char= (car r) #\/) 28 | (if (string-contains (coerce (cdr r) 'string) #\/) 29 | ;; then we want to move it to some other directory 30 | nil 31 | ;; else we want to move it to something else in the current directory 32 | (setf newpath (concatenate 'string (namestring (uiop:getcwd)) 33 | new-file)))))) 34 | (if (string-contains new-file ))) 35 | 36 | ;; ok.. what we want to do here, is to immitate mv... we could just shell out, 37 | ;; but that isnt optimal... 38 | 39 | ;; (define-clfm-command ) 40 | -------------------------------------------------------------------------------- /open-files.lisp: -------------------------------------------------------------------------------- 1 | 2 | (in-package :clfm-2) 3 | 4 | (defun open-file (file) 5 | "Opens the provided file with the default application a la xdg-open" 6 | (check-type file string) 7 | (uiop:launch-program (format nil "xdg-open ~a" (escape-spaces file)))) 8 | 9 | (define-clfm-command (com-open-file) ((file string)) 10 | "This command opens a file after checking that it exists" 11 | (when (uiop:file-exists-p (escape-spaces file)) 12 | (open-file file))) 13 | 14 | (define-clfm-command (com-open-file-with) ((file string)) 15 | "Takes a file and prompts for a program to open it with" 16 | (let (program 17 | (stream (frame-standard-input *application-frame*)) 18 | ;; (x (framex )) 19 | ) 20 | (restart-case 21 | (progn 22 | (accepting-values (stream :own-window t 23 | :label "Enter Program" 24 | :initially-select-query-identifier 'program 25 | :resynchronize-every-pass t 26 | ;; :resize-frame t 27 | :height 150 28 | :width 500) 29 | (formatting-table (stream) 30 | (formatting-column (stream) 31 | (formatting-cell (stream) 32 | (setf program (accept 'string 33 | :prompt "Program" 34 | :stream stream 35 | :query-identifier 'program)))))) 36 | (and program (uiop:launch-program 37 | (format nil "~a ~a" program (escape-spaces file))))) 38 | (abort () ())))) 39 | -------------------------------------------------------------------------------- /package.lisp: -------------------------------------------------------------------------------- 1 | ;;;; package.lisp 2 | 3 | (defpackage #:clfm-2 4 | (:use #:clim #:clim-lisp #:clim-tab-layout #:clim-extensions) 5 | (:export "APP-MAIN")) 6 | -------------------------------------------------------------------------------- /password.lisp: -------------------------------------------------------------------------------- 1 | (in-package :clfm-2) 2 | 3 | (define-presentation-type password () 4 | :inherit-from '((string) 5 | :description "Password") 6 | :description "password") 7 | 8 | (define-presentation-method present (password (type password) stream 9 | (view textual-view) 10 | &key acceptably) 11 | (when acceptably (error "Not acceptably")) 12 | (write-string (make-string (length password) :initial-element #\*) stream)) 13 | 14 | (define-presentation-method accept ((type password) stream view ;; (view textual-view) 15 | &key) 16 | (let* ((s (stream-scan-pointer stream)) 17 | (p (with-output-recording-options (stream :draw nil :record nil) 18 | (read-token stream)))) 19 | (presentation-replace-input stream p 'password view 20 | :buffer-start s) 21 | (return-from accept p))) 22 | 23 | ;; (define-presentation-method accept ((type password) stream view ;; (view textual-view) 24 | ;; &key) 25 | ;; (let* ((s (stream-scan-pointer stream)) 26 | ;; (p (clim:with-output-recording-options (stream :draw t :record nil) 27 | ;; (read-token stream)))) 28 | ;; (presentation-replace-input stream p 'password view 29 | ;; :buffer-start s) 30 | ;; (return-from accept p))) 31 | -------------------------------------------------------------------------------- /rename-file-directory.lisp: -------------------------------------------------------------------------------- 1 | 2 | (in-package :clfm-2) 3 | 4 | (defun %rename-file-directory (&optional old-name new-name) 5 | (restart-case 6 | (let ((stream (frame-standard-input *application-frame*)) 7 | oldname newname) 8 | (accepting-values (stream :own-window t 9 | :label (or (and 10 | old-name 11 | (format nil "Rename ~a" old-name)) 12 | "Rename a file") 13 | :initially-select-query-identifier 14 | (or (and old-name 'newfile) 'file)) 15 | (formatting-table (stream) 16 | (or (and old-name (setf oldname old-name)) 17 | (formatting-row (stream) 18 | (formatting-column (stream) 19 | (formatting-cell (stream) 20 | (setf oldname (accept 'string 21 | :prompt "Filename " 22 | :stream stream 23 | :query-identifier 'file)))))) 24 | (or (and new-name (setf newname new-name)) 25 | (formatting-row (stream) 26 | (formatting-column (stream) 27 | (formatting-cell (stream) 28 | (setf newname (accept 'string 29 | :prompt "Rename to" 30 | :stream stream 31 | :query-identifier 'newfile)))))))) 32 | (and oldname newname (rename-file oldname newname))) 33 | (abort () ()))) 34 | 35 | (define-clfm-command (com-rename) ((thing string) (newname string)) 36 | (rename-file thing newname)) 37 | 38 | (define-clfm-command (com-rename-this) ((thing string)) 39 | (%rename-file-directory thing)) 40 | 41 | (define-clfm-command (com-rename-this) ((thing t)) 42 | (%rename-file-directory thing)) 43 | 44 | (define-clfm-command (com-rename-prompt) () 45 | (%rename-file-directory)) 46 | -------------------------------------------------------------------------------- /testing.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Testing Functions for CLFM 2 | 3 | * Display Current Directory 4 | Wish List: 5 | - We want to be able to mark items by 6 | - Clicking 7 | - Clicking and dragging to mark all items between pointer button press and release 8 | - Clicking and then Shift-Clicking to mark all items between the first item and the one Shift-Clicked 9 | - Marking the currently selected item (via C-SPC or M-SPC) 10 | - Marking multiple items by marking the currently selected item, navigating to another item, and marking it with M-SPC 11 | 12 | ** Ideas for Implementation 13 | We can have our display functions contained within a let, forming a closure, wherein a variable called ~current-directory-contents~ is bound. we can define another function within this let to update this variable whenever we change directory. When displaying the current directory, we should loop through this list instead of gathering the contents every time. This would be more efficcient when navigating the selected item than collecting the contents on every function call. 14 | #+BEGIN_SRC common-lisp 15 | (let ((current-directory-contents 16 | (append (sort (uiop:subdirectories (uiop:getcwd)) #'path<) 17 | (sort (uiop:directory-files (uiop:getcwd)) #'path<)))) 18 | (defun display-current-directory (frame pane) ...)) 19 | #+END_SRC 20 | However this introduces a problem - we want to have the selection be movable... perhaps we could have multiple variables, ~pre-selection-contents~, ~selected-item~, and ~post-selection-contents~. When we read a C-n or C-p keyboard event, we move the selection. If its C-n, we put ~selected-item~ at the head of ~pre-selection-contents~, and pop the first item of ~post-selected-contents~ and store it in ~selected-item~. if its C-p we do that in reverse. 21 | Of course, when displaying, we will have to reverse ~pre-selection-contents~. 22 | #+BEGIN_SRC common-lisp 23 | (let (pre-selection-contents 24 | (selected-item 25 | (car (append (sort (uiop:subdirectories (uiop:getcwd)) #'path<) 26 | (sort (uiop:directory-files (uiop:getcwd)) #'path<)))) 27 | (post-selection-contents 28 | (cdr (append (sort (uiop:subdirectories (uiop:getcwd)) #'path<) 29 | (sort (uiop:directory-files (uiop:getcwd)) #'path<))))) 30 | (defun change-directory (directory) 31 | (uiop:chdir directory) 32 | (let ((contents 33 | (append (sort (uiop:subdirectories (uiop:getcwd)) #'path<) 34 | (sort (uiop:directory-files (uiop:getcwd)) #'path<)))) 35 | (setf pre-selection-contents nil 36 | selected-item (car contents) 37 | post-selection-contents (cdr contents)))) 38 | (defun move-selection-up () 39 | (when pre-selection-contents 40 | (setf post-selection-contents (cons selected-item post-selection-contents)) 41 | (setf selected-item (pop pre-selection-contents)))) 42 | (defun move-selection-down () 43 | (when post-selection-contents 44 | (setf pre-selection-contents (cons selected-item pre-selection-contents)) 45 | (setf selected-item (pop post-selection-contents)))) 46 | (defun display-current-directory (frame pane) 47 | (labels ((display-item (path &optional current) 48 | (with-drawing-options (pane (when current '(:ink +flipping-ink+))) 49 | (let ((stat (handler-case (osicat-posix:stat path) (t () nil)))) 50 | (with-output-as-presentation (pane 51 | (namestring path) 52 | 'filesystem-presentation 53 | :single-box t) 54 | (slim:row 55 | (with-drawing-options 56 | (pane :ink (if (member (namestring path) *marks* 57 | :test #'string=) 58 | +orange-red+ +black+)) 59 | (with-text-style 60 | (pane (make-text-style 61 | "ETBembo" (if (member (namestring path) 62 | ,*marks* 63 | :test #'string=) 64 | "DisplayItalicBold" "RomanLF") 65 | 16)) 66 | (slim:cell 67 | (if (uiop:directory-exists-p path) 68 | (with-drawing-options 69 | (pane :ink (if (member (namestring path) 70 | ,*marks* 71 | :test #'string=) 72 | +orange-red+ +blue+)) 73 | (format pane "DIR")) 74 | (with-drawing-options 75 | (pane :ink (if (member (namestring path) 76 | ,*marks* 77 | :test #'string=) 78 | +orange-red+ +green4+)) 79 | (format pane "FILE")))) 80 | (slim:cell (format pane "~a" (file/directory-name 81 | (namestring path)))) 82 | (slim:cell 83 | (format pane "~a" 84 | (cdr 85 | (assoc 86 | (format nil "~a" 87 | (and stat 88 | (osicat-posix:stat-uid stat))) 89 | ,*uid-username* :test #'string-equal)))) 90 | (slim:cell 91 | (format pane "~a" 92 | (and stat (permissions-as-string 93 | (namestring-path))))))))))))) 94 | (loop for path in (reverse pre-selection-contents) 95 | unless (and *hide-files* (hidden-pathname-p path)) 96 | do (display-item path)) 97 | (display-item selected-item) 98 | (loop for path in post-selection-contents 99 | unless (and *hide-files* (hidden-pathname-p path)) 100 | do (display-item path))))) 101 | #+END_SRC 102 | 103 | ** Here is an updated version that is currently working 104 | #+BEGIN_SRC common-lisp 105 | (let (pre-selection-contents 106 | (selected-item 107 | (let ((all (append (sort (uiop:subdirectories (uiop:getcwd)) #'path<) 108 | (sort (uiop:directory-files (uiop:getcwd)) #'path<)))) 109 | (if *hide-files* 110 | (loop for path in all 111 | unless (hidden-pathname-p path) 112 | return path) 113 | (car all)))) 114 | (post-selection-contents 115 | (let ((all (append (sort (uiop:subdirectories (uiop:getcwd)) #'path<) 116 | (sort (uiop:directory-files (uiop:getcwd)) #'path<)))) 117 | (if *hide-files* 118 | (cdr (remove-if #'hidden-pathname-p all)) 119 | (cdr all))))) 120 | (defun change-directory (directory) 121 | (uiop:chdir directory) 122 | (let ((contents 123 | (append (sort (uiop:subdirectories (uiop:getcwd)) #'path<) 124 | (sort (uiop:directory-files (uiop:getcwd)) #'path<)))) 125 | (setf pre-selection-contents nil 126 | selected-item (car contents) 127 | post-selection-contents (cdr contents)))) 128 | (defun move-selection-up () 129 | (when pre-selection-contents 130 | (setf post-selection-contents (cons selected-item post-selection-contents)) 131 | (setf selected-item (pop pre-selection-contents)))) 132 | (defun move-selection-down () 133 | (when post-selection-contents 134 | (setf pre-selection-contents (cons selected-item pre-selection-contents)) 135 | (setf selected-item (pop post-selection-contents)))) 136 | (defun display-current-directory (frame pane) 137 | (declare (ignore frame)) 138 | (slim:with-table (pane) 139 | (labels ((display-item (path &optional current) 140 | (let ((stat (handler-case (osicat-posix:stat path) (t () nil)))) 141 | (with-output-as-presentation (pane 142 | (namestring path) 143 | 'filesystem-presentation 144 | :single-box t) 145 | (slim:row 146 | (slim:cell 147 | (if (member (namestring path) 148 | ,*marks* :test #'string-equal) 149 | (with-drawing-options (pane :ink +red+) 150 | (format pane "*")) 151 | (with-drawing-options (pane :ink +black+) 152 | (format pane " ")))) 153 | (with-drawing-options 154 | (pane :ink (if (member (namestring path) *marks* 155 | :test #'string=) 156 | +orange-red+ 157 | (if current +purple+ +black+))) 158 | (with-text-style 159 | (pane (make-text-style 160 | "ETBembo" (if (member (namestring path) 161 | ,*marks* 162 | :test #'string=) 163 | "DisplayItalicBold" "RomanLF") 164 | 16)) 165 | (slim:cell 166 | (if (uiop:directory-exists-p path) 167 | (with-drawing-options 168 | (pane :ink (if (member (namestring path) 169 | ,*marks* 170 | :test #'string=) 171 | +orange-red+ +blue+)) 172 | (format pane "DIR")) 173 | (with-drawing-options 174 | (pane :ink (if (member (namestring path) 175 | ,*marks* 176 | :test #'string=) 177 | +orange-red+ +green4+)) 178 | (format pane "FILE")))) 179 | (slim:cell (format pane "~a" (file/directory-name 180 | (namestring path)))) 181 | (slim:cell 182 | (format pane "~a" 183 | (cdr 184 | (assoc 185 | (format nil "~a" 186 | (and stat 187 | (osicat-posix:stat-uid stat))) 188 | ,*uid-username* :test #'string-equal)))) 189 | (slim:cell 190 | (format pane "~a" 191 | (and stat (permissions-as-string 192 | (namestring path)))))))))) 193 | ;; (with-drawing-options (pane :ink (if current +white+ +black+)) 194 | ;; ) 195 | )) 196 | (loop for path in (reverse pre-selection-contents) 197 | unless (and *hide-files* (hidden-pathname-p path)) 198 | do (display-item path)) 199 | (display-item selected-item t) 200 | (loop for path in post-selection-contents 201 | unless (and *hide-files* (hidden-pathname-p path)) 202 | do (display-item path)))))) 203 | #+END_SRC 204 | --------------------------------------------------------------------------------